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 install now always installs optional dependencies? (extras) #1863

Closed
1 task done
pawamoy opened this issue Apr 28, 2023 · 8 comments
Closed
1 task done

pdm install now always installs optional dependencies? (extras) #1863

pawamoy opened this issue Apr 28, 2023 · 8 comments
Labels
🐛 bug Something isn't working

Comments

@pawamoy
Copy link
Contributor

pawamoy commented Apr 28, 2023

  • 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

pdm install with optional dependencies specified in pyproject.toml.

Actual behavior

PDM installs all optional dependencies, while it didn't before.

Expected behavior

I expect PDM not to install optional dependencies (extras) without me explicitly asking for it (with -G :all or -G myextra), since there's no way to explicitly exclude them.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.5.3
Python Interpreter:
  /home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.11.0/bin/python3 (3.11)
Project Root:
  /media/data/dev/mkdocstrings
Local Packages:
  /media/data/dev/mkdocstrings/__pypackages__/3.11
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.0",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.2.12-arch1-1",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Thu, 20 Apr 2023 16:11:55 +0000",
  "python_full_version": "3.11.0",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "linux"
}
@pawamoy pawamoy added the 🐛 bug Something isn't working label Apr 28, 2023
@pawamoy
Copy link
Contributor Author

pawamoy commented May 1, 2023

By the way pdm lock without -G ... will not include optional dependencies in the lock file, so pdm lock then pdm install will fail.

An alternative would be to add a --no-optional flag to pdm install (and maybe to pdm lock as well).

So my conclusion is that we should have the following behavior:

  • pdm lock: lock everything
  • pdm lock -G ...: lock only the given groups
  • pdm install: install everything
  • pdm install -G ...: install only the given groups
  • pdm install --no-optional: install everything except optional deps (extras), compatible with other --no-* flags

Finally, the -d, --dev flag is useless now, right? Also maybe we should have an alias --no-dev for --production. That would give us the following flags which look consistent:

  • --no-default
  • --no-optional
  • --no-dev

@frostming
Copy link
Collaborator

More such options will add to the confusion. I will just revert this behavior so that users can choose to include the optional groups. But in the future, we would like to change the options to --with/--without to be more orthogonal.

@pawamoy
Copy link
Contributor Author

pawamoy commented May 4, 2023

I understand, reverting to the previous behavior sounds good to me 🙂

But in the future, we would like to change the options to --with/--without to be more orthogonal.

Orthogonal to Poetry 😄? This was the initial proposal I made there indeed haha, funny. Yeah the --with and --without syntax is nice I think. Would groups be a comma-separated list, like --with group1,group2?

@frostming
Copy link
Collaborator

frostming commented May 5, 2023

so pdm lock then pdm install will fail.

This isn't the case at least from my observation, if no --dev/-G/--production/--no-default option are given to pdm install, what are locked in the lockfile will be installed without error.

@pawamoy
Copy link
Contributor Author

pawamoy commented May 5, 2023

Yeah I think my lock file contained all groups. I thought pdm lock overwrites it each time it is run, but it seems it reuses its contents instead. My bad.

@frostming
Copy link
Collaborator

The behavior change here, is when you doesn't give any dependency selection option, PDM will install what is locked in the lockfile.

There is a way to not install the optional dependencies though: pdm install -d. I am going to close it now.

@AndrewLaptev
Copy link

AndrewLaptev commented Jun 7, 2023

@frostming
Hi! Are you planning to eventually return to the old pdm install behavior when optional dependencies are not installed by default? In pdm 2.7.0, optional dependencies are still installed by default, although the documentation says the opposite

@frostming
Copy link
Collaborator

although the documentation says the opposite

The docs need update.

Yeah when no options are given, all locked groups will be installed. You can pass some flags to select or unselect some groups.

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

No branches or pull requests

3 participants