[Distutils] Setuptools/Distribute - using from a
Vinay Sajip
vinay_sajip at yahoo.co.uk
Thu Feb 28 23:58:45 CET 2013
Paul Moore <p.f.moore <at> gmail.com> writes:
> distribute for the setup.py run? I've tried setting PYTHONPATH, but
> that doesn't seem to work
Here's what I tried. I set up the following work area:
.
├── pkg_resources.py -> /path/to/distribute/pkg_resources.py
├── runit.py
├── setuptools -> /path/to/distribute/setuptools/
└── work
├── mymodule.py
└── setup.py
Where /path/to/distribute is pointing into my clone of Distribute (i.e. an
uninstalled copy). Then, runit.py is analogous to your script:
import os
import subprocess
import sys
here = os.path.abspath(os.path.dirname(__file__))
# setuptools is available in os.path.join(here, 'setuptools')
# setuptools.pth and easy-install.pth are in here
os.environ['PYTHONPATH'] = here # this doesn't work
setup_py = 'work/setup.py'
setup_dir = os.path.abspath(os.path.dirname(setup_py))
subprocess.check_call([sys.executable, 'setup.py', 'sdist'], cwd=setup_dir)
Of course, I'm doing sdist rather than install, but IMO it should work in the
same way for install.
mymodule.py is an empty file, and setup.py is:
import setuptools
print('using setuptools from %s' % setuptools.__file__)
setuptools.setup(name='dummy', version='0.1', py_modules=['mymodule'])
Now, when in the top of my work area I run "python runit.py", I get:
$ python runit.py
using setuptools from /home/vinay/projects/scratch/junk/setuptools/__init__.pyc
running sdist
running egg_info
creating dummy.egg-info
writing dummy.egg-info/PKG-INFO
writing top-level names to dummy.egg-info/top_level.txt
writing dependency_links to dummy.egg-info/dependency_links.txt
writing manifest file 'dummy.egg-info/SOURCES.txt'
reading manifest file 'dummy.egg-info/SOURCES.txt'
writing manifest file 'dummy.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst,
README.txt
running check
warning: check: missing required meta-data: url
warning: check: missing meta-data: either (author and author_email) or
(maintainer and maintainer_email) must be supplied
creating dummy-0.1
creating dummy-0.1/dummy.egg-info
making hard links in dummy-0.1...
hard linking mymodule.py -> dummy-0.1
hard linking setup.py -> dummy-0.1
hard linking dummy.egg-info/PKG-INFO -> dummy-0.1/dummy.egg-info
hard linking dummy.egg-info/SOURCES.txt -> dummy-0.1/dummy.egg-info
hard linking dummy.egg-info/dependency_links.txt -> dummy-0.1/dummy.egg-info
hard linking dummy.egg-info/top_level.txt -> dummy-0.1/dummy.egg-info
Writing dummy-0.1/setup.cfg
creating dist
Creating tar archive
removing 'dummy-0.1' (and everything under it)
and my work area now looks like this:
.
├── pkg_resources.py -> /path/to/distribute/pkg_resources.py
├── pkg_resources.pyc
├── runit.py
├── setuptools -> /path/to/distribute/setuptools/
└── work
├── dist
│ └── dummy-0.1.tar.gz
├── dummy.egg-info
│ ├── dependency_links.txt
│ ├── PKG-INFO
│ ├── SOURCES.txt
│ └── top_level.txt
├── mymodule.py
└── setup.py
Note the pkg_resources.pyc file, plus the "using setuptools from ..." message,
indicating that it's not running some other setuptools,
This is on Linux and I used symlinks for this quick test, but I can't see why
it would be different for a copy.
Regards,
Vinay Sajip
More information about the Distutils-SIG
mailing list