Repository: beam Updated Branches: refs/heads/master f8c6836ec -> 88c2fe18d
Revert "[BEAM-547] Version should be accessed from pom file" This reverts commit b43eea47e3b1e842bc28543679500452ceda5a33. Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/76a05acd Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/76a05acd Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/76a05acd Branch: refs/heads/master Commit: 76a05acd08530b9faf3c5cca0adc9f61dcf656d5 Parents: f8c6836 Author: Sourabh Bajaj <[email protected]> Authored: Wed Mar 15 12:51:46 2017 -0700 Committer: Ahmet Altay <[email protected]> Committed: Wed Mar 15 14:42:52 2017 -0700 ---------------------------------------------------------------------- sdks/python/apache_beam/__init__.py | 3 -- .../runners/dataflow/internal/dependency.py | 2 +- sdks/python/apache_beam/version.py | 25 +++++++++------ sdks/python/apache_beam/version_test.py | 32 -------------------- sdks/python/setup.py | 2 +- 5 files changed, 18 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/76a05acd/sdks/python/apache_beam/__init__.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/__init__.py b/sdks/python/apache_beam/__init__.py index 2001c80..77c89ad 100644 --- a/sdks/python/apache_beam/__init__.py +++ b/sdks/python/apache_beam/__init__.py @@ -77,9 +77,6 @@ import apache_beam.internal.pickler 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.get_version() http://git-wip-us.apache.org/repos/asf/beam/blob/76a05acd/sdks/python/apache_beam/runners/dataflow/internal/dependency.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/runners/dataflow/internal/dependency.py b/sdks/python/apache_beam/runners/dataflow/internal/dependency.py index 4e49a4f..902d738 100644 --- a/sdks/python/apache_beam/runners/dataflow/internal/dependency.py +++ b/sdks/python/apache_beam/runners/dataflow/internal/dependency.py @@ -476,7 +476,7 @@ def get_sdk_name_and_version(): # TODO(ccy): Make this check cleaner. container_version = get_required_container_version() if container_version == BEAM_CONTAINER_VERSION: - return ('Apache Beam SDK for Python', beam_version.get_version()) + return ('Apache Beam SDK for Python', beam_version.__version__) else: return ('Google Cloud Dataflow SDK for Python', container_version) http://git-wip-us.apache.org/repos/asf/beam/blob/76a05acd/sdks/python/apache_beam/version.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/version.py b/sdks/python/apache_beam/version.py index ef07dbf..e5d61a1 100644 --- a/sdks/python/apache_beam/version.py +++ b/sdks/python/apache_beam/version.py @@ -21,17 +21,14 @@ import re -__version__ = None +__version__ = '0.7.0.dev' -def get_version(): - global __version__ - if not __version__: - __version__ = get_version_from_pom() - return __version__ +# The following utilities are legacy code from the Maven integration; +# see BEAM-378 for further details. -# Read the version from pom.xml file +# Reads the actual version from pom.xml file, def get_version_from_pom(): with open('pom.xml', 'r') as f: pom = f.read() @@ -46,5 +43,15 @@ def get_version_from_pom(): return version -if __name__ == '__main__': - __version__ = get_version_from_pom() +# 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) http://git-wip-us.apache.org/repos/asf/beam/blob/76a05acd/sdks/python/apache_beam/version_test.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/version_test.py b/sdks/python/apache_beam/version_test.py deleted file mode 100644 index e3c431d..0000000 --- a/sdks/python/apache_beam/version_test.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -"""Unit tests for the version module.""" - -import unittest -from apache_beam import version as beam_version - - -class Version(unittest.TestCase): - - def test_version(self): - # Test that version is processed from the external file and cached. - self.assertIsNotNone(beam_version.get_version()) - self.assertEqual(beam_version.get_version(), beam_version.__version__) - - -if __name__ == '__main__': - unittest.main() http://git-wip-us.apache.org/repos/asf/beam/blob/76a05acd/sdks/python/setup.py ---------------------------------------------------------------------- diff --git a/sdks/python/setup.py b/sdks/python/setup.py index 3456e7d..3b44b82 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -30,7 +30,7 @@ from pkg_resources import get_distribution, DistributionNotFound def get_version(): - global_names = {'__name__': '__main__'} + global_names = {} exec(open(os.path.normpath('./apache_beam/version.py')).read(), global_names) return global_names['__version__']
