Skip to content

Commit 7cb3c12

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. 1. https://pypi.org/project/setuptools-scm/ 2. https://packaging.python.org/en/latest/guides/single-sourcing-package-version/ Part of #238
1 parent 63ef2ed commit 7cb3c12

File tree

7 files changed

+31
-21
lines changed

7 files changed

+31
-21
lines changed

Diff for: .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

Diff for: .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

Diff for: Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.PHONY: test docs
2+
install:
3+
python setup.py install
24
test:
35
python setup.py test
46
testdata:

Diff for: README.rst

+10-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can also download zip archive, unpack it and run:
3333

3434
.. code-block:: bash
3535
36-
$ python setup.py install
36+
$ make install
3737
3838
Development version
3939
^^^^^^^^^^^^^^^^^^^
@@ -103,6 +103,7 @@ On Windows:
103103
* Set the following environment variables:
104104
* ``REMOTE_TARANTOOL_HOST=...``,
105105
* ``REMOTE_TARANTOOL_CONSOLE_PORT=3302``.
106+
* Install the package.
106107
* Run ``python setup.py test``.
107108

108109
Build docs
@@ -114,7 +115,14 @@ To build documentation, first you must install its build requirements:
114115
115116
$ pip install -r docs/requirements.txt
116117
117-
Then run
118+
To build with valid version, `tarantool` package must be installed before
119+
documentation build.
120+
121+
.. code-block:: bash
122+
123+
$ make install
124+
125+
Build documentation the documentation with
118126

119127
.. code-block:: bash
120128

Diff for: 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'

Diff for: setup.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,11 @@ def get_dependencies():
4646
result = f.read().splitlines()
4747
return result
4848

49-
def find_version(*file_paths):
50-
version_file = read(*file_paths)
51-
version_match = re.search(r"""^__version__\s*=\s*(['"])(.+)\1""",
52-
version_file, re.M)
53-
if version_match:
54-
return version_match.group(2)
55-
raise RuntimeError("Unable to find version string.")
56-
57-
5849
setup(
5950
name="tarantool",
6051
packages=["tarantool"],
6152
package_dir={"tarantool": os.path.join("tarantool")},
62-
version=find_version('tarantool', '__init__.py'),
53+
use_scm_version=True,
6354
platforms=["all"],
6455
author="tarantool-python AUTHORS",
6556
author_email="[email protected]",
@@ -78,5 +69,8 @@ def find_version(*file_paths):
7869
cmdclass=cmdclass,
7970
command_options=command_options,
8071
install_requires=get_dependencies(),
72+
setup_requires=[
73+
'setuptools_scm==5.0.2',
74+
],
8175
python_requires='>=3',
8276
)

Diff for: 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)