jenkins-bot has submitted this change and it was merged.
Change subject: setup.py: Only run generate_user_files.py after installing the package ......................................................................
setup.py: Only run generate_user_files.py after installing the package
Otherwise it will even be run after `python setup.py --help` and other commands where it doesn't make sense.
Change-Id: Idd1794481b4b57c001fed8df0bf8178bb5eccc30 --- M setup.py 1 file changed, 18 insertions(+), 8 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/setup.py b/setup.py index 912c242..a38cfe8 100644 --- a/setup.py +++ b/setup.py @@ -15,11 +15,25 @@ use_setuptools()
from setuptools import setup, find_packages +from setuptools.command import install
if sys.version_info[0] != 2: raise RuntimeError("ERROR: Pywikipediabot only runs under Python 2") elif sys.version_info[1] < 6: raise RuntimeError("ERROR: Pywikipediabot only runs under Python 2.6 or higher") + + +class pwb_install(install.install): + """ + Setuptools' install command subclassed to automatically call + `generate_user_files.py` after installing the package. + """ + def run(self): + install.install.run(self) + import subprocess + python = sys.executable + python = python.replace("pythonw.exe", "python.exe") # for Windows + subprocess.call([python, "generate_user_files.py"])
setup( name='Pywikipediabot', @@ -42,12 +56,8 @@ 'Environment :: Console', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7' - ] + ], + cmdclass={ + 'install': pwb_install + } ) - -# automatically launch generate_user_files.py - -import subprocess -python = sys.executable -python = python.replace("pythonw.exe", "python.exe") # for Windows -ignore = subprocess.call([python, "generate_user_files.py"])