py3: return unicode from setup.py's get_version stable
authorIan Moody <moz-ian@perix.co.uk>
Thu, 03 Oct 2019 23:48:50 +0100
branchstable
changeset 4878 095bab0d0cd7
parent 4877 77e5c733200a
child 4879 77e8ca85d740
child 4880 a8525a2e0748
py3: return unicode from setup.py's get_version py3 expects the version number for eggs to be unicode, so despite 9.2.0 being the first evolve release with beta py3 support it isn't currently pip installable since it dies with: File "*/setuptools/command/egg_info.py", line *, in tagged_version return safe_version(version + self.vtags) TypeError: can't concat str to bytes The `setup.py install` test added in a previous commit should cover this since it died in a different but similar way before.
setup.py
tests/test-version-install.t
--- a/setup.py	Thu Oct 03 23:39:37 2019 +0100
+++ b/setup.py	Thu Oct 03 23:48:50 2019 +0100
@@ -13,7 +13,7 @@
 
 def get_version():
     '''Read version info from a file without importing it'''
-    return get_metadata()['__version__']
+    return u'%s' % get_metadata()['__version__']
 
 def min_hg_version():
     '''Read version info from a file without importing it'''
--- a/tests/test-version-install.t	Thu Oct 03 23:39:37 2019 +0100
+++ b/tests/test-version-install.t	Thu Oct 03 23:48:50 2019 +0100
@@ -19,36 +19,6 @@
 
 Test install
 TODO: fix warning
-#if py3
-BROKEN: unicode errors on version number on install
   $ "$PYTHON" "$TESTDIR/../setup.py" install --root "$TESTTMP/installtest" > /dev/null
   */distutils/dist.py:*: UserWarning: Unknown distribution option: 'python_requires' (glob)
     warnings.warn(msg)
-  Traceback (most recent call last):
-    File "*/../setup.py", line *, in <module> (glob)
-      python_requires=py_versions
-    File "*/distutils/core.py", line *, in setup (glob)
-      dist.run_commands()
-    File "*/distutils/dist.py", line *, in run_commands (glob)
-      self.run_command(cmd)
-    File "*/distutils/dist.py", line *, in run_command (glob)
-      cmd_obj.run()
-    File "*/distutils/command/install.py", line *, in run (glob)
-      self.run_command(cmd_name)
-    File "*/distutils/cmd.py", line *, in run_command (glob)
-      self.distribution.run_command(command)
-    File "*/distutils/dist.py", line *, in run_command (glob)
-      cmd_obj.ensure_finalized()
-    File "*/distutils/cmd.py", line *, in ensure_finalized (glob)
-      self.finalize_options()
-    File "*/distutils/command/install_egg_info.py", line *, in finalize_options (glob)
-      to_filename(safe_version(self.distribution.get_version()))
-    File "*/distutils/command/install_egg_info.py", line *, in safe_version (glob)
-      version = version.replace(' ','.')
-  TypeError: a bytes-like object is required, not 'str'
-  [1]
-#else
-  $ "$PYTHON" "$TESTDIR/../setup.py" install --root "$TESTTMP/installtest" > /dev/null
-  */distutils/dist.py:*: UserWarning: Unknown distribution option: 'python_requires' (glob)
-    warnings.warn(msg)
-#endif