Skip to content

Commit 1ba1247

Browse files
Revert using Python resolves feature (#93)
We decided to not widely publicize resolves in Pants 2.10. Pants's mechanism works great, but using Poetry for lockfile generation is causing several issues: * `[python-repos]` does not work * VCS/local requirements don't work * some transitive deps end up with environment markers that are nonsensical and cause the resolve to fail. There is a workaround, but it's not obvious. This didn't hit example-python, but did hit a user of Pants. We'll switch to resolves once we can use Pex for lockfile generation: pantsbuild/pants#13964
1 parent 5c9912e commit 1ba1247

4 files changed

Lines changed: 29 additions & 32 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
3+
# Licensed under the Apache License, Version 2.0 (see LICENSE).
4+
5+
# See https://www.pantsbuild.org/v2.0/docs/python-third-party-dependencies.
6+
7+
set -euo pipefail
8+
9+
PYTHON_BIN=python3
10+
VIRTUALENV=build-support/.venv
11+
PIP="${VIRTUALENV}/bin/pip"
12+
CONSTRAINTS_FILE=constraints.txt
13+
14+
"${PYTHON_BIN}" -m venv "${VIRTUALENV}"
15+
"${PIP}" install pip --upgrade
16+
"${PIP}" install -r <(./pants dependencies --type=3rdparty ::)
17+
echo "# Generated by build-support/generate_constraints.sh on $(date)" > "${CONSTRAINTS_FILE}"
18+
"${PIP}" freeze --all >> "${CONSTRAINTS_FILE}"

constraints.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Generated by build-support/generate_constraints.sh on Fri Nov 12 13:02:01 MST 2021
2+
ansicolors==1.1.8
3+
pip==21.3.1
4+
setuptools==56.2.0
5+
types-setuptools==57.4.2

lockfile.txt

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

pants.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ repo_id = "3B1D361B-E9F1-49A8-B761-03DCC41FD58E"
2626
root_patterns = ["/"]
2727

2828
[python]
29-
# The default interpreter compatibility for code in this repo. Individual targets can override
29+
# The default interpreter constraints for code in this repo. Individual targets can override
3030
# this with the `interpreter_constraints` field. See
3131
# https://www.pantsbuild.org/docs/python-interpreter-compatibility.
3232
#
33+
# It's usually a good idea to pin this to a particular version, e.g. `==3.9.*`. We only use a range
34+
# so that this example works on many different machines.
35+
#
3336
# If you use Apple Silicon, set to a value like `>=3.9`.
3437
interpreter_constraints = [">=3.7"]
3538

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"}
39+
# Use a constraints file. See https://www.pantsbuild.org/docs/python-third-party-dependencies.
40+
requirement_constraints = "constraints.txt"
4041

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

0 commit comments

Comments
 (0)