[Distutils] setuptools deps
Phillip J. Eby
pje at telecommunity.com
Mon Aug 29 00:26:13 CEST 2005
At 04:45 PM 8/26/2005 +0200, Vincenzo Di Massa wrote:
>Hello,
>As you know I'm developing easy-deb using setuptools.
>I need a way to query a module dependencies, but I don't know how to
>achieve this.
>
>I need to know dependencies because when I install an egg into a package I
>don't want the dependencies to go into the same package.
>So I detect if setup.py uses setuptools (grep setuptools setup.py) and then:
>if the module uses setuptools:
> I call setup.py bdist_egg -d dest/pkg/dir
>else:
> I call easy_install.py -d dest/pkg/dir . # in the setup.py containing dir
>
>Is there a way to tell easy_install "don't install dependencies but tell
>me what they are".
>
>Better, I would like to be able to detect dependencies from inside python.
The way that easy_install does this sort of thing is to run the package's
setup script and execute a distutils command. The distutils command then
has access to the distribution metadata.
So, your high-level script could:
1. import setuptools
2. invoke easy_install --editable to download and extract the target package
3. use setuptools.sandbox.run_setup() to run the setup script, telling it
to run a 'bdist_easydeb' command or some such
4. Have the command access metadata directly from the setup() call, e.g.
the 'install_requires' attribute. Be prepared for the possibility that the
attribute(s) you're looking for might be None.
This is the easiest way to get information from a setup script, and with
the latest version of setuptools it should work fine even if the setup
script does not import setuptools itself.
More information about the Distutils-SIG
mailing list