|
1 | 1 | #!/usr/bin/env python3
|
2 |
| -import semver as package |
| 2 | +# import semver as package |
3 | 3 | from os.path import dirname, join
|
4 | 4 | from setuptools import setup
|
| 5 | +import re |
| 6 | + |
| 7 | + |
| 8 | +VERSION_MATCH = re.compile(r"__version__ = ['\"]([^'\"]*)['\"]", re.M) |
5 | 9 |
|
6 | 10 |
|
7 | 11 | def read_file(filename):
|
8 | 12 | with open(join(dirname(__file__), filename)) as f:
|
9 | 13 | return f.read()
|
10 | 14 |
|
11 | 15 |
|
| 16 | +def find_meta(meta): |
| 17 | + """ |
| 18 | + Extract __*meta*__ from META_FILE. |
| 19 | + """ |
| 20 | + meta_match = re.search( |
| 21 | + r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), META_FILE, re.M |
| 22 | + ) |
| 23 | + if meta_match: |
| 24 | + return meta_match.group(1) |
| 25 | + raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta)) |
| 26 | + |
| 27 | + |
| 28 | +NAME = "semver" |
| 29 | +META_FILE = read_file("semver.py") |
| 30 | + |
| 31 | + |
| 32 | +# ----------------------------------------------------------------------------- |
12 | 33 | setup(
|
13 |
| - name=package.__name__, |
14 |
| - version=package.__version__, |
15 |
| - description=package.__doc__.strip(), |
| 34 | + name=NAME, |
| 35 | + version=find_meta("version"), |
| 36 | + description=find_meta("description").strip(), |
16 | 37 | long_description=read_file("README.rst"),
|
17 | 38 | long_description_content_type="text/x-rst",
|
18 |
| - author=package.__author__, |
19 |
| - author_email=package.__author_email__, |
| 39 | + author=find_meta("author"), |
| 40 | + author_email=find_meta("author_email"), |
20 | 41 | url="https://github.com/python-semver/python-semver",
|
21 | 42 | download_url="https://github.com/python-semver/python-semver/downloads",
|
22 | 43 | project_urls={
|
23 | 44 | "Documentation": "https://python-semver.rtfd.io",
|
24 | 45 | "Releases": "https://github.com/python-semver/python-semver/releases",
|
25 | 46 | "Bug Tracker": "https://github.com/python-semver/python-semver/issues",
|
26 | 47 | },
|
27 |
| - py_modules=[package.__name__], |
| 48 | + py_modules=[NAME], |
28 | 49 | include_package_data=True,
|
29 | 50 | license="BSD",
|
30 | 51 | classifiers=[
|
|
0 commit comments