• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 35215
0%
main: 93%

Build:
Build:
LAST BUILD BRANCH: fix_uv_lockfile_sync
DEFAULT BRANCH: main
Ran 02 Sep 2020 10:41PM UTC
Jobs 1
Files 430
Run time 21s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
35215

push

travis-ci-com

web-flow
Add a plugin hook for `setup-py` kwargs  (#10721)

### Problem

Users want to be able to automate some of `setup-py`, such as setting the `version` from a file checked into VCS, or even automatically incrementing the version. Pants itself has a need for this, which we used to achieve through the `pants_setup_py` object.

Using an `object` or `context_aware_object_factory` is inadequate. It does not have access to the Rules API, so cannot do things like safely read from the file system or safely read options from subsystems. It's also hard to get caching right when using `object`.

### Solution

Expose a new hook `SetupKwargsRequest`, which allows users to set whatever kwargs they want through writing a rule that returns `SetupKwargs`. They will have access to the original explicit kwargs, and can also use the Rules API and Target API to do more fancy things like reading from the file system.

These kwargs cannot set certain values like `package_dir` and `packages`. This is because Pants will set those values - the plugin is instead meant to set other metadata like `version` and `long_description`.

### Result

A very simple example plugin:

```python
class DemoSetupKwargsRequest(SetupKwargsRequest):
    @classmethod
    def is_applicable(cls, _: Target) -> bool:
        return True


@rule
def setup_kwargs_plugin(request: DemoSetupKwargsRequest) -> SetupKwargs:
    return SetupKwargs(
        {**request.explicit_kwargs, "plugin_demo": "hello world"}, address=request.target.address
    )

```

[ci skip-rust]

143 of 143 new or added lines in 9 files covered. (100.0%)

0 of 29006 relevant lines covered (0.0%)

0.0 hits per line

Jobs
ID Job ID Ran Files Coverage
4 35215.4 (PANTS_CONFIG_FILES="${TRAVIS_BUILD_DIR}/pants.travis-ci.toml" PANTS_DYNAMIC_UI=false LC_ALL="en_US.UTF-8" AWS_BUCKET=ci-public.pantsbuild.org BOOTSTRAPPED_PEX_KEY_PREFIX=daily/${TRAVIS_BUILD_NUMBER}/${TRAVIS_BUILD_ID}/pants.pex NATIVE_ENGINE_SO_KEY_PREFIX=monthly/native_engine_so PYENV_PY27_VERSION=2.7.18 PYENV_PY36_VERSION=3.6.10 PYENV_PY37_VERSION=3.7.7 PYENV_PY38_VERSION=3.8.3 PYENV_ROOT_OSX=${HOME}/.pants_pyenv PYENV_ROOT="${PYENV_ROOT:-${PYENV_ROOT_OSX}}" PATH="${PYENV_ROOT}/shims:${PATH}" AWS_CLI_ROOT="${HOME}/.aws_cli" AWS_ACCESS_KEY_ID__TO_BE_REEXPORTED_ON_DEPLOYS=AKIAV6A6G7RQ2HFZ5KP7 AWS_SECRET_ACCESS_KEY=[secure] RUST_BACKTRACE="all" BOOTSTRAPPED_PEX_KEY_SUFFIX=py36.linux PANTS_REMOTE_CA_CERTS_PATH=/usr/lib/google-cloud-sdk/lib/third_party/grpc/_cython/_credentials/roots.pem CACHE_NAME=python_tests.py36) 02 Sep 2020 10:41PM UTC 0
0.0
Travis Job 35215.4
Source Files on build 35215
Detailed source file information is not available for this build.
  • Back to Repo
  • Build #35215
  • 38a7d946 on github
  • Prev Build on master (#35208)
  • Next Build on master (#35218)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc