Skip to content

Commit a792a8b

Browse files
authored
Upgrade to Pants 2.15.0 and use scie-pants. (#122)
1 parent c5f6f1f commit a792a8b

File tree

7 files changed

+48
-548
lines changed

7 files changed

+48
-548
lines changed

.github/workflows/pants.yaml

+11-9
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ jobs:
2424
python-version: [3.9]
2525
steps:
2626
- uses: actions/checkout@v3
27-
- uses: pantsbuild/actions/init-pants@v2
27+
- uses: actions/setup-python@v4
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- uses: pantsbuild/actions/init-pants@v4-scie-pants
2831
# This action bootstraps pants and manages 2-3 GHA caches.
2932
# See: github.com/pantsbuild/actions/tree/main/init-pants/
3033
with:
31-
pants-python-version: ${{ matrix.python-version }}
32-
# cache0 makes it easy to bust the cache if needed
34+
# v0 makes it easy to bust the cache if needed
3335
# just increase the integer to start with a fresh cache
34-
gha-cache-key: cache0-py${{ matrix.python-version }}
36+
gha-cache-key: v0
3537
# The Python backend uses named_caches for Pip/PEX state,
3638
# so it is appropriate to invalidate on lockfile changes.
3739
named-caches-hash: ${{ hashFiles('python-default.lock') }}
@@ -47,18 +49,18 @@ jobs:
4749
# Alternatively you change gha-cache-key to ignore old caches.
4850
- name: Check BUILD files
4951
run: |
50-
./pants tailor --check update-build-files --check ::
52+
pants tailor --check update-build-files --check ::
5153
- name: Lint and typecheck
5254
run: |
53-
./pants lint check ::
55+
pants lint check ::
5456
- name: Test
5557
run: |
56-
./pants test ::
58+
pants test ::
5759
- name: Package / Run
5860
run: |
5961
# We also smoke test that our release process will work by running `package`.
60-
./pants package ::
61-
./pants run helloworld/main.py
62+
pants package ::
63+
pants run helloworld/main.py
6264
- name: Upload pants log
6365
uses: actions/upload-artifact@v3
6466
with:

README.md

+34-32
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ example layouts.
99

1010
# Running Pants
1111

12-
You run Pants goals using the `./pants` wrapper script, which will bootstrap the
13-
configured version of Pants if necessary.
12+
You run Pants goals using the `pants` launcher binary, which will bootstrap the
13+
version of Pants configured for this repo if necessary.
1414

15-
> :question: Running with Apple Silicon and/or MacOS? You will want to make changes to the `search_path` and
16-
`interpreter_constraints` values in `pants.toml` before running `./pants` - there is guidance in `pants.toml`
15+
See [here](https://www.pantsbuild.org/docs/installation) for how to install the `pants` binary.
16+
17+
> :question: Running with Apple Silicon and/or macOS? You will want to make changes to the `search_path` and
18+
`interpreter_constraints` values in `pants.toml` before running `pants` - there is guidance in `pants.toml`
1719
for those settings.
1820

19-
Use `./pants --version` to see the version of Pants configured for the repo (which you can also find
21+
Use `pants --version` to see the version of Pants configured for the repo (which you can also find
2022
in `pants.toml`).
2123

2224
# Goals
2325

2426
Pants commands are called _goals_. You can get a list of goals with
2527

2628
```
27-
./pants help goals
29+
pants help goals
2830
```
2931

3032
# Targets
@@ -41,52 +43,52 @@ In the latter case, Pants locates target metadata for the source files as needed
4143
Invoking goals on files is straightforward, e.g.,
4244

4345
```
44-
./pants test helloworld/greet/greeting_test.py
46+
pants test helloworld/greet/greeting_test.py
4547
```
4648

4749
You can use globs:
4850

4951
```
50-
./pants lint helloworld/greet/*.py
52+
pants lint helloworld/greet/*.py
5153
```
5254

5355
But note that these will be expanded by your shell, so this is equivalent to having used
5456

5557
```
56-
./pants lint helloworld/greet/__init__.py helloworld/greet/greeting.py helloworld/greet/greeting_test.py
58+
pants lint helloworld/greet/__init__.py helloworld/greet/greeting.py helloworld/greet/greeting_test.py
5759
```
5860

5961
If you want Pants itself to expand the globs (which is sometimes necessary), you must quote them in the shell:
6062

6163
```
62-
./pants lint 'helloworld/greet/*.py'
64+
pants lint 'helloworld/greet/*.py'
6365
```
6466

6567
You can run on all changed files:
6668

6769
```
68-
./pants --changed-since=HEAD lint
70+
pants --changed-since=HEAD lint
6971
```
7072

7173
You can run on all changed files, and any of their "dependees":
7274

7375
```
74-
./pants --changed-since=HEAD --changed-dependees=transitive test
76+
pants --changed-since=HEAD --changed-dependees=transitive test
7577
```
7678

7779
## Target specifications
7880

7981
Targets are referenced on the command line using their address, of the form `path/to/dir:name`, e.g.,
8082

8183
```
82-
./pants lint helloworld/greet:lib
84+
pants lint helloworld/greet:lib
8385
```
8486

8587
You can glob over all targets in a directory with a single trailing `:`, or over all targets in a directory
8688
and all its subdirectories with a double trailing `::`, e.g.,
8789

8890
```
89-
./pants lint helloworld::
91+
pants lint helloworld::
9092
```
9193

9294
## Globbing semantics
@@ -96,7 +98,7 @@ For example, if you run the `test` goal over a set of files that includes non-te
9698
those, rather than error. So you can safely do things like
9799

98100
```
99-
./pants test ::
101+
pants test ::
100102
```
101103

102104
To run all tests.
@@ -108,67 +110,67 @@ Try these out in this repo!
108110
## List targets
109111

110112
```
111-
./pants list :: # All targets.
112-
./pants list 'helloworld/**/*.py' # Just targets containing Python code.
113+
pants list :: # All targets.
114+
pants list 'helloworld/**/*.py' # Just targets containing Python code.
113115
```
114116

115117
## Run linters and formatters
116118

117119
```
118-
./pants lint ::
119-
./pants fmt helloworld/greet::
120+
pants lint ::
121+
pants fmt helloworld/greet::
120122
```
121123

122124
## Run MyPy
123125

124126
```
125-
./pants check ::
127+
pants check ::
126128
```
127129

128130
## Run tests
129131

130132
```
131-
./pants test :: # Run all tests in the repo.
132-
./pants test --output=all :: # Run all tests in the repo and view pytest output even for tests that passed (you can set this permanently in pants.toml).
133-
./pants test helloworld/translator:tests # Run all the tests in this target.
134-
./pants test helloworld/translator/translator_test.py # Run just the tests in this file.
135-
./pants test helloworld/translator/translator_test.py -- -k test_unknown_phrase # Run just this one test by passing through pytest args.
133+
pants test :: # Run all tests in the repo.
134+
pants test --output=all :: # Run all tests in the repo and view pytest output even for tests that passed (you can set this permanently in pants.toml).
135+
pants test helloworld/translator:tests # Run all the tests in this target.
136+
pants test helloworld/translator/translator_test.py # Run just the tests in this file.
137+
pants test helloworld/translator/translator_test.py -- -k test_unknown_phrase # Run just this one test by passing through pytest args.
136138
```
137139

138140
## Create a PEX binary
139141

140142
```
141-
./pants package helloworld/main.py
143+
pants package helloworld/main.py
142144
```
143145

144146
## Run a binary directly
145147

146148
```
147-
./pants run helloworld/main.py
149+
pants run helloworld/main.py
148150
```
149151

150152
## Open a REPL
151153

152154
```
153-
./pants repl helloworld/greet:lib # The REPL will have all relevant code and dependencies on its sys.path.
154-
./pants repl --shell=ipython helloworld/greet:lib --no-pantsd # To use IPython, you must disable Pantsd for now.
155+
pants repl helloworld/greet:lib # The REPL will have all relevant code and dependencies on its sys.path.
156+
pants repl --shell=ipython helloworld/greet:lib --no-pantsd # To use IPython, you must disable Pantsd for now.
155157
```
156158

157159
## Build a wheel / generate `setup.py`
158160

159161
This will build both a `.whl` bdist and a `.tar.gz` sdist.
160162

161163
```
162-
./pants package helloworld/translator:dist
164+
pants package helloworld/translator:dist
163165
```
164166

165167
## Count lines of code
166168

167169
```
168-
./pants count-loc '**/*'
170+
pants count-loc '**/*'
169171
```
170172
## Create virtualenv for IDE integration
171173

172174
```
173-
./pants export ::
175+
pants export ::
174176
```

helloworld/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ python_sources(
77
)
88

99
# This target allows us to bundle our app into a PEX binary file via
10-
# `./pants package`. We can also run it with `./pants run`. See
10+
# `pants package`. We can also run it with `pants run`. See
1111
# https://www.pantsbuild.org/docs/python-package-goal and
1212
# https://www.pantsbuild.org/docs/python-run-goal.
1313
pex_binary(

0 commit comments

Comments
 (0)