pdm-packer
pdm-packer copied to clipboard
Version 0.8.0 failing with FileNotFoundError
Describe the bug
With the release of 0.8.0 I discovered:
- I don't have the version of pdm-packer pinned in my project
- I get a FileNotFoundError when I try to pack
To Reproduce
$ pdm --version
PDM, version 2.18.1
$ mkdir test
$ cd test
$ pdm init
Creating a pyproject.toml for PDM...
Please enter the Python interpreter to use
0. [email protected] (/usr/bin/python3)
1. [email protected] (/usr/bin/python3.12)
2. [email protected] (/usr/bin/python3.9)
3. [email protected] (/bin/python3.12)
Please select (0): 1
Virtualenv is created successfully at /home/vagrant/test/.venv
Project name (test):
Project version (0.1.0):
Do you want to build this project for distribution(such as wheel)?
If yes, it will be installed by default when running `pdm install`. [y/n] (n):
License(SPDX name) (MIT):
Author name (Eric Smith):
Author email ([email protected]):
Python requires('*' to allow any) (==3.12.*):
Project is initialized successfully
$ vi pyproject.toml # Adding `plugins = ["pdm-packer"]`
$ pdm install --plugins
Plugins are installed successfully into .pdm-plugins.
$ pdm lock
Changes are written to pdm.lock.
0:00:00 🔒 Lock successful.
$ pdm pack
Packing packages...
/home/vagrant/test/.pdm-plugins/lib/python3.12/site-packages/pdm_packer/env.py:55: PDMDeprecationWarning: .values() is deprecated on the requirements collection, it's not a mapping but a list.
requirements = project.get_dependencies().values()
All packages are synced to date, nothing to do.
✔ Install test 0.1.0 successful
0:00:00 🎉 All complete! 0/0
[FileNotFoundError]: [Errno 2] No such file or directory: '/tmp/pdm-pack-c68x4fg7/lib64/python3.12/site-packages'
WARNING: Add '-v' to see the detailed traceback
Expected behavior
A zipapp to be created.
System (please complete the following information):
pdm-packerversion: 0.8.0- Python version: 3.12.5
- OS: Linux
Additional context
In debugging, the first exists, but the second doesn't:
/tmp/pdm-pack-c68x4fg7/lib/python3.12/site-packages /tmp/pdm-pack-c68x4fg7/lib64/python3.12/site-packages
If I pin the version to 0.7.0, packing works (other than an expected "Archive has no entry point").
Also, BTW, 0.7.0 doesn't exist in CHANGELOG.md.
Can you show the output of the following command:
/usr/bin/python3.12 /path/to/pdm/lib/site-packages/pdm/models/in_process/sysconfig_get_paths.py prefix
Sure:
$ /usr/bin/python3.12 /usr/local/lib/python3.12/site-packages/pdm/models/in_process/sysconfig_get_paths.py prefix
{"stdlib": "/usr/lib64/python3.12", "platstdlib": "/usr/local/lib64/python3.12", "purelib": "/usr/local/lib/python3.12/site-packages", "platlib": "/usr/local/lib64/python3.12/site-packages", "include": "/usr/include/python3.12", "platinclude": "/usr/include/python3.12", "scripts": "/usr/local/bin", "data": "/usr/local"}
That does not make sense, since we are using the purelib path:
https://github.com/frostming/pdm-packer/blob/3ec0828a8f18711028bf73702b029de62295914d/src/pdm_packer/env.py#L74
Can you provide the full traceback by adding -v
$ pdm pack -v
Packing packages...
STATUS: Resolving packages from lockfile...
All packages are synced to date, nothing to do.
Installing the project as a package...
✔ Install test 0.1.0 successful
🎉 All complete!
Traceback (most recent call last):
File "/usr/local/bin/pdm", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.12/site-packages/pdm/core.py", line 351, in main
return core.main(args or sys.argv[1:])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pdm/core.py", line 269, in main
raise cast(Exception, err).with_traceback(traceback) from None
File "/usr/local/lib/python3.12/site-packages/pdm/core.py", line 264, in main
self.handle(project, options)
File "/usr/local/lib/python3.12/site-packages/pdm/core.py", line 196, in handle
command.handle(project, options)
File "/home/vagrant/test/.pdm-plugins/lib/python3.12/site-packages/pdm_packer/command.py", line 114, in handle
lib = pack_env.prepare_lib_for_pack(compile=options.compile)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vagrant/test/.pdm-plugins/lib/python3.12/site-packages/pdm_packer/env.py", line 73, in prepare_lib_for_pack
synchronizer.synchronize()
File "/usr/local/lib/python3.12/site-packages/pdm/installers/synchronizers.py", line 441, in synchronize
self._fix_pth_files()
File "/usr/local/lib/python3.12/site-packages/pdm/installers/synchronizers.py", line 333, in _fix_pth_files
for path in list(Path(lib_paths[scheme]).iterdir()):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/pathlib.py", line 1056, in iterdir
for name in os.listdir(self):
^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pdm-pack-h9fyqbtr/lib64/python3.12/site-packages'
Just in case it is interesting...
$ uname -srm
Linux 6.8.0-40-generic x86_64
$ lsb_release -a
LSB Version: n/a
Distributor ID: CentOS
Description: CentOS Stream 9
Release: 9
Codename: n/a
Running under Docker.
I'm facing the same kind of issue when trying to build a project inside our Jenkin docker container.
Seem that venv is not being activated?
Traceback (most recent call last):
File "/usr/local/bin/pdm", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.12/site-packages/pdm/core.py", line 391, in main
return core.main(args or sys.argv[1:])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pdm/core.py", line 270, in main
raise cast(Exception, err).with_traceback(traceback) from None
File "/usr/local/lib/python3.12/site-packages/pdm/core.py", line 265, in main
self.handle(project, options)
File "/usr/local/lib/python3.12/site-packages/pdm/core.py", line 195, in handle
command.handle(project, options)
File "/usr/local/lib/python3.12/site-packages/pdm_packer/command.py", line 114, in handle
lib = pack_env.prepare_lib_for_pack(compile=options.compile)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pdm_packer/env.py", line 73, in prepare_lib_for_pack
synchronizer.synchronize()
File "/usr/local/lib/python3.12/site-packages/pdm/installers/synchronizers.py", line 241, in synchronize
self._fix_pth_files()
File "/usr/local/lib/python3.12/site-packages/pdm/installers/synchronizers.py", line 134, in _fix_pth_files
for path in list(Path(lib_paths[scheme]).iterdir()):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.12/pathlib.py", line 1056, in iterdir
for name in os.listdir(self):
^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pdm-pack-ekq2w0u1/lib64/python3.12/site-packages'
any news about it?
@cvgaviao what is the version of PDM? can you use the latest version of PDM?
@frostming , I'm using the latest "2.25.3".
I suspect that the issue is due the fact we are running in a container with Jenkins