stephenfin
stephenfin

Reputation: 1467

Installing dependencies only - setuptools

I have a Python script, with several external dependencies, that I wish to distribute to colleagues. However, we will need to modify this script regularly so I don't want to install it per-se (i.e. copy to site-packages). From what I've seen setuptools seems to do this implicitly.

Is there a recommended approach to installing dependencies without installing the application/script itself?

Upvotes: 3

Views: 2436

Answers (2)

MatrixManAtYrService
MatrixManAtYrService

Reputation: 9131

You can install the package in development mode. This way changes to the code are reflected immediately, rather than needing the package to be reinstalled, which seems to be the problem you're working around:

python setup.py develop

Docs: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode

Upvotes: 0

Christer Nissen
Christer Nissen

Reputation: 485

You probably want to make sure that you and your colleagues use the same dependencies during development.

I think I would try to use virtualenv for this. If you and your collegues install it, it will give you a python environment for this project only, and dependencies for this project only.

So the steps would be:

  1. Everybody installs virtualenv on their computers so they get an isolated environment to use for development of this project only.

  2. One of you determine the current dependencies and installs them in your virtualenv.

  3. You export a list of your used dependencies using this command:

    (inside virtual environment) pip freeze > requirements.txt

  4. You then share this text file with the others. They use this command to import the exact same packages and versions into their virtual environment:

    (inside virtual environent) pip install -r requirements.txt

Just make sure that everybody enters their virtual environment before issuing these commands, otherwise the text file will contain their normal python environment installed packages.

Upvotes: 4

Related Questions