Skip to content

[BEAM-13183] [BEAM-8152] Use venv instead of virtualenv to create Python environments in Gradle scripts.#15819

Merged
tvalentyn merged 6 commits intoapache:masterfrom
tvalentyn:venv
Nov 18, 2021
Merged

[BEAM-13183] [BEAM-8152] Use venv instead of virtualenv to create Python environments in Gradle scripts.#15819
tvalentyn merged 6 commits intoapache:masterfrom
tvalentyn:venv

Conversation

@tvalentyn
Copy link
Copy Markdown
Contributor

@tvalentyn tvalentyn commented Oct 27, 2021

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:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

ValidatesRunner compliance status (on master branch)

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- Build Status Build Status Build Status Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Python --- Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status ---
XLang Build Status Build Status Build Status Build Status Build Status ---

Examples testing status on various runners

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- --- --- --- --- --- ---
Java --- Build Status
Build Status
Build Status
--- --- --- --- ---
Python --- --- --- --- --- --- ---
XLang --- --- --- --- --- --- ---

Post-Commit SDK/Transform Integration Tests Status (on master branch)

Go Java Python
Build Status Build Status Build Status
Build Status
Build Status

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 27, 2021

Codecov Report

Merging #15819 (e87f846) into master (2335ec6) will decrease coverage by 0.02%.
The diff coverage is n/a.

❗ Current head e87f846 differs from pull request most recent head 0a5ec87. Consider uploading reports for the commit 0a5ec87 to get more accurate results
Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
...hon/apache_beam/runners/direct/test_stream_impl.py 94.02% <0.00%> (-2.24%) ⬇️
...pache_beam/runners/interactive/interactive_beam.py 75.60% <0.00%> (-0.98%) ⬇️
sdks/python/apache_beam/runners/direct/executor.py 96.46% <0.00%> (-0.55%) ⬇️
...runners/interactive/display/pcoll_visualization.py 85.85% <0.00%> (-0.51%) ⬇️
sdks/python/apache_beam/transforms/combiners.py 93.15% <0.00%> (-0.40%) ⬇️
...eam/runners/interactive/interactive_environment.py 91.37% <0.00%> (-0.35%) ⬇️
sdks/python/apache_beam/typehints/typehints.py 93.34% <0.00%> (-0.10%) ⬇️
sdks/python/apache_beam/coders/coders.py 88.61% <0.00%> (-0.03%) ⬇️
sdks/python/apache_beam/pipeline.py 91.73% <0.00%> (-0.02%) ⬇️
sdks/python/apache_beam/transforms/core.py 92.63% <0.00%> (-0.01%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2335ec6...0a5ec87. Read the comment docs.

@tvalentyn tvalentyn changed the title [BEAM-12000] Use venv instead of virtualenv to avoid a virtualenv dependency that can be avoided. [BEAM-8152] Use venv instead of virtualenv to avoid a virtualenv dependency that can be avoided. Oct 27, 2021
@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python_PVR_Flink PreCommit

1 similar comment
@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python_PVR_Flink PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run PythonDocs PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python_PVR_Flink PreCommit

1 similar comment
@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python_PVR_Flink PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python_PVR_Flink PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Portable_Python PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run GoPortable PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Portable_Python PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Portable_Python PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Website PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run GoPortable PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Python_PVR_Flink PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run SQL PreCommit

@tvalentyn tvalentyn force-pushed the venv branch 2 times, most recently from be27073 to 0b9e8e2 Compare November 12, 2021 06:51
@tvalentyn tvalentyn changed the title [BEAM-8152] Use venv instead of virtualenv to avoid a virtualenv dependency that can be avoided. [BEAM-8152] Use venv instead of virtualenv to create Python environments on Gradle. Nov 12, 2021
@tvalentyn tvalentyn changed the title [BEAM-8152] Use venv instead of virtualenv to create Python environments on Gradle. [BEAM-8152] Use venv instead of virtualenv to create Python environments in Gradle scripts. Nov 12, 2021
@tvalentyn
Copy link
Copy Markdown
Contributor Author

r: @ryanthompson591 @TheNeuralBit

Copy link
Copy Markdown
Member

@TheNeuralBit TheNeuralBit left a 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

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what is this line?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

@TheNeuralBit TheNeuralBit Nov 17, 2021

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)

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Contributor Author

@tvalentyn tvalentyn Nov 18, 2021

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)

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
# TODO: Consider PEP-517/PEP-518 instead of this file (BEAM-8954).
# TODO(BEAM-8954): Consider PEP-517/PEP-518 instead of this file.

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

seems to work, thanks.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Seed Job

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Inventory apache-beam-jenkins-1

@tvalentyn
Copy link
Copy Markdown
Contributor Author

Run Dependency Check

@tvalentyn tvalentyn changed the title [BEAM-8152] Use venv instead of virtualenv to create Python environments in Gradle scripts. [BEAM-13183] [BEAM-8152] Use venv instead of virtualenv to create Python environments in Gradle scripts. Nov 18, 2021
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.

3 participants