setup.py --install-requires?
Is it possible to get the value of install_requires for an arbitrary package without having to parse setup.py? I see that --name, --version, --description, --provides, and so on are available as an argument to setup.py, but --install-requires is missing. Why? For example, zc.catalog declares these dependencies in its setup.py install_requires=['ZODB3', 'pytz', 'setuptools', 'zope.catalog', 'zope.container', 'zope.component', 'zope.i18nmessageid', 'zope.index>=3.5.1', 'zope.interface', 'zope.publisher', 'zope.schema', 'zope.security', ], Is it possible to reliably get this list in a custom Python code without having to parse setup.py?
Sridhar Ratnakumar wrote:
Is it possible to get the value of install_requires for an arbitrary package without having to parse setup.py?
I see that --name, --version, --description, --provides, and so on are available as an argument to setup.py, but --install-requires is missing. Why?
For example, zc.catalog declares these dependencies in its setup.py
install_requires=['ZODB3', 'pytz', 'setuptools', 'zope.catalog', 'zope.container', 'zope.component', 'zope.i18nmessageid', 'zope.index>=3.5.1', 'zope.interface', 'zope.publisher', 'zope.schema', 'zope.security', ],
Is it possible to reliably get this list in a custom Python code without having to parse setup.py?
stdeb does it like this: install_requires = \ open(os.path.join(egg_info_dirname,'requires.txt'),'rU').read()
At 01:28 PM 4/8/2009 -0700, Sridhar Ratnakumar wrote:
For example, zc.catalog declares these dependencies in its setup.py
install_requires=['ZODB3', 'pytz', 'setuptools', 'zope.catalog', 'zope.container', 'zope.component', 'zope.i18nmessageid', 'zope.index>=3.5.1', 'zope.interface', 'zope.publisher', 'zope.schema', 'zope.security', ],
Is it possible to reliably get this list in a custom Python code without having to parse setup.py?
Something like this should do the trick: import tempfile, os.path from setuptools.sandbox import run_setup def get_requires(setup_dir, empty_tmpdir): tmpdir = tempfile.mkdtemp(prefix="egginfotmp-") run_setup(os.path.join(setup_dir,'setup.py'), ['-e', tmpdir]) for dist in pkg_resources.find_distributions(tmpdir, True): return dist.requires() else: raise RuntimeError("egg_info didn't work") You'll get back a list of pkg_resources.Requirement objects rather than strings, but you can turn them back into strings if you like.
On 08/04/09 02:53 PM, P.J. Eby wrote:
Something like this should do the trick:
import tempfile, os.path from setuptools.sandbox import run_setup
def get_requires(setup_dir, empty_tmpdir): tmpdir = tempfile.mkdtemp(prefix="egginfotmp-") run_setup(os.path.join(setup_dir,'setup.py'), ['-e', tmpdir]) for dist in pkg_resources.find_distributions(tmpdir, True): return dist.requires() else: raise RuntimeError("egg_info didn't work")
That doesn't look like very reliable. It failed with both zc.catalog[1] and pip[2]. [1] error: option -e not recognized [2] IOError: No such file or directory: 'pip-0.3.1/docs/index.txt'
At 04:48 PM 4/8/2009 -0700, Sridhar Ratnakumar wrote:
On 08/04/09 02:53 PM, P.J. Eby wrote:
Something like this should do the trick:
import tempfile, os.path from setuptools.sandbox import run_setup
def get_requires(setup_dir, empty_tmpdir): tmpdir = tempfile.mkdtemp(prefix="egginfotmp-") run_setup(os.path.join(setup_dir,'setup.py'), ['-e', tmpdir]) for dist in pkg_resources.find_distributions(tmpdir, True): return dist.requires() else: raise RuntimeError("egg_info didn't work")
That doesn't look like very reliable. It failed with both zc.catalog[1] and pip[2].
[1] error: option -e not recognized [2] IOError: No such file or directory: 'pip-0.3.1/docs/index.txt'
Whoops... that should be ['egg_info', '-e', tmpdir]
participants (3)
-
Andrew Straw -
P.J. Eby -
Sridhar Ratnakumar