Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdm lock hangs with no further debug output #1609

Closed
1 task done
apollo13 opened this issue Jan 10, 2023 · 15 comments · Fixed by j178/pdm#1
Closed
1 task done

pdm lock hangs with no further debug output #1609

apollo13 opened this issue Jan 10, 2023 · 15 comments · Fixed by j178/pdm#1
Labels
🐛 bug Something isn't working

Comments

@apollo13
Copy link

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

I am running pdm lock -v on this pyproject.toml (https://gitlab.com/rocketduck/csi-plugin-nfs/-/blob/locking-issues/pyproject.toml):

[project]
# PEP 621 project metadata
# See https://www.python.org/dev/peps/pep-0621/
authors = [
    {name = "Florian Apolloner", email = "[email protected]"},
]
requires-python = ">=3.11,<4.0"
dependencies = [
    "grpcio>=1.51.1",
    "grpcio-reflection>=1.51.1",
    "grpc-interceptor>=0.15.0",
]
name = "csi-plugin-nfs"
version = "0.5.0"
description = ""

[project.urls]

[project.scripts]
csi_plugin_nfs = "csi_plugin_nfs.cli:serve"

[tool.pdm.scripts]
server = { call = "csi_plugin_nfs.cli:serve" }

[tool.pdm.dev-dependencies]
dev = [
    "grpcio-tools>=1.51.1",
    "black>=22.12.0",
    "isort>=5.11.4",
    "bump2version>=1.0.1",
    "flake8>=6.0.0",
    "flake8-bugbear>=22.12.6",
    "mypy>=0.991",
    "lxml>=4.9.2",
]

[tool.black]
line-length = 88
target-version = ["py38"]
include = '\.pyi?$'
exclude = 'csi_pb2.*\.py'

[tool.isort]
profile = "black"
skip_glob = "**/csi_pb2*.py"

[build-system]
requires = ["pdm-pep517"]
build-backend = "pdm.pep517.api"

Actual behavior

Locking hangs with the following output:

pdm.termui: ======== Start resolving requirements ========
pdm.termui:   grpcio-tools>=1.51.1
pdm.termui:   black>=22.12.0
pdm.termui:   isort>=5.11.4
pdm.termui:   bump2version>=1.0.1
pdm.termui:   flake8>=6.0.0
pdm.termui:   flake8-bugbear>=22.12.6
pdm.termui:   mypy>=0.991
pdm.termui:   lxml>=4.9.2
pdm.termui:   grpcio>=1.51.1
pdm.termui:   grpcio-reflection>=1.51.1
pdm.termui:   grpc-interceptor>=0.15.0
pdm.termui:   python>=3.11,<4.0
pdm.termui:   Adding requirement grpcio-tools>=1.51.1
pdm.termui:   Adding requirement black>=22.12.0
pdm.termui:   Adding requirement isort>=5.11.4
pdm.termui:   Adding requirement bump2version>=1.0.1
pdm.termui:   Adding requirement flake8>=6.0.0
pdm.termui:   Adding requirement flake8-bugbear>=22.12.6
pdm.termui:   Adding requirement mypy>=0.991
pdm.termui:   Adding requirement lxml>=4.9.2
pdm.termui:   Adding requirement grpcio>=1.51.1
pdm.termui:   Adding requirement grpcio-reflection>=1.51.1
pdm.termui:   Adding requirement grpc-interceptor>=0.15.0
pdm.termui:   Adding requirement python>=3.11,<4.0
pdm.termui: ======== Starting round 0 ========
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui:   Adding requirement click>=8.0.0(from black 22.12.0)
pdm.termui:   Adding requirement mypy-extensions>=0.4.3(from black 22.12.0)
pdm.termui:   Adding requirement pathspec>=0.9.0(from black 22.12.0)
pdm.termui:   Adding requirement platformdirs>=2(from black 22.12.0)
pdm.termui: Pinning: black 22.12.0
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: Pinning: bump2version 1.0.1
pdm.termui: ======== Ending round 2 ========
pdm.termui: ======== Starting round 3 ========
pdm.termui:   Adding requirement mccabe<0.8.0,>=0.7.0(from flake8 6.0.0)
pdm.termui:   Adding requirement pycodestyle<2.11.0,>=2.10.0(from flake8 6.0.0)
pdm.termui:   Adding requirement pyflakes<3.1.0,>=3.0.0(from flake8 6.0.0)
pdm.termui: Pinning: flake8 6.0.0
pdm.termui: ======== Ending round 3 ========
pdm.termui: ======== Starting round 4 ========
pdm.termui:   Adding requirement flake8>=3.0.0(from flake8-bugbear 22.12.6)
pdm.termui:   Adding requirement attrs>=19.2.0(from flake8-bugbear 22.12.6)
pdm.termui: Pinning: flake8-bugbear 22.12.6
pdm.termui: ======== Ending round 4 ========
pdm.termui: ======== Starting round 5 ========
pdm.termui:   Adding requirement grpcio<2.0.0,>=1.32.0(from grpc-interceptor 0.15.0)
pdm.termui: Pinning: grpc-interceptor 0.15.0
pdm.termui: ======== Ending round 5 ========
pdm.termui: ======== Starting round 6 ========
pdm.termui: Pinning: grpcio 1.51.1
pdm.termui: ======== Ending round 6 ========
pdm.termui: ======== Starting round 7 ========
pdm.termui:   Adding requirement protobuf>=4.21.6(from grpcio-reflection 1.51.1)
pdm.termui:   Adding requirement grpcio>=1.51.1(from grpcio-reflection 1.51.1)
pdm.termui: Pinning: grpcio-reflection 1.51.1
pdm.termui: ======== Ending round 7 ========
pdm.termui: ======== Starting round 8 ========
pdm.termui:   Adding requirement protobuf<5.0dev,>=4.21.6(from grpcio-tools 1.51.1)
pdm.termui:   Adding requirement grpcio>=1.51.1(from grpcio-tools 1.51.1)
pdm.termui:   Adding requirement setuptools(from grpcio-tools 1.51.1)
pdm.termui: Pinning: grpcio-tools 1.51.1
pdm.termui: ======== Ending round 8 ========
pdm.termui: ======== Starting round 9 ========
pdm.termui: Pinning: isort 5.11.4
pdm.termui: ======== Ending round 9 ========
pdm.termui: ======== Starting round 10 ========
pdm.termui: Pinning: lxml 4.9.2
pdm.termui: ======== Ending round 10 ========
pdm.termui: ======== Starting round 11 ========
pdm.termui:   Adding requirement typing-extensions>=3.10(from mypy 0.991)
pdm.termui:   Adding requirement mypy-extensions>=0.4.3(from mypy 0.991)
pdm.termui: Pinning: mypy 0.991
pdm.termui: ======== Ending round 11 ========
pdm.termui: ======== Starting round 12 ========
pdm.termui: Pinning: protobuf 4.21.12
pdm.termui: ======== Ending round 12 ========
pdm.termui: ======== Starting round 13 ========
pdm.termui: Pinning: mccabe 0.7.0
pdm.termui: ======== Ending round 13 ========
pdm.termui: ======== Starting round 14 ========
pdm.termui: Pinning: mypy-extensions 0.4.3
pdm.termui: ======== Ending round 14 ========
pdm.termui: ======== Starting round 15 ========
pdm.termui: Pinning: pycodestyle 2.10.0
pdm.termui: ======== Ending round 15 ========
pdm.termui: ======== Starting round 16 ========
pdm.termui: Pinning: pyflakes 3.0.1
pdm.termui: ======== Ending round 16 ========
pdm.termui: ======== Starting round 17 ========
pdm.termui: Pinning: attrs 22.2.0
pdm.termui: ======== Ending round 17 ========
pdm.termui: ======== Starting round 18 ========
pdm.termui:   Adding requirement colorama; platform_system == "Windows"(from click 8.1.3)
pdm.termui: Pinning: click 8.1.3
pdm.termui: ======== Ending round 18 ========
pdm.termui: ======== Starting round 19 ========
pdm.termui: Pinning: pathspec 0.10.3
pdm.termui: ======== Ending round 19 ========
pdm.termui: ======== Starting round 20 ========
pdm.termui: Pinning: platformdirs 2.6.2
pdm.termui: ======== Ending round 20 ========
pdm.termui: ======== Starting round 21 ========
pdm.termui: Pinning: typing-extensions 4.4.0
pdm.termui: ======== Ending round 21 ========
pdm.termui: ======== Starting round 22 ========
pdm.termui: Pinning: setuptools 65.6.3
pdm.termui: ======== Ending round 22 ========
pdm.termui: ======== Starting round 23 ========
pdm.termui: Pinning: colorama 0.4.6
pdm.termui: ======== Ending round 23 ========
pdm.termui: ======== Starting round 24 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:              python None
pdm.termui:               black 22.12.0
pdm.termui:        bump2version 1.0.1
pdm.termui:              flake8 6.0.0
pdm.termui:      flake8-bugbear 22.12.6
pdm.termui:    grpc-interceptor 0.15.0
pdm.termui:              grpcio 1.51.1
pdm.termui:   grpcio-reflection 1.51.1
pdm.termui:        grpcio-tools 1.51.1
pdm.termui:               isort 5.11.4
pdm.termui:                lxml 4.9.2
pdm.termui:                mypy 0.991
pdm.termui:            protobuf 4.21.12
pdm.termui:              mccabe 0.7.0
pdm.termui:     mypy-extensions 0.4.3
pdm.termui:         pycodestyle 2.10.0
pdm.termui:            pyflakes 3.0.1
pdm.termui:               attrs 22.2.0
pdm.termui:               click 8.1.3
pdm.termui:            pathspec 0.10.3
pdm.termui:        platformdirs 2.6.2
pdm.termui:   typing-extensions 4.4.0
pdm.termui:          setuptools 65.6.3
pdm.termui:            colorama 0.4.6

Running strace on the pdm process yields:

strace -p 22876                                                                                                                                                                                                                                    strace: Process 22876 attached
futex(0x7fbf14000b70, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY

Ending the process with CTRL-C:

^CTraceback (most recent call last):
  File "/home/florian/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/florian/.local/pipx/venvs/pdm/lib64/python3.11/site-packages/pdm/core.py", line 259, in main
    return Core().main(args)
           ^^^^^^^^^^^^^^^^^
  File "/home/florian/.local/pipx/venvs/pdm/lib64/python3.11/site-packages/pdm/core.py", line 186, in main
    f(project, options)
  File "/home/florian/.local/pipx/venvs/pdm/lib64/python3.11/site-packages/pdm/cli/commands/lock.py", line 53, in handle
    actions.do_lock(
  File "/home/florian/.local/pipx/venvs/pdm/lib64/python3.11/site-packages/pdm/cli/actions.py", line 100, in do_lock
    fetch_hashes(provider.repository, mapping)
  File "/home/florian/.local/pipx/venvs/pdm/lib64/python3.11/site-packages/pdm/cli/utils.py", line 698, in fetch_hashes
    with ThreadPoolExecutor() as executor:
  File "/usr/lib64/python3.11/concurrent/futures/_base.py", line 647, in __exit__
    self.shutdown(wait=True)
  File "/usr/lib64/python3.11/concurrent/futures/thread.py", line 235, in shutdown
    t.join()
  File "/usr/lib64/python3.11/threading.py", line 1112, in join
    self._wait_for_tstate_lock()
  File "/usr/lib64/python3.11/threading.py", line 1132, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/usr/lib64/python3.11/threading.py'>
Traceback (most recent call last):
  File "/usr/lib64/python3.11/threading.py", line 1561, in _shutdown
    atexit_call()
  File "/usr/lib64/python3.11/concurrent/futures/thread.py", line 31, in _python_exit
    t.join()
  File "/usr/lib64/python3.11/threading.py", line 1112, in join
    self._wait_for_tstate_lock()
  File "/usr/lib64/python3.11/threading.py", line 1132, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt: 

so it seems to be waiting for something?

Expected behavior

Locking should finish

Environment Information

PDM version:
  2.3.4
Python Interpreter:
  /home/florian/sources/csi-plugin-nfs/.venv/bin/python (3.11)
Project Root:
  /home/florian/sources/csi-plugin-nfs
Project Packages:
  None
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.1",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.0.16-300.fc37.x86_64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Sat Dec 31 16:47:53 UTC 2022",
  "python_full_version": "3.11.1",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "linux"
}
@apollo13 apollo13 added the 🐛 bug Something isn't working label Jan 10, 2023
@apollo13
Copy link
Author

It looks as if it might be fetching hashes still, if yes it would be great if there were some output so one knows it is still doing something :)

@apollo13
Copy link
Author

apollo13 commented Jan 10, 2023

It is indeed still fetching hashes. That said fetching wheels like:

<Link https://files.pythonhosted.org/packages/e3/84/188ddeaebfc8b5bbdcc3c7f05c09b61758540b2df84aad0146263d66960a/mypy-0.991-cp38-cp38-macosx_10_9_x86_64.whl (from https://pypi.org/simple/mypy/)>
<Link https://files.pythonhosted.org/packages/af/9a/ee3b76f36e90ecb5e44dd2827bf5992d02c127192366a4c7864cfeab95b6/mypy-0.991-cp38-cp38-macosx_11_0_arm64.whl (from https://pypi.org/simple/mypy/)>
<Link https://files.pythonhosted.org/packages/49/83/34d682a10604845d77a0e7dbde1d0e70f3784d0f67b0df11d2eaf7bb8360/mypy-0.991-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from https://pypi.org/simple/mypy/)>
<Link https://files.pythonhosted.org/packages/5d/c8/fc9b7cd600330e8c9dbd52b499a76eeaf4b48969a605fb50415a9d361d5b/mypy-0.991-cp38-cp38-musllinux_1_1_x86_64.whl (from https://pypi.org/simple/mypy/)>
<Link https://files.pythonhosted.org/packages/f7/3a/19c01d59d24f1f36fabdeb61a286b4fc5e0456bf6211f5159ad5ebb5f735/mypy-0.991-cp38-cp38-win_amd64.whl (from https://pypi.org/simple/mypy/)>
<Link https://files.pythonhosted.org/packages/bc/b2/6e71e47b259992dcd99d257ce452c0de3f711be713d048fe8f0fda9a9996/mypy-0.991-cp39-cp39-macosx_10_9_universal2.whl (from https://pypi.org/simple/mypy/)>

Which brings me back to #1128 -- I think it would be really helpful (speedwise) to parse wheel tags and ignore wheels that do not match the require target pythons, I am downloading hundreds of MB for python versions that will never be used

@apollo13
Copy link
Author

Weird, PDM progresses really slowly through those files which large (?) waits in between. Is there rate limiting somewhere in PDM?

@apollo13
Copy link
Author

Ok downloads are stalling here, this is something I'll have to fix for myself. That said it would be nice of pdm could log what it is doing. I will leave this open for you to decide whether logging should get improved.

@apollo13
Copy link
Author

@frostming thank you for the added logline. What is bugging me now is that my projects still downloads gigabytes of data and I am not sure why. It seems to download all wheel files for the resolved version even though the required python version would not match it. I know you said that having all hashes in #1128 (reply in thread) would be okay. I'd like to ask you if it were possible to reconsider this stance -- as it stands now out of the 2 gigabytes of data downloaded, only a fifth of it or so is actually useful for the project, the rest is for older versions. Even though this occurs only on lock when the cache doesn't exist, this is really wasteful if you ask me. I know that Fastly provides the CDN to PyPI for free basically but I think it would be a good idea to not waste resources we do not need.

@frostming
Copy link
Collaborator

What is bugging me now is that my projects still downloads gigabytes of data and I am not sure why. It seems to download all wheel files for the resolved version even though the required python version would not match it.

Your observation is different from what is expected because fetching hashes doesn't even need to download any file. Can you find out what files it is downloading and the size of these files?

@frostming
Copy link
Collaborator

frostming commented Jan 10, 2023

Yes, it is wasteful, but not too much. Packages often release wheels for Python versions they do support, which in most cases are 2-3 minor versions. Even if your project only supports one minor version, that is a 2/3 waste. Most projects will specify a wider requires-python range so all wheels are stored in the lock file anyway.

@apollo13
Copy link
Author

Hi @frostming,

I have now used a minimal pyproject file:

[project]
authors = [
    {name = "Florian Apolloner", email = "[email protected]"},
]
requires-python = ">=3.11,<4.0"
dependencies = [
    #"grpcio>=1.51.1",
    #"grpcio-reflection>=1.51.1",
    #"grpc-interceptor>=0.15.0",
    "black>=22.12.0",
]
name = "csi-plugin-nfs"
version = "0.5.0"
description = ""

and ran pdm from the master branch. It does download files according to your log lines:

STATUS: Resolving dependencies
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   black>=22.12.0
pdm.termui:   python>=3.11,<4.0
pdm.termui:   Adding requirement black>=22.12.0
unearth.collector: Collecting links from https://pypi.org/simple/black/
unearth.auth: Found index url https://pypi.org/simple
unearth.collector: Fetching HTML page https://pypi.org/simple/black/
unearth.evaluator: Skip link <Link https://files.pythonhosted.org/packages/3d/ad/1cf514e7f9ee4c3d8df7c839d7977f7605ad76557f3fca741ec67f76dba6/black-21.11b0-py3-none-any.whl (from https://pypi.org/simple/black/)>: Yanked due to Broken regex dependency. Use 21.11b1 instead.
unearth.evaluator: Skip link <Link https://files.pythonhosted.org/packages/2f/db/03e8cef689ab0ff857576ee2ee288d1ff2110ef7f3a77cac62e61f18acaf/black-21.11b0.tar.gz (from https://pypi.org/simple/black/)>: Yanked due to Broken regex dependency. Use 21.11b1 instead.
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/black/>
pdm.termui:   Adding requirement python>=3.11,<4.0
pdm.termui: ======== Starting round 0 ========
STATUS: Resolving: new pin python>=3.11,<4.0
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/e9/e0/6aa02d14785c4039b38bfed6f9ee28a952b2d101c64fc97b15811fa8bd04/black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from None)> (1.5 MB)
pdm.termui:   Adding requirement click>=8.0.0(from black 22.12.0)
unearth.collector: Collecting links from https://pypi.org/simple/click/
unearth.auth: Found index url https://pypi.org/simple
unearth.collector: Fetching HTML page https://pypi.org/simple/click/
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui:   Adding requirement mypy-extensions>=0.4.3(from black 22.12.0)
unearth.collector: Collecting links from https://pypi.org/simple/mypy-extensions/
unearth.auth: Found index url https://pypi.org/simple
unearth.collector: Fetching HTML page https://pypi.org/simple/mypy-extensions/
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/mypy-extensions/>
pdm.termui:   Adding requirement pathspec>=0.9.0(from black 22.12.0)
unearth.collector: Collecting links from https://pypi.org/simple/pathspec/
unearth.auth: Found index url https://pypi.org/simple
unearth.collector: Fetching HTML page https://pypi.org/simple/pathspec/
unearth.evaluator: Skip link <Link https://files.pythonhosted.org/packages/3c/52/8559662da5afa79eb439c24d5e4e9752504665c123efbf0c825f8c996ee5/pathspec-0.10.0-py3-none-any.whl (from https://pypi.org/simple/pathspec/)>: Yanked due to v0.10.0 broke a common pattern which is leading to bug reports in dependent libraries (e.g., black). v0.10.1 fixes the issue.
unearth.evaluator: Skip link <Link https://files.pythonhosted.org/packages/03/45/41884de3da7c1012c729fc6fdad25d6b7906c69f5aaf4b23238ac8acfced/pathspec-0.10.0.tar.gz (from https://pypi.org/simple/pathspec/)>: Yanked due to v0.10.0 broke a common pattern which is leading to bug reports in dependent libraries (e.g., black). v0.10.1 fixes the issue.
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/pathspec/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/pathspec/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/pathspec/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/pathspec/>
pdm.termui:   Adding requirement platformdirs>=2(from black 22.12.0)
unearth.collector: Collecting links from https://pypi.org/simple/platformdirs/
unearth.auth: Found index url https://pypi.org/simple
unearth.collector: Fetching HTML page https://pypi.org/simple/platformdirs/
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: 	  ... [20 more candidate(s)]
STATUS: Resolving: new pin black 22.12.0
pdm.termui: Pinning: black 22.12.0
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl (from None)> (96 kB)
pdm.termui:   Adding requirement colorama; platform_system == "Windows"(from click 8.1.3)
unearth.collector: Collecting links from https://pypi.org/simple/colorama/
unearth.auth: Found index url https://pypi.org/simple
unearth.collector: Fetching HTML page https://pypi.org/simple/colorama/
unearth.evaluator: Skip link <Link https://files.pythonhosted.org/packages/31/cb/88c908c1be067fb6bacd3d7488ccab1a212533767b951933aac3d22648e2/colorama-0.4.2-py2.py3-none-any.whl (from https://pypi.org/simple/colorama/)>: Yanked due to Bad build, missing files, will not install
unearth.evaluator: Skip link <Link https://files.pythonhosted.org/packages/cb/fe/bfc4d807aa43a183ab387340f524a0bb086624f2c5935bd08e647b54b269/colorama-0.4.2.tar.gz (from https://pypi.org/simple/colorama/)>: Yanked due to Bad build, missing files, will not install
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: 	  ... [76 more candidate(s)]
STATUS: Resolving: new pin click 8.1.3
pdm.termui: Pinning: click 8.1.3
pdm.termui: ======== Ending round 2 ========
pdm.termui: ======== Starting round 3 ========
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/5c/eb/975c7c080f3223a5cdaff09612f3a5221e4ba534f7039db34c35d95fa6a5/mypy_extensions-0.4.3-py2.py3-none-any.whl (from None)> (4.5 kB)
STATUS: Resolving: new pin mypy-extensions 0.4.3
pdm.termui: Pinning: mypy-extensions 0.4.3
pdm.termui: ======== Ending round 3 ========
pdm.termui: ======== Starting round 4 ========
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/3c/29/c07c3a976dbe37c56e381e058c11e8738cb3a0416fc842a310461f8bb695/pathspec-0.10.3-py3-none-any.whl (from None)> (29 kB)
STATUS: Resolving: new pin pathspec 0.10.3
pdm.termui: Pinning: pathspec 0.10.3
pdm.termui: ======== Ending round 4 ========
pdm.termui: ======== Starting round 5 ========
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/c1/c7/9be9d651b93efce682b45142a6267034fc4215972780748618c02e236361/platformdirs-2.6.2-py3-none-any.whl (from None)> (14 kB)
STATUS: Resolving: new pin platformdirs 2.6.2
pdm.termui: Pinning: platformdirs 2.6.2
pdm.termui: ======== Ending round 5 ========
pdm.termui: ======== Starting round 6 ========
unearth.preparer: Downloading <Link https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl (from None)> (25 kB)
STATUS: Resolving: new pin colorama 0.4.6
pdm.termui: Pinning: colorama 0.4.6
pdm.termui: ======== Ending round 6 ========
pdm.termui: ======== Starting round 7 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:            python None
pdm.termui:             black 22.12.0
pdm.termui:             click 8.1.3
pdm.termui:   mypy-extensions 0.4.3
pdm.termui:          pathspec 0.10.3
pdm.termui:      platformdirs 2.6.2
pdm.termui:          colorama 0.4.6
STATUS: Fetching hashes for resolved packages...
pdm.termui: Fetching hashes for [email protected]
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/black/>
pdm.termui: Downloading link https://files.pythonhosted.org/packages/e9/e0/6aa02d14785c4039b38bfed6f9ee28a952b2d101c64fc97b15811fa8bd04/black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl for calculating hash
pdm.termui: Fetching hashes for [email protected]
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/click/>
pdm.termui: Downloading link https://files.pythonhosted.org/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl for calculating hash
pdm.termui: Fetching hashes for [email protected]
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/mypy-extensions/>
pdm.termui: Downloading link https://files.pythonhosted.org/packages/5c/eb/975c7c080f3223a5cdaff09612f3a5221e4ba534f7039db34c35d95fa6a5/mypy_extensions-0.4.3-py2.py3-none-any.whl for calculating hash
pdm.termui: Fetching hashes for [email protected]
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/pathspec/>
pdm.termui: Fetching hashes for [email protected]
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/platformdirs/>
pdm.termui: Fetching hashes for [email protected]
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/colorama/>
pdm.termui: Downloading link https://files.pythonhosted.org/packages/3c/29/c07c3a976dbe37c56e381e058c11e8738cb3a0416fc842a310461f8bb695/pathspec-0.10.3-py3-none-any.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/c1/c7/9be9d651b93efce682b45142a6267034fc4215972780748618c02e236361/platformdirs-2.6.2-py3-none-any.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/59/87/84326af34517fca8c58418d148f2403df25303e02736832403587318e9e8/click-8.1.3.tar.gz for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/63/60/0582ce2eaced55f65a4406fc97beba256de4b7a95a0034c6576458c6519f/mypy_extensions-0.4.3.tar.gz for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/32/1a/6baf904503c3e943cae9605c9c88a43b964dea5b59785cf956091b341b08/pathspec-0.10.3.tar.gz for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/cf/4d/198b7e6c6c2b152f4f9f4cdf975d3590e33e63f1920f2d89af7f0390e6db/platformdirs-2.6.2.tar.gz for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/0c/51/1f7f93c0555eaf4cbb628e26ba026e3256174a45bd9397ff1ea7cf96bad5/black-22.12.0-py3-none-any.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/79/d9/60852a6fc2f85374db20a9767dacfe50c2172eb8388f46018c8daf836995/black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/71/57/975782465cc6b514f2c972421e29b933dfbb51d4a95948a4e0e94f36ea38/black-22.12.0-cp310-cp310-win_amd64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/4c/49/420dcfccba3215dc4e5790fa47572ef14129df1c5e95dd87b5ad30211b01/black-22.12.0-cp311-cp311-win_amd64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/f1/b7/6de002378cfe0b83beba72f0a7875dfb6005b2a214ac9f9ca689583069ef/black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/eb/91/e0ccc36f8e1a00ed3c343741ca7ffe954e33cd2be0cada039845ff9e0539/black-22.12.0-cp37-cp37m-win_amd64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/54/44/6d5f9af3c14da013754021e28eacc873e6ecbe877b2540e37346579398c8/black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/4c/dd/cdb4e62a58e229ee757110a9dfb914a44e9d41be8becb41e085cb5df5d5b/black-22.12.0-cp38-cp38-win_amd64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/ba/32/954bcc56b2b3b4ef52a086e3c0bdbad88a38c9e739feb19dd2e6294cda42/black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/f2/b9/06fe2dd83a2104d83c2b737f41aa5679f5a4395630005443ba4fa6fece8b/black-22.12.0-cp39-cp39-win_amd64.whl for calculating hash
pdm.termui: Downloading link https://files.pythonhosted.org/packages/a6/59/e873cc6807fb62c11131e5258ca15577a3b7452abad08dc49286cf8245e8/black-22.12.0.tar.gz for calculating hash
🔒 Lock successful
Changes are written to pdm.lock.

