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?
Install the downloaded package into a local directory : python get-pip.py --user This will install pip to your local directory (. local/bin) . Now you may navigate to this directory (cd . local/bin) and then use pip or better set your $PATH variable this directory to use pip anywhere : PATH=$PATH:~/.
Click on the Advanced system settings link on the left panel. Click Environment Variables. Under System Variables, double-click the variable PATH. Click New, and add the directory where pip is installed, e.g. C:Python33Scripts, and select OK.
To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With