Skip to content

Commit 5c9912e

Browse files
Upgrade to Pants 2.10 (#91)
1 parent 1b38d08 commit 5c9912e

8 files changed

Lines changed: 53 additions & 48 deletions

File tree

.github/workflows/pants.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: ./pants tailor --check update-build-files --check
5050
- name: Lint and typecheck
5151
run: |
52-
./pants lint typecheck ::
52+
./pants lint check ::
5353
- name: Test
5454
run: |
5555
./pants test ::

BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# A macro that turns every entry in this directory's requirements.txt into a
55
# `python_requirement_library` target. Refer to
66
# https://www.pantsbuild.org/docs/python-third-party-dependencies.
7-
python_requirements()
7+
python_requirements(name="reqs")

README.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Pants commands are called _goals_. You can get a list of goals with
2626
# Targets
2727

2828
Targets are a way of setting metadata for some part of your code, such as timeouts for tests and
29-
entry points for binaries. Targets have types like `python_binary`, `resources`, and
29+
entry points for binaries. Targets have types like `python_source`, `resources`, and
3030
`pex_binary`. They are defined in `BUILD` files.
3131

3232
Pants goals can be invoked on targets or directly on source files (which is often more intuitive and convenient).
@@ -78,12 +78,6 @@ Targets are referenced on the command line using their address, of the form `pat
7878
./pants lint helloworld/util:util
7979
```
8080

81-
You can omit the target name if it is the same as the immediately enclosing directory name, e.g.,
82-
83-
```
84-
./pants lint helloworld/util
85-
```
86-
8781
You can glob over all targets in a directory with a single trailing `:`, or over all targets in a directory
8882
and all its subdirectories with a double trailing `::`, e.g.,
8983

@@ -103,11 +97,6 @@ those, rather than error. So you can safely do things like
10397

10498
To run all tests.
10599

106-
In some cases trying to run a goal on multiple files or targets will fail due to conflicts. For example, you cannot
107-
`./pants repl helloworld::` because that globs over both Python 2 and Python 3 code, so there is
108-
no way to select an interpreter compatible with both both to run the REPL on.
109-
110-
111100
# Example Goals
112101

113102
Try these out in this repo!
@@ -123,13 +112,13 @@ Try these out in this repo!
123112

124113
```
125114
./pants lint ::
126-
./pants fmt 'helloworld/**/*.py'
115+
./pants fmt helloworld/greet::
127116
```
128117

129118
## Run MyPy
130119

131120
```
132-
./pants typecheck ::
121+
./pants check ::
133122
```
134123

135124
## Run tests
@@ -157,7 +146,7 @@ Try these out in this repo!
157146

158147
```
159148
./pants repl helloworld/greet # The REPL will have all relevant code and dependencies on its sys.path.
160-
./pants repl --shell=ipython helloworld/greet
149+
./pants repl --shell=ipython helloworld/greet --no-pantsd # To use IPython, you must disable Pantsd for now.
161150
```
162151

163152
## Build a wheel / generate `setup.py`
@@ -168,11 +157,13 @@ This will build both a `.whl` bdist and a `.tar.gz` sdist.
168157
./pants package helloworld/util:dist
169158
```
170159

171-
We can also remove the `setup_py_commands` field from `helloworld/util/BUILD` to have Pants instead generate a
172-
`setup.py` file, with all the relevant code in a chroot.
173-
174160
## Count lines of code
175161

176162
```
177163
./pants count-loc '**/*'
178164
```
165+
## Create virtualenv for IDE integration
166+
167+
```
168+
./pants export ::
169+
```

build-support/generate_constraints.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

constraints.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

helloworld/greet/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
# This target sets the metadata for all the Python non-test files in this directory.
55
#
6-
# * Pants cannot infer dependencies on `resource` / `resources` targets, so we explicitly add the
7-
# dep.
6+
# * Pants cannot yet infer dependencies on `resource` / `resources` targets, so we explicitly add
7+
# the dep.
88
python_sources(
99
name="lib",
1010
dependencies=[":translations"],

lockfile.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This lockfile was autogenerated by Pants. To regenerate, run:
2+
#
3+
# ./pants generate-lockfiles --resolve=python-default
4+
#
5+
# --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
6+
# {
7+
# "version": 2,
8+
# "valid_for_interpreter_constraints": [
9+
# "CPython>=3.7"
10+
# ],
11+
# "generated_with_requirements": [
12+
# "ansicolors==1.1.8",
13+
# "setuptools<57,>=56.2.0",
14+
# "types-setuptools<58,>=56.2.0"
15+
# ]
16+
# }
17+
# --- END PANTS LOCKFILE METADATA ---
18+
19+
ansicolors==1.1.8 \
20+
--hash=sha256:00d2dde5a675579325902536738dd27e4fac1fd68f773fe36c21044eb559e187 \
21+
--hash=sha256:99f94f5e3348a0bcd43c82e5fc4414013ccc19d70bd939ad71e0133ce9c372e0
22+
setuptools==56.2.0; python_version >= "3.6" \
23+
--hash=sha256:bc30153eec47d82f20c6f5e1a13d4ee725c6deb7013a67557f89bfe5d25235c4 \
24+
--hash=sha256:7bb5652625e94e73b9358b7ed8c6431b732e80cf31f4e0972294c64f0e5b849e
25+
types-setuptools==57.4.9 \
26+
--hash=sha256:536ef74744f8e1e4be4fc719887f886e74e4cf3c792b4a06984320be4df450b5 \
27+
--hash=sha256:948dc6863373750e2cd0b223a84f1fb608414cde5e55cf38ea657b93aeb411d2

pants.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the Apache License, Version 2.0 (see LICENSE).
33

44
[GLOBAL]
5-
pants_version = "2.9.0"
5+
pants_version = "2.10.0rc0"
66
backend_packages.add = [
77
"pants.backend.python",
88
"pants.backend.python.lint.docformatter",
@@ -12,6 +12,11 @@ backend_packages.add = [
1212
"pants.backend.python.typecheck.mypy",
1313
]
1414

15+
# This will become the default in 2.11, and is only explicitly set to not break
16+
# backwards-compatibility for existing users. If you are setting up Pants for
17+
# the first time, set this to false.
18+
use_deprecated_python_macros = false
19+
1520
[anonymous-telemetry]
1621
enabled = true
1722
repo_id = "3B1D361B-E9F1-49A8-B761-03DCC41FD58E"
@@ -24,9 +29,14 @@ root_patterns = ["/"]
2429
# The default interpreter compatibility for code in this repo. Individual targets can override
2530
# this with the `interpreter_constraints` field. See
2631
# https://www.pantsbuild.org/docs/python-interpreter-compatibility.
32+
#
33+
# If you use Apple Silicon, set to a value like `>=3.9`.
2734
interpreter_constraints = [">=3.7"]
28-
# Use a constraints file. See https://www.pantsbuild.org/docs/python-third-party-dependencies.
29-
requirement_constraints = "constraints.txt"
35+
36+
# Enable the "resolves" mechanism, which allows you to have multiple lockfiles and for Pants to
37+
# generate the lockfiles for you. See https://www.pantsbuild.org/docs/python-third-party-dependencies.
38+
enable_resolves = true
39+
resolves = { python-default = "lockfile.txt"}
3040

3141
[python-bootstrap]
3242
# We search for interpreters on both on the $PATH and in the `$(pyenv root)/versions` folder.

0 commit comments

Comments
 (0)