Skip to content

Commit 0d61462

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 5.0.2 was chosen due to Python 3.5 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 any module interactions (like running tests). 1. https://pypi.org/project/setuptools-scm/ 2. https://packaging.python.org/en/latest/guides/single-sourcing-package-version/ Part of #238
1 parent 8460273 commit 0d61462

File tree

7 files changed

+32
-22
lines changed

7 files changed

+32
-22
lines changed

.github/workflows/reusable_testing.yml

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

36-
- name: Install connector requirements
37-
run: pip install -r requirements.txt
36+
- name: Install the package
37+
run: make install
3838

3939
- name: Install test requirements
4040
run: pip install -r requirements-test.txt

.github/workflows/testing.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ 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
82+
- name: Install the package
83+
run: make install
8484

8585
- name: Install test requirements
8686
run: pip install -r requirements-test.txt
@@ -135,8 +135,8 @@ jobs:
135135
with:
136136
python-version: ${{ matrix.python }}
137137

138-
- name: Install package requirements
139-
run: pip install -r requirements.txt
138+
- name: Install the package
139+
run: make install
140140

141141
- name: Install test requirements
142142
run: pip install -r requirements-test.txt
@@ -179,8 +179,8 @@ jobs:
179179
with:
180180
python-version: ${{ matrix.python }}
181181

182-
- name: Install connector requirements
183-
run: pip install -r requirements.txt
182+
- name: Install the package
183+
run: make install
184184

185185
- name: Install test requirements
186186
run: pip install -r requirements-test.txt

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).

README.rst

+12-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ On Linux:
9191

9292
.. code-block:: bash
9393
94-
$ make test
94+
$ make install
95+
$ make test
9596
9697
On Windows:
9798

@@ -103,7 +104,8 @@ On Windows:
103104
* Set the following environment variables:
104105
* ``REMOTE_TARANTOOL_HOST=...``,
105106
* ``REMOTE_TARANTOOL_CONSOLE_PORT=3302``.
106-
* Run ``make test``.
107+
* Install the package: ``make install``.
108+
* Run tests: ``make test``.
107109

108110
Build docs
109111
^^^^^^^^^^
@@ -114,7 +116,14 @@ To build documentation, first you must install its build requirements:
114116
115117
$ pip install -r requirements-doc.txt
116118
117-
Then run
119+
To build with valid version, `tarantool` package must be installed before
120+
documentation build.
121+
122+
.. code-block:: bash
123+
124+
$ make install
125+
126+
Build documentation the documentation with
118127

119128
.. code-block:: bash
120129

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
result = f.read().splitlines()
6060
return result
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=["tarantool"],
7465
package_dir={"tarantool": os.path.join("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==5.0.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)