I would like to call the setup () function of the Python distutils or setuptools functions in a slightly unconventional way, but I'm not sure if distutils are intended for such use.
As an example, suppose I currently have a setup.py file that looks like this (taken verbatim from distutils docs docs - using setuptools is almost identical):
from distutils.core import setup setup(name='Distutils', version='1.0', description='Python Distribution Utilities', author='Greg Ward', author_email='gward@python.net', url='http://www.python.org/sigs/distutils-sig/', packages=['distutils', 'distutils.command'], )
Usually, to create only the .spec file for the RPM of this module, I can run python setup.py bdist_rpm --spec-only , which parses the command line and calls the code "bdist_rpm" to process RPM-specific files. The .spec file falls into './dist'.
How can I change the setup () call so that it runs the “bdist_rpm” command with the “only-specialization” option, WITHOUT parsing command-line options? Can I pass the name and parameters of the command as parameters to setup ()? Or can I manually build the command line and pass this as a parameter instead?
NOTE. I already know that I could call the script in a separate process with the actual command line using os.system () or a subprocess module or something similar. I am trying to avoid using any external command calls. I am looking specifically for a solution that runs setup () in the current interpreter.
For the background, I convert some release shell scripts into a single Python program. One of the tasks is "setup.py" to create a .spec file for further testing before release. Running "setup.py" as an external command with its own command line parameters looks like an inconvenient method, and this complicates the rest of the program. I feel that there may be a more Pythonic way.
python setuptools distutils
Ryan B. Lynch
source share