Skip to content

Commit

Permalink
package version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jue-Xu committed Jul 1, 2024
1 parent ecc9f2e commit 6119368
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
12 changes: 12 additions & 0 deletions quantum_simulation_recipe/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os


def string():
try:
with open(os.path.dirname(__file__) + "/VERSION", "r", encoding="utf-8") as fh:
version = fh.read().strip()
if version:
return version
except:
pass
return "unknown (git checkout)"
44 changes: 22 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
import subprocess
import os

# cf_remote_version = (
# subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE)
# .stdout.decode("utf-8")
# .strip()
# )
package_version = (
subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE)
.stdout.decode("utf-8")
.strip()
)

# if "-" in cf_remote_version:
# # when not on tag, git describe outputs: "1.3.3-22-gdf81228"
# # pip has gotten strict with version numbers
# # so change it to: "1.3.3+22.git.gdf81228"
# # See: https://peps.python.org/pep-0440/#local-version-segments
# v,i,s = cf_remote_version.split("-")
# cf_remote_version = v + "+" + i + ".git." + s
if "-" in package_version:
# when not on tag, git describe outputs: "1.3.3-22-gdf81228"
# pip has gotten strict with version numbers
# so change it to: "1.3.3+22.git.gdf81228"
# See: https://peps.python.org/pep-0440/#local-version-segments
v,i,s = package_version.split("-")
package_version = v + "+" + i + ".git." + s

# assert "-" not in cf_remote_version
# assert "." in cf_remote_version
assert "-" not in package_version
assert "." in package_version

# assert os.path.isfile("cf_remote/version.py")
# with open("cf_remote/VERSION", "w", encoding="utf-8") as fh:
# fh.write("%s\n" % cf_remote_version)
assert os.path.isfile("quantum_simulation_recipe/version.py")
with open("quantum_simulation_recipe/VERSION", "w", encoding="utf-8") as fh:
fh.write("%s\n" % package_version)

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

setuptools.setup(
name="quantum-simulation-recipe",
version='0.0.3',
# version=cf_remote_version,
author="Jue XU",
# version='0.0.3',
version=package_version,
# author="Jue XU",
author_email="[email protected]",
description="Recipe for quantum simulation",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Jue-Xu/quantum-simulation-recipe",
packages=setuptools.find_packages(include=["quantum_simulation_recipe"]),
# package_data={"cf_remote": ["VERSION"]},
# include_package_data=True,
package_data={"quantum_simulation_recipe": ["VERSION"]},
include_package_data=True,
license="Apache-2.0",
classifiers=[
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit 6119368

Please sign in to comment.