Reputation: 12879
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.
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.
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?
Upvotes: 8
Views: 18075
Reputation: 39834
You could install with -e
your package into your local python installation or wherever you desire, then symlink that particular local package dir into your app's lib
dir:
ln -s /my/local/package /my/sample/application/lib/
Upvotes: 1
Reputation: 12879
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
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.
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.
Upvotes: 5
Reputation: 585
Adapting the instructions from Jeffrey Godwyll's Google App Engine Vendoring Done Right worked for me:
cd ~/app-engine-project-directory
mkdir lib
ln -s env/lib/python2.7/site-packages lib
pip install -e ../my-local-dependency
(Of course, you may need to change the third line depending on which version of Python you're using.)
Upvotes: 3