I have a project from which I would like to generate two separate python packages. I want to install these packages using pip.
In answers to this previous question, the general recommendation was to write two setup.py
scripts: Multiple projects from one setup.py?
So I tried a structure like this:
/myproject
setup_foo.py
setup_bar.py
/mypackage1
/mypackage2
...
In setup_foo.py
I set the script_name
parameter:
from distutils.core import setup
setup(name = 'foo',
version = '2.0.0',
...,
script_name = 'setup_foo.py')
(I also tried the below without the parameter - according to the documentation it defaults to sys.argv[0])
I create foo-2.0.0.tar.gz
using
python setup_foo.py sdist
But when I pip install foo-2.0.0.tar.gz
, I get an error like this:
Unpacking .../foo-2.0.0.tar.gz
Running setup.py egg_info for package from file:///...foo-2.0.0.tar.gz
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory: '/var/folders/wj/jv7n2pmn5d1g1jjx6khc8bx80000gn/T/pip-v3dujq-build/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory:
'/var/folders/wj/jv7n2pmn5d1g1jjx6khc8bx80000gn/T/pip-v3dujq-build/setup.py'
Am I missing some way of instructing pip
to use setup_foo.py
? Or should I place two scripts, both named 'setup.py', in separate directories?
The question is why you put those projects into one directory. My recommendation would be to properly separate them, and then add them to a shared virtualenv via "setup.py develop -U". Been there, done that, works beautifully.
Otherwise, your next problem will be sharing a "setup.cfg", "MANIFEST.in", etc. In general you'll have a lot of unnecessary pain, each time you break assumptions of setuptools / distribute.
I suppose you chose the above structure so both packages are in the python path automagically, the "develop -U" makes it explicit, and quoting "import this":
Explicit is better than implicit.