Mineo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/86435


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/35/86435/1

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"])

-- 
To view, visit https://gerrit.wikimedia.org/r/86435
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd1794481b4b57c001fed8df0bf8178bb5eccc30
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mineo <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to