diff --git a/autouri/__init__.py b/autouri/__init__.py index bba6d0c..cc19d10 100644 --- a/autouri/__init__.py +++ b/autouri/__init__.py @@ -5,4 +5,4 @@ from .s3uri import S3URI __all__ = ["AbsPath", "AutoURI", "URIBase", "GCSURI", "HTTPURL", "S3URI"] -__version__ = "0.2.4" +__version__ = "0.2.5" diff --git a/setup.py b/setup.py index b82b8f1..289e1f5 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,43 @@ +import os +import re +from pathlib import Path + import setuptools +META_PATH = Path("autouri", "__init__.py") +HERE = os.path.abspath(os.path.dirname(__file__)) + + +def read(*parts): + """ + Build an absolute path from *parts* and and return the contents of the + resulting file. Assume UTF-8 encoding. + """ + with Path(HERE, *parts).open(encoding="utf-8") as f: + return f.read() + + +META_FILE = read(META_PATH) + + +def find_meta(meta): + """ + Extract __*meta*__ from META_FILE. + """ + meta_match = re.search( + r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), META_FILE, re.M + ) + if meta_match: + return meta_match.group(1) + raise + + with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="autouri", - version="0.2.5", + version=find_meta("version"), python_requires=">=3.6", scripts=["bin/autouri"], author="Jin wook Lee",