Hi guys, I am trying to generate a pants lockfile ...
# general
a
Hi guys, I am trying to generate a pants lockfile for one of my python projects, however it is stuck in the generation process forever (for more than a day!). These are my dependencies:
Copy code
python = "^3.9, <3.10"
pandas = {extras = ["aws", "performance"], version = "^2.0.1"}
awswrangler = {extras = ["redshift"], version = "^3.1.1"}
typer = {extras = ["all"], version = "0.7.0"}
webdriver-manager = "3.8.5"
selenium-wire = "5.1.0"
halo = "0.0.31"
inquirer = "3.1.3"
defusedxml = "0.7.1"
geoip2 = "^4.6.0"
sqlparse = "^0.4.3"
mypy-boto3-redshift = "^1.26.79"
isort = "^5.12.0"
mypy-boto3-cur = "1.26.0.post1"
mypy-boto3-sts = "1.26.57"
mypy-boto3-s3 = "1.26.97.post2"
boto3 = "1.26.76"
prefect = "^2.8.3"
s3fs = "^2023.1.0"
cryptography = "38.0.4"
However, when I tried to use Poetry to generate the lockfile, it was generated in an instant. Any help on debugging this is thoroughly appreciated
h
Pants version?
More information would be helpful
You may want to upgrade to a newer Pip, which can be done via this option in Pants 2.16: https://www.pantsbuild.org/v2.16/docs/reference-python#pip_version
But also, what are your interpreter constraints?
a
Hi Benjy, thanks for replying to my query. After reading a few other similar issues in the slack, I upgraded my pants version to
"2.16.0rc3"
and my python options to:
Copy code
[python]
interpreter_constraints = [">=3.9,<3.10"]
pip_version = 22.3
So after the following changes I managed to generate the lockfile within 2 mins locally
However, now I am facing the problem of the lockfile taking forever to generate on my Jenkins CI. I am using the exact same configurations and commands as I did for local testing. Both my pants and python versions are same between local and Jenkins CI environment. Any idea why I am facing this issue?
Is there any way I can print out what pants is doing behind the scenes when I run the
pants generate-lockfiles
command? Or any debug logs which I can refer to, to see where it's getting stuck on?
r
Why would you like to generate lockfile in CI though? You can look at some of the troubleshooting options here
Copy code
pants --print-stacktrace -ldebug <rest of your command>
https://www.pantsbuild.org/docs/troubleshooting
a
Thanks for sharing the command to print the debug stack, really appreciated! I am using Pants in a python monorepo and I have individual projects in there which are using different versions of the same dependencies and for that I thought a lockfile for each project would be quite beneficial. And I am generating these lockfiles during the build stage of the Jenkins CI. Am I missing something on how lockfiles should normally be used?
r
Yes lockfiles should be generated only once outside of CI. Generating it during CI will add extra time in your CI and it will also make it difficult to debug if something fails because of broken dependencies. Once you have generated it locally or outside of CI elsewhere and pushed to some git repo, the CI should just use it to install any dependencies.
h
It would be good for you to figure out why this is taking a long time in CI because it means you may have a misconfiguration where CI isn't picking up your Pants config changes somehow.
But - @refined-addition-53644 is correct, you generate a lockfile once (per every time a requirement changes) and check it in to the repo
so it is a human action, not a CI one
technically you are supposed to manually verify the lockfile, although in practice that is hard to do for large ones