Pip等价于Bundler Local Overrid

2024-04-18 16:30:38 发布

您现在位置:Python中文网/ 问答频道 /正文

在Ruby中,当我同时开发一个库和一个应用程序时,我可以使用Bundler的local override特性使应用程序使用库的本地副本,而不是试图从系统上的Github获取。这很方便。你知道吗

# Given my application's Gemfile with this one line...
gem 'mylib', :github => 'smackesey/mylib', :branch => 'master'

# I can run this once in my shell...
bundle config local.mylib /path/to/mylib

# And now on my system, the app will use the copy at /path/to/my/lib

我现在在Python中也面临类似的情况。requirements.txt本质上等同于Gemfile,但是pip是否支持本地重写功能?你知道吗


Tags: thetopath应用程序mylocal系统副本
1条回答
网友
1楼 · 发布于 2024-04-18 16:30:38

您可以使用pip install -e git+ssh://...#egg=package-name(此处替换your repository URL)安装库的可编辑版本。这将创建库的签出并将其放入python模块搜索路径。如果已经有库的本地副本,那么执行pip install -e /path/to/your/checkout也会执行同样的操作。如果已经安装了库的不可编辑版本,则可能需要将 upgrade传递给pip。你知道吗

在幕后,pip将在site-packages目录中创建一个名为easy-install.pth的文件,其中包含一行指向库签出的完整路径。您可以阅读更多关于.pth文件in the official Python documentation;有关更多pip选项,请参阅the official pip documentationhere是关于editable installs的部分。你知道吗

相关问题 更多 >