8000 Dockerfiles Python 3 cleanup by nicknezis · Pull Request #3601 · apache/incubator-heron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Dockerfiles Python 3 cleanup #3601

Merged
merged 11 commits into from
Aug 21, 2020
Merged

Conversation

nicknezis
Copy link
Contributor

No description provided.

@nicknezis nicknezis self-assigned this Aug 6, 2020
@nwangtw
Copy link
Contributor
nwangtw commented Aug 7, 2020

Thanks. Python 3 is kinda annoying. :(

unzip \
git \
curl \
tree \
openjdk-11-jdk-headless

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
Copy link
Contributor

Choose a reason for hiding this comment

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

is linking python to python3 needed - was it that transient dependency which needed it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got this error:

ERROR: An error occurred during the fetch of repository 'pip_deps':
   pip_import failed:  (src/main/tools/process-wrapper-legacy.cc:75: "execvp(python, ...)": No such file or directory
)
ERROR: no such package '@pip_deps//': pip_import failed:  (src/main/tools/process-wrapper-legacy.cc:75: "execvp(python, ...)": No such file or directory
)

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes it sound like bazel (that .cc is a part of it) is trying to run python on the system, rather than python3 for some reason, which would be a preexisting issue. Maybe it's because test --host_force_python=PY3 isn't in tools/bazel.rc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just tested with the following, but it still fails:

test --genrule_strategy=standalone
test --host_force_python=PY3
test --ignore_unsupported_sandboxing
test --spawn_strategy=standalone

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to be related to this line. Maybe we don't need it? Testing it now with it removed.

pip_deps()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it's needed for some of the tar and docker rules.

@@ -413,7 +413,7 @@ def main():
env_map['AUTOMAKE'] = discover_tool('automake', 'Automake', 'AUTOMAKE', '1.9.6')
env_map['AUTOCONF'] = discover_tool('autoconf', 'Autoconf', 'AUTOCONF', '2.6.3')
env_map['MAKE'] = discover_tool('make', 'Make', 'MAKE', '3.81')
env_map['PYTHON3'] = discover_tool('python3', 'Python3', 'PYTHON3', '3.4')
env_map['PYTHON3'] = discover_tool('python3', 'Python3', 'PYTHON3', '3.5')

Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably check that python -m venv returns non-zero (the version will be same as the python interpreter)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have a suggestion of how best to do this? Seems the discover_tool method wouldn't work for what you describe, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

It might take a custom test, which I think there's already some of. I'm not sure if there is a nice portable test for venv other than something like:

import subprocess, tempfile
def test_venv():
    with tempfile.TemporaryDirectory() as tmpdirname:
        return subprocess.run(["python3", "-mvenv", tmdpirname]).returncode == 0

The reason I think this is because I suspect there will be difference with how distribution maintainers can choose how this is included, and trying to cater for nuances doesn't sound good.

trivia: Debian make venv and pip separate packages, whereas the cpython codebase can let you install venv along with python, and then pip will be created using vendoered version that ensurepip unfurls (debian patches this out).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the test function. Let me know if it looks good.

@nicknezis nicknezis marked this pull request as ready for review August 10, 2020 01:56
nicknezis and others added 2 commits August 9, 2020 21:58
Co-authored-by: Oliver Bristow <evilumbrella+github@gmail.com>
Copy link
Contributor
@Code0x58 Code0x58 left a comment

Choose a reason for hiding this comment

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

The changes to use make pythonpython3 ok to me. It's not risk free, as it will mean CI will not bump into issues developers would encounter if they have pythonpython2, but seems a manageable risk - on the bright side it could reduce the risk of issues in official builds.

It looks like the dead images are yet to be removed following your comment.

The python-venv change also seems ok, but does add an additional requirement to developer environments unlike using (an old) virtualenv in the WORKSPACE, so would be something to put some handrails on via ./configure_bazel.py.

@@ -413,7 +413,7 @@ def main():
env_map['AUTOMAKE'] = discover_tool('automake', 'Automake', 'AUTOMAKE', '1.9.6')
env_map['AUTOCONF'] = discover_tool('autoconf', 'Autoconf', 'AUTOCONF', '2.6.3')
env_map['MAKE'] = discover_tool('make', 'Make', 'MAKE', '3.81')
env_map['PYTHON3'] = discover_tool('python3', 'Python3', 'PYTHON3', '3.4')
env_map['PYTHON3'] = discover_tool('python3', 'Python3', 'PYTHON3', '3.5')

Copy link
Contributor

Choose a reason for hiding this comment

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

It might take a custom test, which I think there's already some of. I'm not sure if there is a nice portable test for venv other than something like:

import subprocess, tempfile
def test_venv():
    with tempfile.TemporaryDirectory() as tmpdirname:
        return subprocess.run(["python3", "-mvenv", tmdpirname]).returncode == 0

The reason I think this is because I suspect there will be difference with how distribution maintainers can choose how this is included, and trying to cater for nuances doesn't sound good.

trivia: Debian make venv and pip separate packages, whereas the cpython codebase can let you install venv along with python, and then pip will be created using vendoered version that ensurepip unfurls (debian patches this out).

unzip \
git \
curl \
tree \
openjdk-11-jdk-headless

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
Copy link
Contributor

Choose a reason fo 1E0A r hiding this comment

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

That makes it sound like bazel (that .cc is a part of it) is trying to run python on the system, rather than python3 for some reason, which would be a preexisting issue. Maybe it's because test --host_force_python=PY3 isn't in tools/bazel.rc?

Copy link
Member
@joshfischer1108 joshfischer1108 left a comment

Choose a reason for hiding this comment

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

Looking over I think @Code0x58 gave an in depth review. No issues from me.

@nicknezis nicknezis merged commit 96dda44 into master Aug 21, 2020
nicknezis added a commit that referenced this pull request Sep 14, 2020
@nicknezis nicknezis deleted the nicknezis/python-container-cleanup branch September 14, 2020 20:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0