英文:
Upgrade a self hosted python package from within a python session
问题
We are developing a python package hosted on our own Bitbucket. So far the upgrade of the package works fine from the terminal:
python -m pip install --upgrade --no-cache-dir git+ssh://git@{package_git_url}
The idea is to let the user upgrade the package from within its notebook as the package development is in early stage. For this we use this method within the package:
def upgrade(self):
subprocess.run(
[
"python",
"-m",
"pip",
"install",
"--upgrade",
"--no-cache-dir",
self.config.PIP.URL,
]
)
But when calling this function within python, it does not upgrade the package in the virtual environment. Hence my question: is it possible to upgrade a python package from within a python session?
英文:
We are developing a python package hosted on our own Bitbucket. So far the upgrade of the package works fine from the terminal :
python -m pip install --upgrade --no-cache-dir git+ssh://git@{package_git_url}
The idea is to let the user upgrade the package from within its notebook as the package development is in early stage. For this we use this method within the package :
def upgrade(self):
subprocess.run(
[
"python",
"-m",
"pip",
"install",
"--upgrade",
"--no-cache-dir",
self.config.PIP.URL,
]
)
But when calling this function within python, it does not upgrade the package in the virtual environment. Hence my question : is it possible to upgrade a python package from within a python session ?
答案1
得分: 0
@Klaus D.:亲爱的朋友,你太棒了!只需按照以下方式调整upgrade
函数:
import sys
from pathlib import Path
def upgrade(self):
executable = Path(sys.executable).resolve()
subprocess.run(
[
executable,
"-m",
"pip",
"install",
"--upgrade",
"--no-cache-dir",
self.config.PIP.URL,
]
)
猜猜?它有效。感谢你的帮助!
英文:
@Klaus D. : beste Man, you rock ! just adjusted the upgrade
function as follow :
import sys
from pathlib import Path
def upgrade(self):
executable = Path(sys.executable).resolve()
subprocess.run(
[
executable,
"-m",
"pip",
"install",
"--upgrade",
"--no-cache-dir",
self.config.PIP.URL,
]
)
and guess what ? it works. Thanks for your help !
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论