Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip: install dependencies as editable

I have an in-house Python application that deploys as a collection of packages, and I need a way for a developer to quickly check out all of these packages as editable source, so that the entire application can be edited in situ, and changes in all packages easily pushed back to the original git server. In addition, the application needs to be deployable as traditional packages by a non-developer.

Say I have a top-level package that has a setup.py looking like this:

# ...
setup(name="Foo",
      # ...
      url="https://mygitserver.com/Foo",
      install_requires=[
          "Bar>=0.0.1",
      ],
      dependency_links=["git+https://mygitserver.com/[email protected]#egg=Bar-0.0.1",],
      # ...
  )

I can install this package as editable with the following command:

pip3 install -e git+https://[email protected]/Foo#egg=Foo --process-dependency-links

This will create a directory src/foo and populate it with the source code for Foo checked out from the git server. This is good.

The dependency, Bar, is also retrieved from the git server, but it is not installed as editable. pip3 freeze just shows it as a regular installed package called Bar, so the git URL is also lost.

Is there a way to intervene somehow and have pip install some (not necessarily all) dependencies as editable? Or will I need to use a requirements.txt in this case? If I have to use requirements.txt, how do I also ensure these dependencies are installed normally when deployed by a non-developer?

I know that pip > 10 is meant to do away with dependency_links however for the moment I'm stuck with pip 9.0.2. I'm using Python 3.5. I'm targeting an embedded platform that makes it difficult to change these, so these versions are what I'm working with for the moment. If pip >= 10 can do something new to help in this area then I can look into upgrading, it's just not trivial to do on this system.

like image 460
davidA Avatar asked Nov 30 '25 19:11

davidA


1 Answers

You could simply pip install -e <Bar-URL> before anything and then, when you install Foo, pip would figure out the dependency was already installed. Both would be editable.

like image 172
rsalmei Avatar answered Dec 02 '25 09:12

rsalmei