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