[Distutils] inability to pass setup.py command line arguments to dependency setups
Kent
kb at retailarchitects.com
Fri May 7 15:09:00 CEST 2010
Consider the case where you want your setup to install third-party
software, but you want/need to pass an argument to the command line
that runs "python setup.py --argument install" or "python setup.py --
argument bdist_egg"
As far as I could research, this feature is unavailable.
If there is a graceful way to accomplish this I would really like to
know. If there is no way, I offer a workaround to those who require
this functionality.
Consider a setup.py with the following setup() function call:
________________________________________________________________________________________
setup(
name='pylotengine',
version='0.1',
description='',
author='',
author_email='',
install_requires=[
"SQLAlchemy >= 0.6",
"tg.devtools >= 2.0.1",
...
...
)
________________________________________________________________________________________
Now, when SQLAlchemy is to be installed, there is a really nice
feature that can be enabled to build it with C extensions for
performance, so you want easy_install to run:
"python setup.py --with-cextensions bdist_egg"
instead of just:
"python setup.py bdist_egg"
In order to pass the "--with-cextensions" argument, I do the following
(again, not a very graceful solution):
________________________________________________________________________________________
# -*- coding: utf-8 -*-
try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages
#kb: since apparently setuptools has no mechanism to pass
# arguments to the dependencies, I am "decorating" the function
# that runs the command and adding the arguments myself...
from setuptools.command.easy_install import easy_install
normal_run_setup_fn = easy_install.run_setup
def setup_hook(self, setup_script, setup_base, args):
# SQLAlchemy we want to run setup.py --with-cextensions
if setup_script.find('/SQLAlchemy') > -1 and
setup_script.endswith('setup.py'):
args.insert(0,'--with-cextensions')
normal_run_setup_fn(self, setup_script, setup_base, args)
easy_install.run_setup = setup_hook
setup(
name='pylotengine',
version='0.1',
description='',
author='',
author_email='',
#url='',
install_requires=[
#kb start
"SQLAlchemy >= 0.6",
"tg.devtools >= 2.0.1",
"psycopg2 >= 2.0.11",
...
...rest of setup() call...
________________________________________________________________________________________
Hope this is helpful to someone...
More information about the Distutils-SIG
mailing list