Replies: 3 comments
-
Another issue I am having is trying to use conda on a Mac ARM platform under rosetta. Typically what one would do is set # Minimal pyproject.toml
[project]
requires-python = ">=3.10" $ CONDA_SUBDIR=osx-64 CONDA_PREFIX= PDM_VENV_IN_PROJECT=1 PDM_USE_VENV=1 PDM_VENV_BACKEND=conda PDM_IGNORE_SAVED_PYTHON=1 pdm venv create 3.10
Virtualenv .../.venv is created successfully
$ pdm add pyfftw
Adding packages to default dependencies: pyfftw
Virtualenv .../.venv is reused.
...
✔ Install numpy 1.24.2 successful
✖ Install pyfftw 0.13.1 failed
Retry failed jobs
✖ Install pyfftw 0.13.1 failed
* The Python version is: Python3.10 from ".../.venv/bin/python"
* The NumPy version is: "1.21.6" Why is NumPy version 1.21.6 being used if the installed version is 1.24.2? The debug log seems to show that pdm is installing this (probably with the wrong architecture). If I install pdm in the virtual environment and run it from there, everything works, but this seems completely counter to the philosophy that PDM should be installed as a tool outside of the project. $ conda activate .venv
$ pip install pdm
...
$ pdm add pyfftw
...
✔ Install pyfftw 0.13.1 successful
✔ Install numpy 1.24.2 successful
Installing the project as an editable package...
✔ Install test 0.0.1 successful
🎉 All complete! Full traceback and logs$ CONDA_SUBDIR=osx-64 CONDA_PREFIX= PDM_VENV_IN_PROJECT=1 PDM_USE_VENV=1 PDM_VENV_BACKEND=conda PDM_IGNORE_SAVED_PYTHON=1 pdm venv create 3.10
Virtualenv .../.venv is created successfully
$ pdm add pyfftw
Adding packages to default dependencies: pyfftw
Virtualenv .../.venv is reused.
🔒 Lock successful
...
✔ Install numpy 1.24.2 successful
✖ Install pyfftw 0.13.1 failed
Retry failed jobs
✖ Install pyfftw 0.13.1 failed
ERRORS:
add pyfftw failed:
Traceback (most recent call last):
File "/data/apps/conda_arm64/lib/python3.9/concurrent/futures/thread.py", line 58, in run
...
File "/Volumes/Data/apps/pipx/venvs/pdm/lib/python3.9/site-packages/pdm/builders/base.py", line 107, in log_subprocessor
raise build_error(e) from None
pdm.exceptions.BuildError: Build backend raised error: Showing the last 10 lines of the build output:
Please note and check the following:
* The Python version is: Python3.10 from ".../.venv/bin/python"
* The NumPy version is: "1.21.6"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(/var/folders/m7/dnr91tjs4gn58_t3k8zp_g000000gr/T/pdm-build-env-yo2qn11z-shared/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried:
'/usr/local/cuda/lib/_multiarray_umath.cpython-310-darwin.so' (no such file),
'/var/folders/m7/dnr91tjs4gn58_t3k8zp_g000000gr/T/pdm-build-env-yo2qn11z-shared/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible
architecture (have (arm64), need (x86_64))), '/usr/local/cuda/lib/_multiarray_umath.cpython-310-darwin.so' (no such file),
'/private/var/folders/m7/dnr91tjs4gn58_t3k8zp_g000000gr/T/pdm-build-env-yo2qn11z-shared/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible
architecture (have (arm64), need (x86_64)))
See /var/folders/m7/dnr91tjs4gn58_t3k8zp_g000000gr/T/pdm-install-iaborwk7.log for detailed debug log.
...
Is this a bug? How do I control the platform and |
Beta Was this translation helpful? Give feedback.
-
A related question: why can't I specify the $ pdm config -l cache_dir .local/pdm
[ValueError]: Config item 'cache_dir' is not allowed to set in project config. Update: There is reference in #435 (comment) to assumptions being made about a centralized cache... but I still don't understand why, or how to get |
Beta Was this translation helpful? Give feedback.
-
Hi, sorry if this is too tangential, but I use https://github.com/bluss/pyproject-local-kernel for reproducible notebooks - each directory of notebooks have their dependencies defined by a pyproject.toml. I use it with Rye, but it supports Pdm as well. |
Beta Was this translation helpful? Give feedback.
-
Recently I started trying to use pdm for managing project dependencies and have been stumbling because of what I interpret as two distinct and somewhat conflicting goals:
I have been trying to achieve goal 2, but keep stumbling on issues related to 1. This discussing is to help document the issues I had, their resolution, with the goal of being turned into clear documentation so future users like me do not stumble on similar issues.
Use Case
I am trying to setup a general workflow for establishing a reproducible computing environment for projects with cross-platform support. I am currently using a
Makefile
to specify the workflow so that users can get up and running by doing something like this:make init
.My impression was that this should be possible with tools like Anaconda Project, Poetry and pdm through something like this:
Anaconda Project: (I am most familiar with this.)
Poetry adds a nice feature
poetry shell
which spawns a shell that one can work in. I can fake this with a custom command in Anaconda Project that runs bash using a local init script that activates the appropriate environment.The reason I have to use a
Makefile
is that this all requires having Anaconda Project installed on the users computer which should not be taken for granted. I use this on CoCalc for example, which has everything installed, but where it needs to be activated by an appropriate command, and on HPC clusters where one needs to load an appropriate module etc. Even ifconda
is available, I don't want to muck up peoples environments, so I can't just tell them to doconda install anaconda-project
. I can use theMakefile
to code all of the subtleties so that the user just needs to do:and things work. (Plus, the
Makefile
then provides a reference about what needs to be done on various platforms.)I have been trying to figure out how to do something similar with pdm but keep running into issues with semi-magic defaults (goal 1.) such as:
.pdm.toml
. This is machine-dependent, so not something I should control in my project, but subtly overrides some of the explicit behaviour I was expecting (seepython.use_venv = True
does not cause packages to be installed in venv #973 (comment)). I think the correct way to control this is the-I, --ignore-python
option, or settingPDM_IGNORE_SAVED_PYTHON=1
before runningpdm
, then usingPDM_VENV_IN_PROJECT=1
andPDM_USE_VENV=1
works to create the isolated virtual environment in.venv
... unlessCONDA_PREFIX=
before runningpdm
, or to explicitly create and use the virtualenv.-i, --ignore-remembered
flag is important because if you have runpdm use .venv
before in another project, then that result will be cached somewhere (see thecache_dir
output ofpdm config
) and reused. This is another semi-magical default behaviour introduced in Feature: Remember the last selection in "pdm use" #852 in response to Support configuring Python interpreter paths for different Python versions in.pdm.toml
#846 which helps with goal 1. but creates a stumbling block for goal 2.Thus, I am currently working with instructions and a
Makefile
with something like the following.If needed, install
pdm
withpipx install pdm
.Run
make init
with the followingMakefile
To show some of the things I am trying to do (and why I probably need a
Makefile
) I have included instructions to register and unregister a Jupyter kernel for the current environment.Is this overkill? Have I missed any other potential issues (have not extensively tested this yet).
Also, is there any way to get a command like
pdm shell
to work likepoetry shell
: i.e. spawning a shell with the appropriate venv activated? I know there is pdm-shell, but this just sets the environmental variableseval "$(pdm shell)"
: I would like to spawn a new shell likepoetry shell
does. With Anaconda Project one can define custom commands that do thisanaconda-project run shell
. Is there something similar with pdm? (I am sure I could probably do this with a plugin... is that the best approach or am I missing something.)Suggestions/comments appreciated!
Beta Was this translation helpful? Give feedback.
All reactions