From 9a021b68f09006cd2076b535fa5c721e1c8acc83 Mon Sep 17 00:00:00 2001 From: Sourabh Bajaj Date: Wed, 15 Mar 2017 16:14:44 -0700 Subject: [PATCH] [BEAM-547] [BEAM-1730] Cleanup versions.py --- sdks/python/MANIFEST.in | 3 --- sdks/python/apache_beam/__init__.py | 3 +++ sdks/python/apache_beam/version.py | 36 ----------------------------- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/sdks/python/MANIFEST.in b/sdks/python/MANIFEST.in index 57f684e97f1a..ff572bac8f27 100644 --- a/sdks/python/MANIFEST.in +++ b/sdks/python/MANIFEST.in @@ -15,7 +15,4 @@ # limitations under the License. # -# This file is used from Python to sync versions -include pom.xml - include README.md diff --git a/sdks/python/apache_beam/__init__.py b/sdks/python/apache_beam/__init__.py index 77c89adc2f2f..5a63fff1f702 100644 --- a/sdks/python/apache_beam/__init__.py +++ b/sdks/python/apache_beam/__init__.py @@ -77,6 +77,9 @@ from apache_beam import coders from apache_beam import io from apache_beam import typehints +from apache_beam import version from apache_beam.pipeline import Pipeline from apache_beam.transforms import * # pylint: enable=wrong-import-position + +__version__ = version.__version__ diff --git a/sdks/python/apache_beam/version.py b/sdks/python/apache_beam/version.py index e5d61a132aa6..22d16839e567 100644 --- a/sdks/python/apache_beam/version.py +++ b/sdks/python/apache_beam/version.py @@ -18,40 +18,4 @@ """Apache Beam SDK version information and utilities.""" -import re - - __version__ = '0.7.0.dev' - - -# The following utilities are legacy code from the Maven integration; -# see BEAM-378 for further details. - - -# Reads the actual version from pom.xml file, -def get_version_from_pom(): - with open('pom.xml', 'r') as f: - pom = f.read() - regex = (r'.*\s*' - r'[a-z\.]+\s*' - r'[a-z\-]+\s*' - r'([0-9a-zA-Z\.\-]+).*') - pattern = re.compile(str(regex)) - search = pattern.search(pom) - version = search.group(1) - version = version.replace("-SNAPSHOT", ".dev") - return version - - -# Synchronizes apache_beam.__version__ field for later usage -def sync_version(version): - init_path = 'apache_beam/__init__.py' - regex = r'^__version__\s*=\s*".*"' - with open(init_path, "r") as f: - lines = f.readlines() - with open(init_path, "w") as f: - for line in lines: - if re.search(regex, line): - f.write(re.sub(regex, '__version__ = "%s"' % version, line)) - else: - f.write(line)