I am trying to generate lockfiles using pants `2.1...
# general
r
I am trying to generate lockfiles using pants
2.10.0rc5
but keep getting error. Please see the ๐Ÿงต for details
โœ… 2
Copy code
./pants generate-lockfiles
20:37:59.84 [INFO] Initializing scheduler...
20:37:59.97 [INFO] Scheduler initialized.
20:38:08.27 [INFO] Completed: Generate lockfile for python-default
20:38:08.28 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Generate lockfile for python-default' failed with exit code 1.
stdout:
The currently activated Python version 3.7.9 is not supported by the project (<=3.10.0,>=3.9).
Trying to find and use a compatible version.
Using python3 (3.9.10)
Creating virtualenv pants-lockfile-generation-NUz-zxU6-py3.9 in /Users/developer/Library/Caches/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...

  SolverProblemError

  Because no versions of pantsbuild.pants match >2.10.0rc0,<2.10.0rc1 || >2.10.0rc1,<2.10.0rc2 || >2.10.0rc2,<2.10.0rc3 || >2.10.0rc3,<2.10.0rc4 || >2.10.0rc4,<2.10.0rc5 || >2.10.0rc5,<2.11
   and pantsbuild.pants (2.10.0rc0) depends on packaging (21.3), pantsbuild.pants (>=2.10.0rc0,<2.10.0rc1 || >2.10.0rc1,<2.10.0rc2 || >2.10.0rc2,<2.10.0rc3 || >2.10.0rc3,<2.10.0rc4 || >2.10.0rc4,<2.10.0rc5 || >2.10.0rc5,<2.11) requires packaging (21.3).
  And because pantsbuild.pants (2.10.0rc1) depends on packaging (21.3)
   and pantsbuild.pants (2.10.0rc2) depends on packaging (21.3), pantsbuild.pants (>=2.10.0rc0,<2.10.0rc3 || >2.10.0rc3,<2.10.0rc4 || >2.10.0rc4,<2.10.0rc5 || >2.10.0rc5,<2.11) requires packaging (21.3).
  And because pantsbuild.pants (2.10.0rc3) depends on packaging (21.3)
   and pantsbuild.pants (2.10.0rc4) depends on packaging (21.3), pantsbuild.pants (>=2.10.0rc0,<2.10.0rc5 || >2.10.0rc5,<2.11) requires packaging (21.3).
  And because pantsbuild.pants (2.10.0rc5) depends on packaging (21.3)
   and poetry (1.1.8) depends on packaging (>=20.4,<21.0), poetry (1.1.8) is incompatible with pantsbuild.pants (>=2.10.0rc0,<2.11).
  So, because pants-lockfile-generation depends on both pantsbuild.pants (<2.11,>=2.10.0rc0) and poetry (==1.1.8), version solving failed.

  at ~/.cache/pants/named_caches/pex_root/venvs/s/5d728165/venv/lib/python3.7/site-packages/poetry/puzzle/solver.py:241 in _solve
      237โ”‚             packages = result.packages
      238โ”‚         except OverrideNeeded as e:
      239โ”‚             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240โ”‚         except SolveFailure as e:
    โ†’ 241โ”‚             raise SolverProblemError(e)
      242โ”‚
      243โ”‚         results = dict(
      244โ”‚             depth_first_search(
      245โ”‚                 PackageNode(self._package, packages), aggregate_package_nodes

stderr:



Use `--no-process-cleanup` to preserve process chroots for inspection.
This is my
pants.toml
Copy code
[GLOBAL]
pants_version = "2.10.0rc5"
pythonpath = ["%(buildroot)s/pants-plugins"]
backend_packages.add = [
  "pants.backend.python",
  "pants.backend.python.lint.black",
  "pants.backend.python.lint.docformatter",
  "pants.backend.docker",
  "pants.backend.python.lint.flake8",
  "pants.backend.docker.lint.hadolint",
  "pants.backend.python.lint.pylint",
  "pants.backend.python.typecheck.mypy",
  "pants.backend.python.lint.isort",
  "pants.backend.plugin_development",
  "internal_plugins",
]
use_deprecated_python_macros = false
pants_ignore.add = ["cdk.out/", "infrastructure/"]

[source]
root_patterns = [
  "/src/pyfleet-etl",
  "/pants-plugins",
]

[anonymous-telemetry]
enabled = false

[setup-py-generation]
generate_setup_default = true

[python-infer]
inits = true

[python]
interpreter_constraints = ["CPython>=3.9,<=3.10.0"]
enable_resolves = true
resolves = { python-default = "./3rdparty/python_lockfile.txt" }
h
The error is telling you what the issue is: you're depending on Poetry 1.1.8 somewhere, which requires packaging<21.0 , but the version of Pants you're using depends on packaging==21.3
Where is that poetry dependency happening?
What does your requirements.txt or whatever you're generating the lockfile for look like?
r
where does it expect the
requirements.txt
to live? It's right now at
3rdparty/requirements.txt
I also had another
requirements.txt
with
poetry==1.1.8
as dependency in the root which was the one causing this error. I have removed it and it seems to be working.
Seems to have found the
3rdparty/requirements.txt
as I can see all the packages added as metadata to the generated lockfile
h
yep, but it also finds that other requirements.txt apparently
And treats them both as part of the same resolve
what is in that other one?
Usually you don't want things like poetry as code dependencies, so it may be wise to tell Pants to ignore that file (assuming it doesn't contain requirements that your code imports)
๐Ÿ™Œ 1
(ignore it using
pants_ignore
in the
[GLOBAL]
section of pants.toml, that is)
r
in the other one requirements, it was just
poetry==1.1.8
. Not sure why I put it there.
h
OK, cool
So sounds like this is sorted out?
r
Yes. False alarm, sorry!
h
No problem! Glad to help