-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BEAM-13183] [BEAM-8152] Use venv instead of virtualenv to create Python environments in Gradle scripts. #15819
Conversation
Codecov Report
@@ Coverage Diff @@
## master #15819 +/- ##
==========================================
- Coverage 83.63% 83.60% -0.03%
==========================================
Files 445 445
Lines 61371 61329 -42
==========================================
- Hits 51326 51277 -49
- Misses 10045 10052 +7
Continue to review full report at Codecov.
|
Run Python_PVR_Flink PreCommit |
1 similar comment
Run Python_PVR_Flink PreCommit |
Run PythonDocs PreCommit |
Run Python_PVR_Flink PreCommit |
1 similar comment
Run Python_PVR_Flink PreCommit |
Run Python PreCommit |
Run Python_PVR_Flink PreCommit |
Run Python PreCommit |
Run Portable_Python PreCommit |
Run GoPortable PreCommit |
Run Python PreCommit |
Run Portable_Python PreCommit |
Run Python PreCommit |
Run Portable_Python PreCommit |
Run Website PreCommit |
Run GoPortable PreCommit |
Run Java PreCommit |
Run Python_PVR_Flink PreCommit |
Run SQL PreCommit |
be27073
to
0b9e8e2
Compare
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.
This LGTM, I have a few questions though
- pip, setuptools, virtualenv, and tox installed for Python development | ||
- Python 3.x interpreters. You will need Python interpreters for all Python versions supported by Beam. | ||
Interpreters should be installed and available in shell via `python3.x` commands. For more information, see: | ||
Python installation tips in [Developer Wiki](https://cwiki.apache.org/confluence/display/BEAM/Python+Tips#PythonTips-InstallingPythoninterpreters). |
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.
Consider noting the issue with venv in deadsnakes pythons, and the need to install python3.x-dev
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 added a note to the Wiki about it.
dev-support/docker/pkglist
Outdated
tox | ||
docker.io | ||
|
||
|
||
python3.6 python3.6-dev python3.6-venv python3.7 python3.7-dev python3.7-distutils python3.7-venv python3.8 python3.8-dev python3.8-distutils python3.8-venv |
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.
what is this line?
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 think there is some 'dev' environment, and this file lists all apt packages to install in that environment.
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.
ah looks like the line is a leftover, thanks for catching.
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.
re: dev envirornment - this file is referenced from ./local-env-setup.sh
(configures current system), and ./start-build-env.sh
(builds and start a development container)
@@ -33,7 +33,22 @@ openjdk-8-jdk | |||
python3-setuptools | |||
python3-pip | |||
python3.6 | |||
python3.6-dev | |||
python3.6-venv |
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.
Should we drop 3.6? (also note python is aliased to python3.6 in dev-support/docker/Dockerfile)
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's to be dropped in Beam 2.36.0 (after 2.35.0 release cut)
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 see, that makes sense. I thought maybe we were already dropping it because of the for ver in 3.7 3.8 3.9; do
in local-env-setup.sh
@@ -66,7 +66,7 @@ RUN alias python=python3.6 | |||
### | |||
# Install grpcio-tools mypy-protobuf for `python3 sdks/python/setup.py sdist` to work | |||
### | |||
RUN pip3 install grpcio-tools mypy-protobuf virtualenv | |||
RUN pip3 install grpcio-tools mypy-protobuf | |||
|
|||
### | |||
# Install useful tools |
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.
Maybe we can drop distilib below? It says it's installed to workaround a virtualenv issue
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 believe I tried to remove it and still ran into some issues. We can try again later.
local-env-setup.sh
Outdated
fi | ||
if [ ! $(type -P python$ver) > /dev/null 2>&1 ]; then | ||
# For some python packages, brew does not add symlinks... | ||
# TODO: use pyenv. |
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.
What exactly is the TODO here? Will pyenv make symlinks for us?
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.
Reworded to: # TODO: Consider using pyenv to manage multiple installations of Python.
sdks/python/build-requirements.txt
Outdated
@@ -14,6 +14,12 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
# | |||
|
|||
# TODO: Consider PEP-517/PEP-518 instead of this file (BEAM-8954). |
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.
nit:
# TODO: Consider PEP-517/PEP-518 instead of this file (BEAM-8954). | |
# TODO(BEAM-8954): Consider PEP-517/PEP-518 instead of this file. |
# TODO: Consider PEP-517/PEP-518 instead of this file (BEAM-8954). | ||
|
||
setuptools | ||
wheel>=0.36.0 |
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 is this change necessary?
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.
these are common build dependencies, however wheel is not installed by default into venv
, but is installed in virtualenv-created env. without this change, installing from sdist was failing on some python versions.
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.
setuptools is still implicitly installed, keeping it explicitly so that we add them when we adopt PEP-517/518 which might require them mentioned explicitly.
|
||
python -m dependency_check.dependency_check_report_generator Java | ||
$PYTHON -m dependency_check.dependency_check_report_generator Java |
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.
Were you able to verify this (and other .test-infra changes)?
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.
seems to work, thanks.
@@ -648,7 +646,7 @@ if [[ ("$python_xlang_kafka_taxi_dataflow" = true | |||
do | |||
rm -rf ./beam_env_${py_version} | |||
echo "--------------Setting up virtualenv with $py_version interpreter----------------" | |||
virtualenv beam_env_${py_version} -p $py_version | |||
$py_version -m venv beam_env_${py_version} |
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.
Same question about the release script changes, but fortunately you are the next release manager, so I trust you'll be able to detect and fix any issues here.
@@ -22,6 +22,7 @@ plugins { | |||
} | |||
|
|||
applyGoNature() | |||
applyPythonNature() |
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.
Maybe add a comment that this is needed for ./license_scripts/license_script.sh
. Also, why is it that we need this now, but it seemed to work ok before?
@@ -20,6 +20,9 @@ | |||
set -e | |||
set -v | |||
|
|||
# Get currently used Python version from args or assume a default. | |||
PYTHON=${1:-python3} |
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.
Does this work if users are using an alias/symlink?
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.
yes, it should work. python3 is typically a symlink.
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.
alias probably wouldn't work
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.
verified that symlinks work and aliases don't
Run Seed Job |
Run Inventory apache-beam-jenkins-1 |
Run Dependency Check |
Remove a dependency on virtualenv, instead use venv, which is a part of Python library (https://docs.python.org/3/library/venv.html).
Use venv in gradle commands and in the website documentation.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunner
compliance status (on master branch)Examples testing status on various runners
Post-Commit SDK/Transform Integration Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.