It seems like the hashes from unearth are not moved over. While link.hashes is populated, link.hash is not. Can you reproduce this?

@apollo13
Copy link
Author

Just to be clear, the lines I am refering to are:

STATUS: Fetching hashes for resolved packages...
pdm.termui: Fetching hashes for [email protected]
pdm.termui: 	Found matching candidates:
pdm.termui: 	  <Candidate [email protected] from https://pypi.org/simple/black/>
pdm.termui: Downloading link https://files.pythonhosted.org/packages/e9/e0/6aa02d14785c4039b38bfed6f9ee28a952b2d101c64fc97b15811fa8bd04/black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl for calculating hash

@apollo13
Copy link
Author

apollo13 commented Jan 10, 2023

Interesting, any idea what could be causing the difference? I am running with python 3.11 and pdm says:

pdm --version
PDM, version 2.3.5.dev11+g885a7ec0

@apollo13
Copy link
Author

Oha, I have added a print("LINK:", link, link.hash, link.hashes) into get_hash and it yields:

LINK: <Link https://files.pythonhosted.org/packages/e9/e0/6aa02d14785c4039b38bfed6f9ee28a952b2d101c64fc97b15811fa8bd04/black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/5c/eb/975c7c080f3223a5cdaff09612f3a5221e4ba534f7039db34c35d95fa6a5/mypy_extensions-0.4.3-py2.py3-none-any.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/3c/29/c07c3a976dbe37c56e381e058c11e8738cb3a0416fc842a310461f8bb695/pathspec-0.10.3-py3-none-any.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/c1/c7/9be9d651b93efce682b45142a6267034fc4215972780748618c02e236361/platformdirs-2.6.2-py3-none-any.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/63/60/0582ce2eaced55f65a4406fc97beba256de4b7a95a0034c6576458c6519f/mypy_extensions-0.4.3.tar.gz (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/32/1a/6baf904503c3e943cae9605c9c88a43b964dea5b59785cf956091b341b08/pathspec-0.10.3.tar.gz (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/cf/4d/198b7e6c6c2b152f4f9f4cdf975d3590e33e63f1920f2d89af7f0390e6db/platformdirs-2.6.2.tar.gz (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/59/87/84326af34517fca8c58418d148f2403df25303e02736832403587318e9e8/click-8.1.3.tar.gz (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/0c/51/1f7f93c0555eaf4cbb628e26ba026e3256174a45bd9397ff1ea7cf96bad5/black-22.12.0-py3-none-any.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/79/d9/60852a6fc2f85374db20a9767dacfe50c2172eb8388f46018c8daf836995/black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/71/57/975782465cc6b514f2c972421e29b933dfbb51d4a95948a4e0e94f36ea38/black-22.12.0-cp310-cp310-win_amd64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/4c/49/420dcfccba3215dc4e5790fa47572ef14129df1c5e95dd87b5ad30211b01/black-22.12.0-cp311-cp311-win_amd64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/f1/b7/6de002378cfe0b83beba72f0a7875dfb6005b2a214ac9f9ca689583069ef/black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/eb/91/e0ccc36f8e1a00ed3c343741ca7ffe954e33cd2be0cada039845ff9e0539/black-22.12.0-cp37-cp37m-win_amd64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/54/44/6d5f9af3c14da013754021e28eacc873e6ecbe877b2540e37346579398c8/black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/4c/dd/cdb4e62a58e229ee757110a9dfb914a44e9d41be8becb41e085cb5df5d5b/black-22.12.0-cp38-cp38-win_amd64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/ba/32/954bcc56b2b3b4ef52a086e3c0bdbad88a38c9e739feb19dd2e6294cda42/black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/f2/b9/06fe2dd83a2104d83c2b737f41aa5679f5a4395630005443ba4fa6fece8b/black-22.12.0-cp39-cp39-win_amd64.whl (from None)> None None
LINK: <Link https://files.pythonhosted.org/packages/a6/59/e873cc6807fb62c11131e5258ca15577a3b7452abad08dc49286cf8245e8/black-22.12.0.tar.gz (from None)> None None

