Skip to content

Commit

Permalink
Allow __version__ to be overridden for release
Browse files Browse the repository at this point in the history
setuptools_scm always generates dev __version__; during release
we might need to use the exact pinned version.
  • Loading branch information
wookayin committed Apr 5, 2023
1 parent 649fe45 commit 17dffb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@

[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]

[tool.setuptools_scm]
write_to = "gpustat/_version.py"
17 changes: 14 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ def read_version():
"setuptools_scm needs to be installed manually. "
"Or consider running `pip install -e .` instead."
)
return setuptools_scm.get_version()
version = setuptools_scm.get_version()
setuptools_scm.dump_version(root=__PATH__, version=version,
write_to='gpustat/_version.py')
return version


__version__ = read_version()
if os.getenv("GPUSTAT_VERSION"):
# release process, e.g. GPUSTAT_VERSION="1.1" python setup.py sdist
__version__ = os.environ["GPUSTAT_VERSION"]
else:
# Let dev version auto-generated from git tags, or
# grab the version information from PKG-INFO for source distribution
__version__ = read_version()



# brought from https://github.com/kennethreitz/setup.py
Expand Down Expand Up @@ -62,7 +72,8 @@ def run(self):
pass

self.status('Building Source and Wheel (universal) distribution ...')
os.system('{0} setup.py sdist'.format(sys.executable))
os.system("GPUSTAT_VERSION='{}' sh -c '{} setup.py sdist'".format(
__version__, sys.executable))

self.status('Uploading the package to PyPI via Twine ...')
ret = os.system('twine upload dist/*')
Expand Down

0 comments on commit 17dffb5

Please sign in to comment.