jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/563431 )

Change subject: [bugfix] Fix broken get_version() in setup.py
......................................................................

[bugfix] Fix broken get_version() in setup.py

`python setup.py sdist` does not include .git folder, which
get_version() from setup.py relies on. Therefore
`python setup.py install` from sdist package (also called when running
`pip install pywikibot`) identifies itself with a fallback version
3.0.dev0. This breaks pip when running tasks like `pip freeze`
or `pip install --upgrade`.

This patch adds a possibility to get version from pkg_resources module
of setuptools in such case.

Bug: T198374
Change-Id: Id833db9cf38158afc96d4b5e6e4822c14b6bb485
---
M setup.py
1 file changed, 9 insertions(+), 4 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/setup.py b/setup.py
index 56bf1c2..69e12d7 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 """Installer script for Pywikibot 3.0 framework."""
 #
-# (C) Pywikibot team, 2009-2019
+# (C) Pywikibot team, 2009-2020
 #
 # Distributed under the terms of the MIT license.
 #
@@ -164,7 +164,7 @@
 test_deps += ['six;python_version>="3"']


-def get_version():
+def get_version(name):
     """Get a valid pywikibot module version string."""
     version = '3.0'
     try:
@@ -177,7 +177,12 @@
             version += '.dev0'
     except Exception as e:
         print(e)
-        version += '.dev0'
+        from pkg_resources import get_distribution, DistributionNotFound
+        try:
+            version = get_distribution(name).version
+        except DistributionNotFound as e:
+            print(e)
+            version += '.dev0'
     return version


@@ -205,7 +210,7 @@
 name = 'pywikibot'
 setup(
     name=name,
-    version=get_version(),
+    version=get_version(name),
     description='Python MediaWiki Bot Framework',
     long_description=read_desc('README.rst'),
     keywords=['API', 'bot', 'framework', 'mediawiki', 'pwb', 'python',

--
To view, visit https://gerrit.wikimedia.org/r/563431
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id833db9cf38158afc96d4b5e6e4822c14b6bb485
Gerrit-Change-Number: 563431
Gerrit-PatchSet: 6
Gerrit-Owner: Dvorapa <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to