so there are indeed no hashes, adding print("LINK BEFORE PREPARE", c.link, c.link.hash, c.link.hashes) in repositories.py get_hashes shows:

LINK BEFORE PREPARE <Link https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl (from https://pypi.org/simple/colorama/)> None {'sha256': '4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6'}
LINK BEFORE PREPARE <Link https://files.pythonhosted.org/packages/71/57/975782465cc6b514f2c972421e29b933dfbb51d4a95948a4e0e94f36ea38/black-22.12.0-cp310-cp310-win_amd64.whl (from https://pypi.org/simple/black/)> None {'sha256': '159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351'}
...

so at least .hashes is lost on the way down. Why .hash is always None I have no idea yet.

@apollo13
Copy link
Author

Okay @frostming, I am a step further. I do get your result if I comment out those two lines in unearth:

https://github.com/frostming/unearth/blob/69d8af100f85467b4c501619447c06f0b1ec142e/src/unearth/collector.py#L180-L181

It seems to me that response from the json api do not populate link.hash at all.

@apollo13
Copy link
Author

apollo13 commented Jan 10, 2023

Ok, so I can confirm the following: When the simple index page returns HTML then the URLs look like this:

https://files.pythonhosted.org/packages/28/04/8ff5a1f6e4a8f808ae0320c8353b64fe85fcd700fe900010307b5a991c6a/pdm-2.3.4.tar.gz#sha256=cda48d339132e2823632d50f6011c6d0f08c80975ab156adc248da441ad3d514

and link.hash/link.hash_name is filled correctly and link.hashes is None. This makes sense since link.hash is populated from the fragment:
https://github.com/frostming/unearth/blob/69d8af100f85467b4c501619447c06f0b1ec142e/src/unearth/link.py#L160

When the index returns a JSON response then the URL is:

https://files.pythonhosted.org/packages/28/04/8ff5a1f6e4a8f808ae0320c8353b64fe85fcd700fe900010307b5a991c6a/pdm-2.3.4.tar.gz

and link.hash is None but link.hashes is {'sha256': 'cda48d339132e2823632d50f6011c6d0f08c80975ab156adc248da441ad3d514'}

This begs two new questions:

  • Do you get a HTML response or a JSON response?
  • Should this code
    if link.hash and link.hash_name in self.STRONG_HASHES:
    logger.debug("Using hash in link for %s", link.redacted)
    hash_value = f"{link.hash_name}:{link.hash}"
    take link.hashes into account as well?

frostming added a commit that referenced this issue Jan 11, 2023
@frostming
Copy link
Collaborator

Fixed in the main branch

@apollo13
Copy link
Author

Thanks! I wonder if it would make sense to fix in unearth as well. Ie return one of the hashes for .hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants