How to use packages on the local filesystem?
I have two libraries, lib1 and lib2 and a program that uses them, program1. The libraries have setup.py files that look like this:
from distutils.core import setup setup(name='lib1', version='0.1.0', maintainer='foven', email@example.com', url='example.com/lib1', packages=[ ] )
The setup.py for lib2 obviously replaces lib1 instances with lib2, but is otherwise the same.
Now program1 has a requirements.txt file, that looks like this:
-e ../lib1 -e ../lib2
I want to use the two libraries from their locations on the filesystem, since I'm not ready to put these into the repository yet. When running pip install -r requirements.txt for program1, this seems to work.
However, if I change the lib1/setup.py file to look like this:
from distutils.core import setup setup(name='lib1', version='0.1.0', maintainer='foven', firstname.lastname@example.org', url='example.com/lib1', packages=[ 'axel' ] )
and change program1/requirements.txt to this:
axel == 0.0.4 -e ../lib1 -e ../lib2
running pip install -r requirements.txt from program1 results in an error:
error: package directory 'axel' does not exist
Yet, pip list and pip freeze both indicate that the package is installed.
To me, it seems as though pip is not looking for axel in the normal location for installed packages or in pypi, but I don't have much experience with this, so I could be totally wrong. If I create an empty directory lib1/axel and run pip install -r requirements.txt for program1, it seems to work:
Obtaining file:///C:/Users/foven/code/lib1 (from -r requirements.txt (line 2)) Obtaining file:///C:/Users/foven/code/lib2 (from -r requirements.txt (line 3)) Requirement already satisfied (use --upgrade to upgrade): axel==0.0.4 in c:\program files\python35\lib\site-packages (from -r requirements.txt (line 1)) Installing collected packages: lib1, lib2 Running setup.py develop for lib1 Running setup.py develop for lib2 Successfully installed lib1-0.1.0 lib2-0.1.0
Just to be clear, I'll restate my goal: I want to be able to use the two libraries that only exist on the local filesytem with the program I am working on. What am I doing wrong and how should I setup these libraries and the program to work the way I want?
packages is for listing the packages within the package you're creating. install_requires is for listing the packages your package depends on. You put a dependency, 'axel', in packages. There's no internal package called 'axel', so of course the directory with that name can't be found.
setup( ..., install_requires=['axel'], ... )