Skip to content

Commit

Permalink
Move version source of truth to esrally/_version.py (elastic#1351)
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin authored Oct 6, 2021
1 parent 3cb3133 commit cd0b6a0
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 29 deletions.
10 changes: 10 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2

python:
version: "3.8"
install:
- method: pip
path: .

sphinx:
fail_on_warning: true
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include LICENSE
include MANIFEST.in
include README.rst
include setup.py
include version.txt
include esrally/min-es-version.txt
recursive-include docs *
recursive-include esrally/resources *
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfiles/Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ RUN apt-get -y update && \
RUN mkdir -p /rally/esrally
COPY setup.py /rally/
COPY setup.cfg /rally/
COPY version.txt /rally/
COPY README.rst /rally/
COPY MANIFEST.in /rally/
COPY esrally/ /rally/esrally/
Expand Down
21 changes: 9 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,34 @@ def setup(app):
app.connect("source-read", replace_globals)


def read_version(version_file="version.txt", full_version=True):
with open(join(dirname(__file__), os.pardir, version_file)) as f:
raw_version = f.read().strip()
return raw_version if full_version else raw_version.replace(".dev0", "")
def read_min_es_version():
with open(join(dirname(__file__), os.pardir, "esrally/min-es-version.txt")) as f:
return f.read().strip()


year = date.today().year

rst_prolog = f"""
.. |year| replace:: {year}
.. |MIN_PY_VER| replace:: {read_min_python_version()}
.. |min_es_version| replace:: {read_version(version_file="esrally/min-es-version.txt")}
.. |min_es_version| replace:: {read_min_es_version()}
"""

# General information about the project.
project = "Rally"
copyright = "%i, Elasticsearch B.V." % year
author = "Daniel Mitterdorfer"

import esrally

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.

# development versions always have the suffix '.dev0'


version = read_version(full_version=False)
# Technically the short X.Y version, but let's use the full version, including .dev0
version = esrally.__version__
# The full version, including alpha/beta/rc tags.
release = read_version()
release = version

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
4 changes: 1 addition & 3 deletions esrally/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import sys
import urllib

import pkg_resources

__version__ = pkg_resources.require("esrally")[0].version
from ._version import __version__

# Allow an alternative program name be set in case Rally is invoked a wrapper script
PROGRAM_NAME = os.getenv("RALLY_ALTERNATIVE_BINARY_NAME", os.path.basename(sys.argv[0]))
Expand Down
1 change: 1 addition & 0 deletions esrally/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "2.3.1.dev0"
5 changes: 1 addition & 4 deletions esrally/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
import re
from importlib import resources

import pkg_resources

from esrally import paths
from esrally._version import __version__
from esrally.utils import git, io

__version__ = pkg_resources.require("esrally")[0].version

__RALLY_VERSION_PATTERN = re.compile(r"^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:.(.+))?$")


Expand Down
4 changes: 2 additions & 2 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ git commit -a -m "Update changelog for Rally release $RELEASE_VERSION"

# * Update version in `setup.py` and `docs/conf.py`
echo "Updating release version number"
echo "$RELEASE_VERSION" > version.txt
printf '__version__ = "%s"\n' $RELEASE_VERSION > esrally/_version.py
git commit -a -m "Bump version to $RELEASE_VERSION"

# --upgrade is required for virtualenv
Expand All @@ -83,7 +83,7 @@ git tag -s "${RELEASE_VERSION}" -m "Rally release $RELEASE_VERSION"
git push --tags

# Update version to next dev version
echo "$NEXT_RELEASE" > version.txt
printf '__version__ = "%s"\n' $NEXT_RELEASE > esrally/_version.py

# Install locally for development
python3 setup.py develop --upgrade
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

from os.path import join, dirname
import re

try:
from setuptools import setup, find_packages
Expand All @@ -29,10 +30,8 @@ def str_from_file(name):
return f.read().strip()


raw_version = str_from_file("version.txt")
VERSION = raw_version.split(".")
__version__ = VERSION
__versionstr__ = raw_version
raw_version = str_from_file("esrally/_version.py")
version = re.match(r'__version__ = "(.+)"', raw_version).group(1)

long_description = str_from_file("README.rst")

Expand Down Expand Up @@ -122,7 +121,7 @@ def str_from_file(name):
setup(name="esrally",
maintainer="Daniel Mitterdorfer",
maintainer_email="[email protected]",
version=__versionstr__,
version=version,
description="Macrobenchmarking framework for Elasticsearch",
long_description=long_description,
url="https://github.com/elastic/rally",
Expand Down
1 change: 0 additions & 1 deletion version.txt

This file was deleted.

0 comments on commit cd0b6a0

Please sign in to comment.