Polish version retrieval and long description loading
This commit is contained in:
35
setup.py
35
setup.py
@@ -1,33 +1,30 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
HERE = pathlib.Path(__file__).parent.absolute()
|
||||||
PACKAGE = "qibotn"
|
PACKAGE = "qibotn"
|
||||||
|
|
||||||
|
|
||||||
# Returns the qibotn version
|
# Returns the qibotn version
|
||||||
def get_version():
|
def version():
|
||||||
""" Gets the version from the package's __init__ file
|
"""Gets the version from the package's __init__ file
|
||||||
if there is some problem, let it happily fail """
|
if there is some problem, let it happily fail"""
|
||||||
VERSIONFILE = os.path.join("src", PACKAGE, "__init__.py")
|
version_file = HERE / "src" / PACKAGE / "__init__.py"
|
||||||
initfile_lines = open(VERSIONFILE, "rt").readlines()
|
version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]"
|
||||||
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
|
|
||||||
for line in initfile_lines:
|
initfile = version_file.read_text(encoding="utf-8")
|
||||||
mo = re.search(VSRE, line, re.M)
|
matched = re.search(version_regex, initfile, re.M)
|
||||||
if mo:
|
|
||||||
return mo.group(1)
|
if matched is not None:
|
||||||
|
return matched.group(1)
|
||||||
|
return "0.0.0"
|
||||||
|
|
||||||
|
|
||||||
# load long description from README
|
# load long description from README
|
||||||
this_directory = os.path.abspath(os.path.dirname(__file__))
|
|
||||||
with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
|
|
||||||
long_description = f.read()
|
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="qibotn",
|
name="qibotn",
|
||||||
version=get_version(),
|
version=version(),
|
||||||
description="A tensor-network translation module for quantum computing",
|
description="A tensor-network translation module for quantum computing",
|
||||||
author="The Qibo team",
|
author="The Qibo team",
|
||||||
author_email="",
|
author_email="",
|
||||||
@@ -58,6 +55,6 @@ setup(
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
python_requires=">=3.7.0",
|
python_requires=">=3.7.0",
|
||||||
long_description=long_description,
|
long_description=(HERE / "README.md").read_text(encoding="utf-8"),
|
||||||
long_description_content_type='text/markdown',
|
long_description_content_type="text/markdown",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user