4

What is the best practice for installing Python libraries that are available on a VCS, but are not maintained as pip installable packages?

So far I've found lots of solutions that suggest just installing directly from GitHub, but those all appear to require that the maintainer has packaged for a pip install. There's also the option of installing from tarballs, but in this case, the maintainer does not offer an installable tarball.

There are several attempts on pypi to release this, but they are all out of date or have issues of one kind or another.

The library in question is for working with E-Paper displays from waveshare. The libraries I'd like to use are buried several directories deep within the git repository. To make things worse, the project is released without a license.txt, but does have a generic license text within each library file. The license text appears to grant a wide permission to include the libraries into any type of project (see the text below).

I've come up with a few options for dealing with this, but I hope there's something better:

  1. Copy the libraries into the project

    Issues:

    • libraries get stale
    • there's no easy way to update them except for manually copying into the project
  2. Repackage the libraries and upload to pip

    Issues:

    • I now need to maintain the pypi projects
    • They end up stale and with issues exactly like the ones I've found so far
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Aaron Ciuffo
  • 804
  • 8
  • 22
  • What about copying/filtering the subdirectory into your own private Git repo and installing from there? – Nils Werner Oct 27 '19 at 19:38
  • I can definitely copy the required subdir into my own repo. Is there a sane way to keep that copy fresh without manually pulling and recopying? I can script that, but it all feels like a huge kludge and doesn't make the project easy to deploy in the future. – Aaron Ciuffo Oct 27 '19 at 19:42
  • The code you've linked to is not really production quality... So if you're really going to deploy that project in a production environment you should have someone maintain that copied library anyways. – Nils Werner Oct 27 '19 at 19:44
  • It's for a home project, but one I can see using over and over again. I suppose I can add a line in the README.md that clues me in to update the libraries manually or with a script. Is this "good practice?" Or, is there a better way? – Aaron Ciuffo Oct 27 '19 at 19:46

2 Answers2

2

There is a setup.py and so it should be possible to install the project with the following command:

pip install -e 'git+https://github.com/waveshare/e-Paper.git#egg=waveshare-epd&subdirectory=RaspberryPi&JetsonNano/python'

But it fails since there is an ampersand (&) in the directory name. If it were possible to somehow escape that character, it would probably work.

sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • 1
    I had no idea that you could specify sub directories like that! That's a huge side-win. Thanks for teaching me that. – Aaron Ciuffo Oct 27 '19 at 19:53
  • I cloned the Repo and renamed the directory to remove the offending "&", but pip still has issues. It looks like it expects there to be a setup.py higher up in the tree: IOError: [Errno 2] No such file or directory: '/home/pi/src/slimpi_epd/src/waveshare-epd/setup.py' Any other ideas? – Aaron Ciuffo Oct 27 '19 at 20:20
  • `$ pip3 install -e git+https://github.com/txoof/e-Paper.git#egg=waveshare-epd&subdirectory=RaspberryPi_and_JetsonNano/python` That does clone the repo into ~/src/waveshare-epd, but errors out ultimately with: `FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/src/waveshare-epd/setup.py' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /home/pi/src/waveshare-epd/` – Aaron Ciuffo Oct 27 '19 at 20:38
  • 1
    Aaand. I'm an idiot. I forgot the quotes! Thanks for your help. This might be a good middle-of-the-road solution. – Aaron Ciuffo Oct 27 '19 at 21:00
  • 1
    If I were you, I would ask the maintainers of the project to fix the name of the folder. – sinoroc Oct 27 '19 at 21:14
  • I just did that. That would simplify things tremendously. – Aaron Ciuffo Oct 27 '19 at 21:34
0

I tried a few variants of url encoding, etc., but couldn't get it to go directly from pip... so I did the following instead:

git clone https://github.com/waveshare/e-Paper
cd e-Paper/RaspberryPi\&JetsonNano/
pip3 install -e .

Successfully installed waveshare-epd :D