Skip to content

Commit

Permalink
Fixed setuptools_scm issue with legacy python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain MARIE committed Sep 26, 2024
1 parent 7f70bbb commit e61cd0f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@
DOWNLOAD_URL = URL + "/tarball/" + get_version()


# (3) Call setup() with as little args as possible
setup(
download_url=DOWNLOAD_URL,
use_scm_version={
"write_to": "src/makefun/_version.py",
# Custom template to avoid type hints and annotations (python <3.8)
"version_file_template": """# file generated by setuptools_scm
# Setuptools_scm target version file to generate
args = {
"write_to": "src/makefun/_version.py",
}
# Use the 'version_file_template' directive if possible to avoid type hints and annotations (python <3.8)
from packaging.version import Version
setuptools_scm_version = pkg_resources.get_distribution("setuptools_scm").version
if Version(setuptools_scm_version) >= Version('8.1.0'):
# Note that it was named 'write_to_template' earlier. But at that time it was not generating annotations so no need.
args["version_file_template"] = """# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '{version}'
__version_tuple__ = version_tuple = {version_tuple}
"""
}, # we can't put `use_scm_version` in setup.cfg yet unfortunately
# (3) Call setup() with as little args as possible
setup(
download_url=DOWNLOAD_URL,
use_scm_version=args
)

0 comments on commit e61cd0f

Please sign in to comment.