Skip to content

Commit

Permalink
[build] Centralize project version to version.txt
Browse files Browse the repository at this point in the history
This patch changes the Java and Python builds
to use the version.txt as their source of the project
version. This simplifies branching and ensures
our versions always match.

I use symbolic links in the python project to ensure
that the version and licence file are copied from the
parent directory when generating a source
distribution.

This patch also corrects the versioning of snapshot
builds to ensure they include .dev0. This was being
done in the kudu/version.py file, but not in the
distribution version set in setup(…).

Change-Id: Ib654be8657ae3dc2f193056484b5d0743aa1ce95
Reviewed-on: http://gerrit.cloudera.org:8080/11735
Tested-by: Kudu Jenkins
Reviewed-by: <[email protected]>
Reviewed-by: Adar Dembo <[email protected]>
  • Loading branch information
granthenke committed Oct 31, 2018
1 parent 0b2fef4 commit dc71ab7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 24 deletions.
7 changes: 1 addition & 6 deletions RELEASING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,7 @@ branch with the same name and the previously-noted SHA1.

. Check out the `master` branch and bump the version in `version.txt`.

. Update the version in `java/gradle.properties`.

. If the python API has changed since the previous release, bump the Python version
in `python/setup.py` in master. (the Python API uses separate versioning).

. After all the versions are updated, commit and push that change to Gerrit.
. Commit and push that change to Gerrit.

. Notify [email protected] that the new branch is available.

Expand Down
3 changes: 3 additions & 0 deletions java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ allprojects {
mavenLocal()
}

// Read the version.txt file to set the project version
project.version = file("$rootDir/../version.txt").text.trim()

apply from: "$rootDir/gradle/docs.gradle"
}

Expand Down
1 change: 0 additions & 1 deletion java/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

group = org.apache.kudu
version = 1.9.0-SNAPSHOT
url = https://kudu.apache.org/

# The Maven respository used when uploading artifacts.
Expand Down
1 change: 1 addition & 0 deletions python/LICENSE.txt
3 changes: 2 additions & 1 deletion python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include LICENSE.txt
include MANIFEST.in
include ../LICENSE.txt
include README.md
include setup.py
include version.txt

graft kudu

Expand Down
39 changes: 23 additions & 16 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from distutils.command.clean import clean as _clean
from distutils.extension import Extension
import os
import re
import subprocess

# Workaround a Python bug in which multiprocessing's atexit handler doesn't
Expand All @@ -37,31 +38,35 @@
if Cython.__version__ < '0.21.0':
raise Exception('Please upgrade to Cython 0.21.0 or newer')

MAJOR = 1
MINOR = 9
MICRO = 0
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
ISRELEASED = True

setup_dir = os.path.abspath(os.path.dirname(__file__))


def write_version_py(filename=os.path.join(setup_dir, 'kudu/version.py')):
version = VERSION
if not ISRELEASED:
version += '.dev'

def find_version():
version_file = open(os.path.join(setup_dir, "version.txt")).read()
version_match = re.search(
# Matches versions in the format of major.minor.patch-optional-label.
# For example: 1.2.3 or 1.2.3-SNAPSHOT or 1.2.3-beta-SNAPSHOT
r"^(?P<version>\d+\.\d+\.\d+)(?:-(?P<label>.+))?",
version_file
)
if not version_match:
raise RuntimeError("Unable to parse version string " + version_file)
version = version_match.group("version")
if "SNAPSHOT" in version_match.group("label"):
version += '.dev0'
return version

def write_version_py(version, filename=os.path.join(setup_dir, 'kudu/version.py')):
is_release = "dev" not in version
a = open(filename, 'w')
file_content = "\n".join(["",
"# THIS FILE IS GENERATED FROM SETUP.PY",
"version = '%(version)s'",
"isrelease = '%(isrelease)s'"])

a.write(file_content % {'version': VERSION,
'isrelease': str(ISRELEASED)})
a.write(file_content % {'version': version,
'isrelease': str(is_release)})
a.close()


class clean(_clean):
def run(self):
_clean.run(self)
Expand Down Expand Up @@ -99,6 +104,8 @@ def generate_config_pxi(include_dirs):
else:
os.rename(dst_tmp, dst)

VERSION = find_version()

# If we're in the context of the Kudu git repository, build against the
# latest in-tree build artifacts
if 'KUDU_HOME' in os.environ:
Expand Down Expand Up @@ -155,7 +162,7 @@ def generate_config_pxi(include_dirs):

extensions = cythonize(extensions)

write_version_py()
write_version_py(VERSION)

LONG_DESCRIPTION = open(os.path.join(setup_dir, "README.md")).read()
DESCRIPTION = "Python interface to the Apache Kudu C++ Client API"
Expand Down
1 change: 1 addition & 0 deletions python/version.txt

0 comments on commit dc71ab7

Please sign in to comment.