|
1 | 1 | import setuptools |
| 2 | +import re |
| 3 | +from subprocess import Popen, PIPE |
| 4 | + |
| 5 | + |
| 6 | +def get_current_version_tag(): |
| 7 | + process = Popen(["git", "describe", "--tags", "--match", "v[0-9]*"], stdout=PIPE) |
| 8 | + (output, err) = process.communicate() |
| 9 | + process.wait() |
| 10 | + |
| 11 | + tags = str(output, "utf-8").strip().split("\n") |
| 12 | + |
| 13 | + version_tags = [tag for tag in tags if re.match(r"^v?(\d*\.){2}\d$", tag)] |
| 14 | + dev_tags = [tag for tag in tags if re.match(r"^v?(\d*\.){2}\d-\d*-[a-z\d]{8}$", tag)] |
| 15 | + |
| 16 | + if len(version_tags) == 1: |
| 17 | + return version_tags.pop()[1:] |
| 18 | + elif len(dev_tags) == 1: |
| 19 | + base_tag, num_commits = dev_tags.pop().split("-")[:2] |
| 20 | + return "{}.dev{}".format(base_tag, num_commits)[1:] |
| 21 | + else: |
| 22 | + return "0.0.0.dev0" |
| 23 | + |
2 | 24 |
|
3 | 25 | with open("README.md", "r") as readme_file: |
4 | 26 | long_description = readme_file.read() |
5 | 27 |
|
6 | 28 | setuptools.setup( |
7 | 29 | name="nitric", |
8 | | - version="0.1.0", |
| 30 | + version=get_current_version_tag(), |
9 | 31 | author="Nitric", |
10 | 32 | author_email="team@nitric.io", |
11 | 33 | description="The Nitric SDK for Python 3", |
12 | 34 | long_description=long_description, |
13 | 35 | long_description_content_type="text/markdown", |
14 | 36 | url="https://github.com/nitrictech/python-sdk", |
15 | | - packages=setuptools.find_packages(), |
| 37 | + packages=setuptools.find_packages(exclude=["tests", "tests.*"]), |
16 | 38 | license_files=("LICENSE.txt",), |
17 | 39 | classifiers=[ |
18 | 40 | "Programming Language :: Python :: 3", |
|
0 commit comments