chore: prevent normalization of semver versioning (#1292)
When there is a patch version added to semver versioning, setuptools.setup(version) will normalize the versioning from `-patch` to `.patch` which is not correct SEMVER versioning. The added feature with setuptools.sic(version) will prevent this from happening.
diff --git a/setup.py b/setup.py
index 0d51ab3..9bbd5a8 100644
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,22 @@
import io
import os
-from setuptools import setup
+import setuptools
+
+# Disable version normalization performed by setuptools.setup()
+try:
+ # Try the approach of using sic(), added in setuptools 46.1.0
+ from setuptools import sic
+except ImportError:
+ # Try the approach of replacing packaging.version.Version
+ sic = lambda v: v
+ try:
+ # setuptools >=39.0.0 uses packaging from setuptools.extern
+ from setuptools.extern import packaging
+ except ImportError:
+ # setuptools <39.0.0 uses packaging from pkg_resources.extern
+ from pkg_resources.extern import packaging
+ packaging.version.Version = packaging.version.LegacyVersion
packages = ["apiclient", "googleapiclient", "googleapiclient/discovery_cache"]
@@ -48,9 +63,9 @@
version = "2.2.0"
-setup(
+setuptools.setup(
name="google-api-python-client",
- version=version,
+ version=sic(version),
description="Google API Client Library for Python",
long_description=readme,
long_description_content_type='text/markdown',