From c2485bed001c11003fa3d97f952f2b31eecb5346 Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Wed, 15 Jun 2022 20:05:59 +0200 Subject: [PATCH] Use setuptools_scm for versioning --- .gitignore | 1 + bin/swarm | 2 +- setup.py | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 24a1b5c..b879627 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build dist .mypy_cache .tox +_version.py diff --git a/bin/swarm b/bin/swarm index 94d0606..cdad9fe 100755 --- a/bin/swarm +++ b/bin/swarm @@ -115,7 +115,7 @@ parser.add_argument( "--extra-files", nargs="+", default=[], - help="A list of extra files or directories to upload. Space-separated, e.g. --extra-files testdata.csv common.py my-directory/", + help="A list of extra files or directories to upload. Space-separated, e.g. --extra-files testdata.csv *.py my-directory/", ) parser.add_argument( # secret parameter to optimize by not uploading locust-plugins every time "--skip-plugins", diff --git a/setup.py b/setup.py index 154d797..96c49f3 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import ast -import re import os import sys @@ -10,11 +8,6 @@ from setuptools.command.egg_info import egg_info from setuptools.command.develop import develop -_version_re = re.compile(r"__version__\s+=\s+(.*)") -_init_file = "locust_swarm/__init__.py" -with open(_init_file, "rb") as f: - version = str(ast.literal_eval(_version_re.search(f.read().decode("utf-8")).group(1))) - class PostDevelopCommand(develop): def run(self): @@ -39,7 +32,6 @@ def run(self): setup( name="locust-swarm", - version=version, description="Load test + test data distribution & launching tool for Locust", long_description="""https://github.com/SvenskaSpel/locust-swarm""", classifiers=[ @@ -63,7 +55,17 @@ def run(self): packages=find_packages(), include_package_data=True, zip_safe=False, - install_requires=["keyring==21.4.0", "locust-plugins>=2.2.2", "psutil", "ConfigArgParse>=1.0"], + install_requires=[ + "keyring==21.4.0", + "locust-plugins>=2.2.2", + "psutil", + "ConfigArgParse>=1.0", + ], scripts=["bin/swarm"], cmdclass={"egg_info": PostEggInfoCommand, "install": PostInstallCommand, "develop": PostDevelopCommand}, + use_scm_version={ + "write_to": "locust_swarm/_version.py", + "local_scheme": "no-local-version", + }, + setup_requires=["setuptools_scm"], )