magnificent-toothbrush-17254
03/02/2023, 6:30 PMenough-analyst-54434
03/02/2023, 6:33 PM">=3.7,<4"
by default.
+ old pip is slow: Pants 2.16.x allows setting `[python] pip_version = "23.0.1"`which makes many resolves faster
+ Pex can still do 1 more optimization: outlined here: https://github.com/pantsbuild/pex/issues/2044magnificent-toothbrush-17254
03/02/2023, 6:36 PMenough-analyst-54434
03/02/2023, 6:38 PMmagnificent-toothbrush-17254
03/02/2023, 6:38 PMenough-analyst-54434
03/02/2023, 6:39 PMmagnificent-toothbrush-17254
03/02/2023, 6:41 PMenough-analyst-54434
03/02/2023, 6:41 PMpants.toml
as an org?: https://www.pantsbuild.org/docs/reference-python#enable_resolvesmagnificent-toothbrush-17254
03/02/2023, 6:41 PMenough-analyst-54434
03/02/2023, 6:42 PMpants.toml
?magnificent-toothbrush-17254
03/02/2023, 6:43 PM[GLOBAL]
pants_version = "2.15.0"
backend_packages = [
# BUILD files
"pants.backend.build_files.fmt.black",
# Docker images
"pants.backend.docker",
"pants.backend.docker.lint.hadolint",
# Python
"pants.backend.python",
"pants.backend.experimental.python",
# Note that we want Autoflake to run before Black and isort,
# so it must appear first.
"pants.backend.python.lint.autoflake",
"pants.backend.python.lint.black",
"pants.backend.python.lint.isort",
"pants.backend.python.lint.docformatter",
"pants.backend.python.lint.flake8",
"pants.backend.python.typecheck.mypy",
"pants.backend.python.mixed_interpreter_constraints",
]
[source]
root_patterns = ['/src/*', '/bin/*', '3rdparty/*']
[python]
tailor_pex_binary_targets = false
enable_resolves = true
interpreter_constraints = ["==3.9.*"]
[python.resolves]
python-default = "resolves/python-default.lock"
py2-py3 = "resolves/py2-py3.lock"
py3 = "resolves/py3.lock"
[python.resolves_to_interpreter_constraints]
python-default = [">=3.7,<3.10"]
py2-py3 = [
">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,<3.10",
]
py3 = [">=3.11"]
[pytest]
lockfile = "resolves/pytest.lock"
version = "pytest==4.6.11"
xdist_enabled = false
extra_requirements = [
"pytest-cov>=2.12,!=2.12.1,<3.1",
"pytest-xdist>=1"
]
[mypy]
lockfile = "resolves/mypy.lock"
extra_requirements = ["typed_ast"]
[setuptools]
lockfile = "resolves/setuptools.lock"
version = "setuptools==44.1.1"
[python-bootstrap]
search_path = [
# This will use all interpreters in `$(pyenv root)/versions`.
"<PYENV>",
"<PATH>",
# Brew usually installs Python here.
"/usr/local/bin",
]
[anonymous-telemetry]
enabled = false
enough-analyst-54434
03/02/2023, 6:46 PM-ldebug
thrown in that will show the Pex command line used which will allow trying it out with Pex latest + --pip-version 23.0.1
to see if that would help.magnificent-toothbrush-17254
03/02/2023, 7:00 PMenough-analyst-54434
03/02/2023, 7:09 PMmagnificent-toothbrush-17254
03/02/2023, 7:09 PMenough-analyst-54434
03/02/2023, 7:09 PMmagnificent-toothbrush-17254
03/02/2023, 7:21 PMenough-analyst-54434
03/02/2023, 7:22 PMmagnificent-toothbrush-17254
03/02/2023, 10:00 PMpip install -r requirements.txt
will work fine, but for something like this (just an example)
MarkupSafe==1.1.1; python_version < '3.9'
MarkupSafe==2.1.1; python_version >= '3.8'
it will fail when trying to generate the lockfilepython_requirement
, no matter what it'll error out saying there is a conflict:
The conflict is caused by:
The user requested MarkupSafe==1.1.1
The user requested MarkupSafe==2.1.1
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
enough-analyst-54434
03/02/2023, 10:05 PMpython_version
constraints look like a typo, they are not disjoint. They should be disjoint.magnificent-toothbrush-17254
03/02/2023, 10:08 PMenough-analyst-54434
03/02/2023, 10:08 PMmagnificent-toothbrush-17254
03/02/2023, 10:09 PMMarkupSafe==2.1.1; python_version >= '3.7'
MarkupSafe==1.1.1; python_version == '2.7'
will fail, which it still does. those have no overlapenough-analyst-54434
03/02/2023, 10:12 PMmagnificent-toothbrush-17254
03/02/2023, 10:14 PMYou can specify multiple requirements for the same project in order to use environment markers, such asor just that I didn't understand them haha either are possible.["foo>=1.2,<1.3 ; python_version>'3.6'", "foo==0.9 ; python_version<'3'"]
enough-analyst-54434
03/02/2023, 10:17 PM--style universal
lock like Pants uses. Pex will allow you to create a bifurcated lock file for --style strict
or --style sources
but Pants doesn't use either of those styles. In Pants you must instead split the resolve in two and get 2 lock files.pex3 lock create --style universal --interpreter-constraint ">=2.7,<3.10,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*" --resolver-version pip-2020-resolver MarkupSafe==1.1.1
magnificent-toothbrush-17254
03/02/2023, 10:22 PMenough-analyst-54434
03/02/2023, 10:22 PM