-
-
Notifications
You must be signed in to change notification settings - Fork 646
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 back python_app
/ bundle
, but improved
#10733
Comments
Requirements
Nice to haves
ProposalAdd a new
To accommodate archive(
binaries=[":bin1", ":bin2"],
files=["//:files1"],
format=".zip"
) files(
name="files1",
sources=["*.json"],
path_prefix="json_files/"
) |
Thanks! And as discussed in the comments on #10756, it would be good to be consistent about whether there are separate
This will be important. One related challenge that occurred to me is that configuring the EDIT: And another thing that we should likely fix here as well is that |
We've marked this as a blocker for
If it turns out that we don't need to change |
I was typing out some thoughts about how technically we can allow any target type in the But while typing it out, I realized that in order to get the files to show up without their source roots in both In other words, I think that always using a -- There's one downside that Pants generally doesn't work as well if >1 target refers to the same file. The main place this breaks things is dep inference. But, fortunately, our dep inference code only considers Python targets, so it's legal to have a |
I'm working on the
Some other requirements:
I'm thinking the most flexible design will be a # 1 remove 'src/python'
files(
path_prefix_mapper={"src/python": ""},
)
# 2 add 'thirdparty'
files(
path_prefix_mapper={"": "thirdparty"},
)
# 3 remove and then add
files(
path_prefix_mapper={"src/python": "thirdparty"},
) This field would validate that the dict does not have >1 entry. Why? This manipulation should apply to every single file in the I think I'd prefer to avoid multiple different fields that are all related, like we had with |
This all looks great!
And re:
The single-entry |
I think that determining the connection between the "mapping" and source roots is the main thing to nail down with regard to unblocking
|
### Problem As explained in #10733 and #10876, we are adding back an improved version of the `bundle` goal, and we need a way for users to have Pants relocate loose source files, which they previously did via `bundle(rel_path=)`. Further, we want to allow users to relocate in other contexts, too, such as for `tests`. ### Solution Add a new intermediate target type called `relocated_files`, which has fields for the original `files()` targets and for the desired mapping. This will then use codegen to apply the mapping and generate `FilesSources`. This solution is chosen instead of two alternative designs: 1) Define the mapping on the `files()` target, as done in #10876. This implementation was messy and leaked in lots of places. We also think the risk was too high that a user would change a `files()` target and accidentally break multiple consumers. 2) Have every consumer define its own mapping. This does not scale well as it's not composable. Instead, we find a happy medium by using this intermediate type. There is still a risk of #1, where changing the target will break every consumer. But we think this risk is much lower given the explicitness of having a `relocated_files` target type. You can safely define multiple `relocated_files` targets over the same original `files` target if you want multiple distinct mappings for the same file. [ci skip-rust] [ci skip-build-wheels]
…al (#10881) We now have several goals that build an asset: * `binary` * `awslambda` * `setup-py` Soon, we will be adding support for an `archive()` target type as part of #10733. An `archive` is not really a `binary`, nor any of the other two. We don't want to add a _fourth_ goal `archive`. It gets confusing when there are lots of goals; and it also makes things like `runtime_binary_dependencies` less flexible, e.g. not working with `python_awslambda`. Semantically, the `package` goal is for transforming your code into a single exportable asset that goes into `--distdir`. This is different than, say, a `compile` goal; running on a library target should no-op. This only deprecates `awslambda` and `binary` for now; `setup-py` will be a followup, as that doesn't port as easily due to passthrough args. See https://docs.google.com/document/d/1q77XvcIU9dCzuzA2iFRQQ9AGIfV9jpR269415HdEt0E/edit# for a design doc diving more into this. [ci skip-rust] [ci skip-build-wheels]
Closes #10733. Users liked being able to use `bundle` to be able to create archives which included loose files + binaries. This adds back that feature, but in a simpler way: * `archive` is used regardless of language. No more `python_app` vs. `jvm_app`. * Depending on loose files is down like a normal dependency now, no more `bundle`. To relocate files, you can use the `relocated_files` target. * Your `archive` can contain other `archive`s, or anything built via `./pants package`. For example: ```python archive( files=["src/resources:relocated_json"], packages=["src/python:app"], format="tgz", ) ``` ```bash > ./pants package '//:app_archive' ``` [ci skip-rust] [ci skip-build-wheels]
A user explained that they have use for this goal. They very intentionally want the loose files to be kept outside the .pex file.
However, we should make this much simpler than before and redesign from first principles.
The text was updated successfully, but these errors were encountered: