-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Add ability to run
any PythonSourceField
#15849
Conversation
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
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 has a little bit of time-sensitivity due to pulling pex_binary
's run_in_sandbox
field 😉
src/python/pants/backend/python/goals/run_pex_binary_integration_test.py
Outdated
Show resolved
Hide resolved
# @TODO: How should we make this customizable? | ||
# `False` is backwards-compatible behavior right now | ||
run_in_sandbox=False, | ||
# Setting --venv is kosher because the PEX we create is just for the thirdparty deps. |
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 just kosher, but desirable due to pex-tool/pex#1802. Happy to hear better comment wordsmithing.
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.
No longer necessary if we upgrade PEX to a version which fixes pex-tool/pex#1802
python_sources(name="main_lib", | ||
sources=["main.py"], | ||
# Force-exclude any dep on bar.py, so the only way to consume it is via the dist. | ||
dependencies=[":dist", "!:lib"], |
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 is slightly tweaked from the pex_binary
case because we can't use transitive excludes.
Can I/should I pull the plug on the in-repo EDIT: I'll do this in follow-up PR. I want to be able to demonstrate the ambiguity easily. |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Example of deprecations (while there is ambiguity and the
|
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
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.
Yay!!
Docs need to be updated for the Python package
and run
pages before merging. I'm gonna be OOO till Thursday, but lmk if you want an assist when I get back.
Our deprecation messages might want to suggest for people that they get rid of pex_binary
targets they use to have. No need. And you can delete all of build-support/bin
I think :)
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
I'll take a stab at the docs. The deprecation message does make the suggestion:
I'll dedicate a separate PR for deletion of our binary targets 😄 |
| My vote is well-documented flag on run (and eventually repl) An issue with that is that it's meaningless for compiled languages. |
That's the well documented part 😉 This is relevant for any language which can run on the loose files, so mostly scripting languages. Maybe I just make it a field, and hope either the default covers most cases or its rare people will want to toggle between the two modes on the same target easily? |
Naming nit: |
I'm still trying to figure out if I think this is intuitive to Winston. I think on balance yes? "Run a source file" seems to intuitively mean "run it and its deps directly from source" and "Run a package" seems to intuitively mean "build an executable and run it". I think the risks re --changed and --loop not doing the right thing are acceptable. |
I like the idea, but the option is on the |
They do the right thing, just on the metadata they have (which might not be right). It's a slight difference, but an important one IMO. Because the use-case we're explicitly not considering isn't that it "doesnt work", but that |
were packaged in a `pex_binary`. Additionally, it may be necessary if your sources depend | ||
transitively on "generated" files which will be materialized in the sandbox in a source | ||
root, but are not in-repo. |
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.
Ya know, we can technically inspect the dep tree for this and issue a warning if the field isn't explictly set or something similar 🤔
Not saying we should block this PR on it, but worth an issue filed once this is in.
|
…to runpython # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Also FWIW this will likely be set in |
Hmmm this just occurred to me, how should we handle restartable? Why is that a field and not a |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
run's counterpart to pantsbuild#15799. Support is added for pex_binary (which will be spiritually lifted to the python_source with pantsbuild#15849) [ci skip-rust] [ci skip-build-wheels]
run's counterpart to pantsbuild#15799. Support is added for pex_binary (which will be spiritually lifted to the python_source with pantsbuild#15849) [ci skip-rust] [ci skip-build-wheels]
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.
Huzzah!
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
…to runpython # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
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.
🎉
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
With #15849 the default for the `--tailor-pex-binary-targets` flag should naturally be `False`, so this begins the path to that. [ci skip-rust] [ci skip-build-wheels]
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> [ci skip-build-wheels]
…ld#15962) With pantsbuild#15849 the default for the `--tailor-pex-binary-targets` flag should naturally be `False`, so this begins the path to that. [ci skip-rust] [ci skip-build-wheels]
…16022) (Minor user API change 😄 ) This PR encompasses a few changes which combined achieve the goal of [the proposal doc](https://docs.google.com/document/d/1R9m-DtM8Y5UKx5iam5ipeK531tZR40_P7El4ucYq4Po). It: - Adds support for `run` on a `PythonSourceField`. The implementation is 100% shifted from `run`ning a `pex_binary` - A new field was added to the `PythonSourceField` targets: `run_goal_use_sandbox` - Unfortunately, for consistency, this (including the new field) applies to `_test_utils` and `_test` targets as well 🤷♂️ - Add a global flag `--use-deprecated-pex-binary-run-semantics` which toggles between the "new" and "old" behavior and must be set (will have the default changed in 2.14 and be removed in 2.15). - Special-cases the handling of an ambiguity between 2 targets if it is between a `pex_binary` and `python_source`. This allows us a path forward without breaking clients who (very very very often) use `./pants run path/to/file.py` to refer to the `pex_binary`. Which target gets selected is based on `--use-deprecated-pex-binary-run-semantics`. - Removes `run_in_sandbox` field from `pex_binary` (this never made it to a stable release, so non-breaking) [ci skip-rust] [ci skip-build-wheels]
(Minor user API change 😄 )
This PR encompasses a few changes which combined achieve the goal of the proposal doc.
It:
run
on aPythonSourceField
. The implementation is 100% shifted fromrun
ning apex_binary
PythonSourceField
targets:run_goal_use_sandbox
_test_utils
and_test
targets as well 🤷♂️--use-deprecated-pex-binary-run-semantics
which toggles between the "new" and "old" behavior and must be set (will have the default changed in 2.14 and be removed in 2.15).pex_binary
andpython_source
. This allows us a path forward without breaking clients who (very very very often) use./pants run path/to/file.py
to refer to thepex_binary
. Which target gets selected is based on--use-deprecated-pex-binary-run-semantics
.run_in_sandbox
field frompex_binary
(this never made it to a stable release, so non-breaking)[ci skip-rust]
[ci skip-build-wheels]