Skip to content

Commit aea15fc

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+. Extract package version in documentation (see "Usage from Sphinx" in [1]). 1. https://pypi.org/project/setuptools-scm/ 2. https://packaging.python.org/en/latest/guides/single-sourcing-package-version/ Part of #238
1 parent 965d43a commit aea15fc

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ To build documentation, first you must install its build requirements:
114114
115115
$ pip install -r docs/requirements.txt
116116
117-
Then run
117+
To build with valid version, `tarantool` package must be installed before
118+
documentation build.
119+
120+
.. code-block:: bash
121+
122+
$ make install
123+
124+
Build documentation the documentation with
118125

119126
.. code-block:: bash
120127

Diff for: docs/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
sphinx==5.2.1
22
sphinx-paramlinks==0.5.4
33
sphinx-favicon==0.2
4+
importlib-metadata >= 1.0 ; python_version < '3.8'

Diff for: docs/source/conf.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@
5757
# The version info for the project you're documenting, acts as replacement for
5858
# |version| and |release|, also used in various other places throughout the
5959
# built documents.
60-
#
60+
61+
if sys.version_info >= (3, 8):
62+
from importlib import metadata
63+
else:
64+
import importlib_metadata as metadata
65+
66+
__version__ = metadata.version('tarantool')
67+
6168
# The short X.Y version.
6269
version = __version__
6370
# The full version, including alpha/beta/rc tags.

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

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
Interval,
4141
)
4242

43-
__version__ = "0.9.0"
44-
4543

4644
def connect(host="localhost", port=33013, user=None, password=None,
4745
encoding=ENCODING_DEFAULT, transport=DEFAULT_TRANSPORT,

0 commit comments

Comments
 (0)