Skip to content
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

[internal] Add infrastructure to deprecate target names #13164

Merged
merged 2 commits into from
Oct 8, 2021

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Oct 8, 2021

This allows us to have two aliases refer back to the same target type. This means that ./pants filter --target-type will work the same as before. Target generation will also work the same, which matches an exact target type, rather than being field-based like most of the Target API.

Example:

❯ ./pants filter --target-type=pex_binary build-support::
22:52:04.98 [WARN] DEPRECATED: the target name pex_binary will be removed in version 2.9.0.dev0.

Instead, use `new_name`, which behaves the same.
22:52:04.99 [WARN] DEPRECATED: using `filter --target-type=pex_binary` will be removed in version 2.9.0.dev0.

Use `filter --target-type=new_name` instead.
...

[ci skip-rust]
[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]
@Eric-Arellano Eric-Arellano merged commit 2b1a6e3 into pantsbuild:main Oct 8, 2021
@Eric-Arellano Eric-Arellano deleted the rename-target branch October 8, 2021 16:00
Eric-Arellano added a commit that referenced this pull request Oct 10, 2021
…t` (#13133)

As articulated in the [target generator proposal](https://docs.google.com/document/d/1HpJn2jTWf5sKob6zhe4SqHZ7KWBlX4a6OJOwnuw-IHo/edit), Pants builds are made up of targets representing the "atom"s of the language, like a single `python_test` file vs. a `go_package` directory. In Python, the atom is a single requirement, like `Django`.

Technically, we let you put multiple requirements into a `python_requirement_library`. But it's intended that the requirements string are for the same project, and it's meant to accommodate `Django==2 ; sys_version<3 && Django==3 ; sys_version>3`. Our macros already conform to that usage.

If you want to relate two different projects—such as that you need `setuptools` for a particular requirement to build—you should use the `dependencies` field.

So, renaming to `python_requirement`:

1. Better captures that it refers to a single external project,
2. Avoids confusion with what a "library" means, and
3. Is less verbose.

--

This adds a script `rename_targets_pants28.py` to automate fixing BUILD files for users. It's not done via tailor because this script is one-time and throw-away.

## Impact on `./pants peek`

The targets generated by macros like `python_requirements` will now report the `target_type` as `python_requirement`. There's no graceful way to handle that deprecation: we can't have `./pants peek` claim it has two target names.

## No impact on `./pants filter --target-type`

Thanks to #13164, you can safely use either the new name or old name.

[ci skip-rust]
[ci skip-build-wheels]
@stuhood stuhood mentioned this pull request Oct 11, 2021
kaos added a commit that referenced this pull request Nov 26, 2021
)

Inspired by #13164 

Pre-work for renaming the `pypi_repositories` field to `repositories` for `python_distribution` targets.
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.

2 participants