diff --git a/sdks/python/apache_beam/__init__.py b/sdks/python/apache_beam/__init__.py index 2001c80ce6e6..044eacc7ee12 100644 --- a/sdks/python/apache_beam/__init__.py +++ b/sdks/python/apache_beam/__init__.py @@ -81,5 +81,3 @@ from apache_beam.pipeline import Pipeline from apache_beam.transforms import * # pylint: enable=wrong-import-position - -__version__ = version.get_version() diff --git a/sdks/python/apache_beam/version.py b/sdks/python/apache_beam/version.py index ef07dbf99f99..d46433aa23f7 100644 --- a/sdks/python/apache_beam/version.py +++ b/sdks/python/apache_beam/version.py @@ -18,6 +18,7 @@ """Apache Beam SDK version information and utilities.""" +import os import re @@ -33,7 +34,7 @@ def get_version(): # Read the version from pom.xml file def get_version_from_pom(): - with open('pom.xml', 'r') as f: + with open(os.path.join(os.path.dirname(__file__), '..', 'pom.xml'), 'r') as f: pom = f.read() regex = (r'.*\s*' r'[a-z\.]+\s*' diff --git a/sdks/python/setup.py b/sdks/python/setup.py index 3456e7de26f5..172691cd36c0 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -30,7 +30,9 @@ def get_version(): - global_names = {'__name__': '__main__'} + global_names = { + '__name__': '__main__', + '__file__': os.path.abspath('./apache_beam/version.py')} exec(open(os.path.normpath('./apache_beam/version.py')).read(), global_names) return global_names['__version__']