Skip to content

Commit 879a5a4

Browse files
setup: use git version instead of hardcoded one
setuptool_scm [1] package is a recommended way to set package version with git [2]. Version 6.4.2 was chosen due to Python 3.6 support, latest version 7.0.5 supports only Python 3.7+. Package version is displayed in documentation, so after this patch documentation for master branch won't be confused with the last tagged one. The drawback is that after this patch, any developer should run `make install` before module interactions. 1. https://pypi.org/project/setuptools-scm/ 2. https://packaging.python.org/en/latest/guides/single-sourcing-package-version/ Part of #238
1 parent a94f97c commit 879a5a4

File tree

8 files changed

+29
-30
lines changed

8 files changed

+29
-30
lines changed

.github/workflows/reusable_testing.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ jobs:
3333
with:
3434
python-version: 3.7
3535

36-
- name: Install connector requirements
37-
run: pip install -r requirements.txt
38-
3936
- name: Install test requirements
4037
run: pip install -r requirements-test.txt
4138

42-
- run: make test
39+
- name: Install the package and run tests
40+
run: make test

.github/workflows/testing.yml

+3-12
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,10 @@ jobs:
7979
pip install ${{ matrix.msgpack-deps }}
8080
sed -i -e "s/^msgpack.*$/${{ matrix.msgpack-deps }}/" requirements.txt
8181
82-
- name: Install package requirements
83-
run: pip install -r requirements.txt
84-
8582
- name: Install test requirements
8683
run: pip install -r requirements-test.txt
8784

88-
- name: Run tests
85+
- name: Install the package and run tests
8986
run: make test
9087

9188
run_tests_ee_linux:
@@ -135,13 +132,10 @@ jobs:
135132
with:
136133
python-version: ${{ matrix.python }}
137134

138-
- name: Install package requirements
139-
run: pip install -r requirements.txt
140-
141135
- name: Install test requirements
142136
run: pip install -r requirements-test.txt
143137

144-
- name: Run tests
138+
- name: Install the package and run tests
145139
run: |
146140
source tarantool-enterprise/env.sh
147141
make test
@@ -232,9 +226,6 @@ jobs:
232226
with:
233227
python-version: ${{ matrix.python }}
234228

235-
- name: Install connector requirements
236-
run: pip install -r requirements.txt
237-
238229
- name: Install test requirements
239230
run: pip install -r requirements-test.txt
240231

@@ -265,7 +256,7 @@ jobs:
265256
touch tarantool.pid
266257
echo $TNT_PID > ./tarantool.pid
267258
268-
- name: Run tests
259+
- name: Install the package and run tests
269260
env:
270261
REMOTE_TARANTOOL_HOST: localhost
271262
REMOTE_TARANTOOL_CONSOLE_PORT: 3302

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
141141
- Change documentation HTML theme (#67).
142142
- Update API documentation strings (#67).
143143
- Update documentation index, quick start and guide pages (#67).
144+
- Use git version to set package version (#238).
144145

145146
### Fixed
146147
- Package build (#238).

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.PHONY: install test
22
install:
33
python setup.py install
4-
test:
4+
test: install
55
python setup.py test
66
testdata:
77
cd ./test/data/; ./generate.sh
8-
coverage:
8+
coverage: install
99
python -m coverage run -p --source=. setup.py test
1010
cov-html:
1111
python -m coverage html -i
@@ -17,7 +17,7 @@ dist-upload:
1717
python setup.py sdist --format=gztar,bztar,zip upload
1818
dist-upload-2:
1919
python setup.py sdist --format=ztar upload
20-
docs:
20+
docs: install
2121
python setup.py build_sphinx
2222
docs-upload: docs
2323
python setup.py upload_sphinx

README.rst

+9
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ This driver is synchronous, so connection mustn't be shared between threads/proc
8484
If you're looking for an asynchronous Python driver based on ``asyncio``,
8585
consider using `asynctnt`_ . See also the `feature comparison table`_.
8686

87+
Local development
88+
^^^^^^^^^^^^^^^^^
89+
90+
If you want to work with cloned repo, first you must run
91+
92+
.. code-block:: bash
93+
94+
$ make install
95+
8796
Run tests
8897
^^^^^^^^^
8998

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
msgpack>=1.0.4
22
pandas
33
pytz
4+
importlib-metadata >= 1.0 ; python_version < '3.8'

setup.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,12 @@ def get_dependencies(file):
5959
return f.read().splitlines()
6060
raise RuntimeError("Unable to get dependencies from file " + file)
6161

62-
def find_version(*file_paths):
63-
version_file = read(*file_paths)
64-
version_match = re.search(r"""^__version__\s*=\s*(['"])(.+)\1""",
65-
version_file, re.M)
66-
if version_match:
67-
return version_match.group(2)
68-
raise RuntimeError("Unable to find version string.")
69-
70-
7162
setup(
7263
name="tarantool",
7364
packages=find_packages("."),
7465
package_dir={"tarantool": "tarantool"},
7566
include_package_data=True,
76-
version=find_version('tarantool', '__init__.py'),
67+
use_scm_version=True,
7768
platforms=["all"],
7869
author="tarantool-python AUTHORS",
7970
author_email="[email protected]",
@@ -92,5 +83,8 @@ def find_version(*file_paths):
9283
cmdclass=cmdclass,
9384
command_options=command_options,
9485
install_requires=get_dependencies('requirements.txt'),
86+
setup_requires=[
87+
'setuptools_scm==6.4.2',
88+
],
9589
python_requires='>=3',
9690
)

tarantool/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@
4040
Interval,
4141
)
4242

43-
__version__ = "0.9.0"
43+
if sys.version_info >= (3, 8):
44+
from importlib import metadata
45+
else:
46+
import importlib_metadata as metadata
47+
48+
__version__ = metadata.version('tarantool')
4449

4550

4651
def connect(host="localhost", port=33013, user=None, password=None,

0 commit comments

Comments
 (0)