pdm icon indicating copy to clipboard operation
pdm copied to clipboard

Allow multiple lockfiles targeting different platforms

Open oyarsa opened this issue 2 years ago • 1 comments

Now that we have #1898, it could be interesting to have platform-specific lockfiles, each generated by something like --no-cross-platform.

My primary use case for this is pytorch: ideally, you would get different results depending on your platform: the CUDA version on Linux and the MPS version on macOS. As it stands, I'm getting the CPU version on Linux if I use the lockfile generated on macOS.

My current solution is not to commit the lockfile and let PDM figure it out every time I do a pdm install. Instead, if we have multiple lockfiles, I could generate specific ones for each platform I support.

The UX for this could be something like this:

  • Manual: new flag --lockfile <file> that creates a lockfile in path file if it doesn't exist or uses it to install dependencies. This would be required for every pdm install.
  • Supply once, use it always: pdm install needs the argument once per instance, but after that, you don't need to specify it anymore
  • Automated: when using --no-cross-platform, the lockfile generated encodes the platform in its name, and pdm install would automatically use that if it exists, prioritising it over other lockfiles.

oyarsa avatar May 10 '23 16:05 oyarsa

Isn't the more obvious to add package based on the platform:

pdm add "pytorch; sys_platform==\"Darwin\""

Another solution is to just do:

On linux:

pdm add pytorch --lockfile pdm-linux.lock

On macos:

pdm add pytorch --lockfile pdm-macos.lock

I will add that this can be easily automated as lockfile is on default set to this:

Specify another lockfile path. Default: pdm.lock. [env var: PDM_LOCKFILE]

So well specify PDM_LOCKFILE on macos to something different, on linux to something different and you are set.

Drachenfels avatar Jul 20 '23 12:07 Drachenfels

Resolved by #2995

frostming avatar Jul 08 '24 09:07 frostming