Skip to content

Conversation

@wikier
Copy link
Member

@wikier wikier commented Feb 1, 2017

By replacing the usage of execfile() by exec(), which is the official recommendation for portability.

Further details described at BEAM-1368.


Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

  • Make sure the PR title is formatted like:
    [BEAM-<Jira issue #>] Description of pull request
  • Make sure tests pass via mvn clean verify. (Even better, enable
    Travis-CI on your fork and ensure the whole test matrix passes).
  • Replace <Jira issue #> in the title with the actual Jira issue
    number, if there is one.
  • If this contribution is large, please file an Apache
    Individual Contributor License Agreement.

@wikier wikier changed the title [BEAM-1368] fixed setup should be portable to Python 3.x [BEAM-1368] fixed Python SDK setup in Python 3.x Feb 1, 2017
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 5253bcb on wikier:BEAM-1368_setup_python3 into ** on apache:master**.

@asfbot
Copy link

asfbot commented Feb 1, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/6958/
--none--

@aaltay
Copy link
Member

aaltay commented Feb 2, 2017

R: @chamikaramj

(@wikier I assume this is ready for review, please correct me if that is not the case)

@chamikaramj
Copy link
Contributor

Looks good. Just waiting for tests to pass.

@chamikaramj
Copy link
Contributor

retest this please

Any idea why tests are not completing here ?

@wikier
Copy link
Member Author

wikier commented Feb 3, 2017

Yes @aaltay, should be ready to review.

I have no idea why the tests are failing @chamikaramj, but doesn't look relevant to this PR.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 69.681% when pulling 5253bcb on wikier:BEAM-1368_setup_python3 into 92021c5 on apache:master.

@asfbot
Copy link

asfbot commented Feb 3, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7063/
--none--

@chamikaramj
Copy link
Contributor

LGTM

@chamikaramj
Copy link
Contributor

R: @robertwb for merging.

global_names = {}
execfile(os.path.normpath('./apache_beam/version.py'),
global_names)
exec(open(os.path.normpath('./apache_beam/version.py')).read(), global_names)
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Member

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_beam is installed, and import does not work at that stage.

If there is a way to import it instead of exec I would prefer that too.

Copy link
Contributor

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

Copy link
Member

@aaltay aaltay Feb 4, 2017

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 version and that fails with cannot import name coders. Maybe we also need to change something in apache_beam/__init__.py for the import to work.

Copy link
Member Author

@wikier wikier Feb 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the trick with exec is for avoiding importing the apache_beam module upon its installation.

Copy link
Contributor

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.

Copy link
Member

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 exec from the version.py.

Copy link
Member Author

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.version is 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.

@asfgit asfgit closed this in cf9d221 Feb 9, 2017
@sneurlax
Copy link

sneurlax commented Jan 4, 2018

What's the word on this? #4078 ?

@aaltay
Copy link
Member

aaltay commented Jan 4, 2018

@sneurlax Python 3 conversion work is ongoing. The master issue for tracking is: https://issues.apache.org/jira/browse/BEAM-1251. If you are interested, we would be happy to accept contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants