Mat
Mat

Reputation: 86562

How can I pip install for development?

I'm trying to pip install a GitHub project locally, outside of site-packages so that I can modify it, etc.

I've added -e [email protected]:Starcross/django-starcross-gallery.git#egg=gallery to my requirements.txt which brings the relevant part of my project layout to look like this:

/home/mat/venv/proj/
└── src
    └── gallery
        ├── admin.py
        ├── apps.py
        ├── build.sh
        ├── django_starcross_gallery.egg-info
        │   ├── dependency_links.txt
        │   ├── PKG-INFO
        │   ├── requires.txt
        │   ├── SOURCES.txt
        │   └── top_level.txt
        ├── forms.py
        ├── __init__.py
        ├── LICENSE
        ├── MANIFEST.in
        ├── models.py
        ├── README.rst
        ├── settings.py
        ├── setup.py
        ├── signals.py
        ├── static
        │   └── ...
        ├── templates
        │   └── ...
        ├── tests
        │   └── ...
        ├── tests.py
        ├── urls.py
        └── views.py

As far as I can see the problem is that these .egg-link and .pth files like one level too deep:

lib/python3.6/site-packages/django-starcross-gallery.egg-link:
/home/mat/venv/proj/src/gallery
.

lib/python3.6/site-packages/easy-install.pth:
/home/mat/venv/proj/src/gallery

I can fix everything by either moving gallery a level deeper, or changing django-starcross-gallery.egg-link and easy-install.pth to point to src.

Is there a config parameter I can pass in requirements.txt to make this work properly? Or do I have to adjust the project layout to fit?

Upvotes: 1

Views: 646

Answers (2)

starcross
starcross

Reputation: 13

As has been mentioned, the best way to do this is to clone the repo. This would go for most packages as pip may build extensions, and carry other actions during install aimed at using the module for production rather than editing the source.

To explain why I chose this structure, I wanted to be able to develop the package inside a Django project. As the Django docs say, the app should be placed in a separate directory, which enables setuptools to install the package correctly. There is no way I could find that would enable this to continue to work inside a project, hence the build script to move the files into a suitable directory and generate the package.

Upvotes: 0

CtheSky
CtheSky

Reputation: 2624

Since you want to modify it, why not just clone the repo. To make your interpreter able to find and use it, you have some options:

  • modify your sys.path, append path to the repo
  • create a symlink under your project directory that points to the repo

And in this way, you don't have to pip install every time you modify it.

Upvotes: 0

Related Questions