Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why in the world are we using exec here rather than just importing this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this was originally added and seems like we had this for some time. Might have been due to we wanting to execute this every time to capture any updates to environment instead of using a compiled version. Doesn't look like this is needed for the current usage of this file though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasons was, this executes at setup time before
apache_beamis installed, andimportdoes not work at that stage.If there is a way to
importit instead ofexecI would prefer that too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should work as a relative import; many packages do that. E.g. https://github.com/cython/cython/blob/master/setup.py#L254
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thank you.
@wikier I tried
from apache_beam.utils import versionand that fails withcannot import name coders. Maybe we also need to change something inapache_beam/__init__.pyfor the import to work.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the trick with
execis for avoiding importing theapache_beammodule upon its installation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we could put version.py at the top level. LGTM, merging this for now as it is an improvement for Python 3, even if still not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened https://issues.apache.org/jira/browse/BEAM-1431 for removing
execfrom theversion.py.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure... the purpose of
apache_beam.versionis to have access to the version at runtime. The trick this PR patched was already there for the purpose I commented before. It's typical chicken-and-egg problem of setuptools.