Reputation: 10959
In Ruby, when I am simultaneously developing a library and an application, I can use Bundler's local override feature to make the application use my local copy of the library instead of trying to fetch from Github on my system. This is very convenient.
# 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
I am now facing a similar situation in Python. requirements.txt
is essentially equivalent to the Gemfile, but does pip
support local override functionality?
Upvotes: 1
Views: 159
Reputation: 6725
You can install an editable version of your library with pip install -e git+ssh://...#egg=package-name
(substitute your repository URL here). This will create a checkout of your library and put it into the python module search path. If you already have a local copy of the library, executing pip install -e /path/to/your/checkout
will do the same. If a non-editable version of your library is already installed, you may need to pass --upgrade
to pip.
Behind the scenes, pip will create a file called easy-install.pth
in your site-packages
directory, which then contains a line with the full path to the checkout of your library. You can read more about .pth
files in the official Python documentation; for more pip options, see the official pip documentation, here is the part about editable installs.
Upvotes: 2