Skip to content

Commit 10287fe

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 08fdcbb commit 10287fe

File tree

9 files changed

+37
-26
lines changed

9 files changed

+37
-26
lines changed

.github/workflows/reusable_testing.yml

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 6 deletions
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

INSTALL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Using `easy_install`::
1414

1515
You can also download the source tarball and install the package using distutils script::
1616

17-
# python setup.py install
17+
# make install

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
include README.rst
22
include README.txt
33
include setup.py
4-
recursive-include tarantool/ *.py
4+
recursive-include tarantool *.py

Makefile

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

README.rst

Lines changed: 13 additions & 4 deletions
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
^^^^^^^^^^^^^^^^^^^
@@ -91,7 +91,8 @@ On Linux:
9191

9292
.. code-block:: bash
9393
94-
$ python setup.py 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 ``python setup.py 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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 10 deletions
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="admin@tarantool.org",
@@ -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

Lines changed: 6 additions & 1 deletion
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)