pip将本地软件包安装到目标目录
我有一个发布到PyPI的Python库.在推送该库的每个新版本之前,我想通过将示例应用程序升级为使用新版本来对其进行测试.
I have a Python library that is published to PyPI. Before pushing each new version of the library, I want to test it by upgrading a sample application to use the new version.
建议的方法使用 -e
(-editable
)标志在开发模式"下工作:
The suggested method to do this is to work in "development mode" using the -e
(--editable
) flag:
$ pip install -e <my package root>
这确实将软件包安装到了我的全局环境中.
And this does indeed install the package into my global environment.
但是,我的示例程序是为Google App Engine编写的,它要求
However, my sample program is written for Google App Engine, which requires that all third-party libraries be copied into an application-specific folder (./lib
in my case). I normally install packages here by using the -t
(--target
) option to pip:
$ pip install -t lib/ <package>
However, it appears that the -e
and -t
options are not compatible, and my attempts to install my local, unpublished library to a specified target folder by using both flags together fail.
在发布之前,如何通过将其安装在自定义目录中来测试我的库包?
How can I test my library package by installing it in a custom directory before publishing?
对于新软件包的一次性测试,最好直接从本地文件系统安装:
For one-time testing of a new package, installing directly from the local filesystem seems to be the best bet:
$ cd /my/sample/application
$ pip install -t lib /my/local/package
当我对本地软件包进行进一步的更改时,此安装将不会保持同步(就像我要使用 pip install --editable
一样),但是我可以不用这样做此用例.
This install won't stay in sync as I make further changes to the local package (as it would if I were to use pip install --editable
), but I can live without that for this use case.
由于 pip install -e
I couldn't get @pbaranay's answer to work because of the way pip install -e
uses "egg-info" files that apparently are not understood/traversed by GAE's dev_appserver.py script. The suggestion to create a virtualenv and symlink it to lib (rather than installing packages directly to lib with -t
) is a good one, though.