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 --no-default now runs a PEP 517 build (we need to add --no-self for PDM<=2.8.2 behavior) #2230

Closed
1 task done
aloisklink opened this issue Sep 4, 2023 · 0 comments · Fixed by #2264
Closed
1 task done
Assignees
Labels
🐛 bug Something isn't working

Comments

@aloisklink
Copy link

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

As of PDM v2.9.0, pdm install --no-default now runs a PEP 517 build, and we need to add --no-self to get the old behavior.
In PDM v2.8.2, pdm install --no-default did not run a PEP 517 build.

This seems pretty minor (and I've got no idea if this is a bug, or the old behavior was a bug and the current behavior is the correct one), but I thought it was making an issue anyway, since I can't seem to find it in the v2.9.0 PDM Release notes, and this did break some of our Linting/Documentation Continuous Integration pipelines.

Steps to reproduce

Clone the following GitHub gist, which has a minimal pdm package that always fails to build: https://gist.github.com/aloisklink/54e8047482db16bef4b2177068aede3c

Afterwards, run: pdm install --no-default.

Actual behavior

In pdm v2.9.0, this installs the dev dependencies, AND causes a PEP 517 build to occur.

Using the above test case, where the build script always fails, you'd get the following output:

verbose logs
alois@pc:/tmp/54e8047482db16bef4b2177068aede3c (main)$ pdm install --no-default --verbose
STATUS: Resolving packages from lockfile...
The saved Python interpreter doesn't match the project's requirement. Trying to find another one.
python.use_venv is on, creating a virtualenv for this project...
Run command: ['/usr/bin/python3', '-m', 'virtualenv', '/tmp/54e8047482db16bef4b2177068aede3c/.venv', '-p', '/usr/bin/python3', 
'--prompt=54e8047482db16bef4b2177068aede3c-3.10', '--no-pip', '--no-setuptools', '--no-wheel']
created virtual environment CPython3.10.12.final.0-64 in 24ms
  creator CPython3Posix(dest=/tmp/54e8047482db16bef4b2177068aede3c/.venv, clear=False, no_vcs_ignore=False, global=False)
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Virtualenv is created successfully at /tmp/54e8047482db16bef4b2177068aede3c/.venv
STATUS: Fetching hashes for resolved packages...
unearth.preparer: The file . is a local directory, use it directly
Synchronizing working set with lock file: 11 to add, 0 to update, 0 to remove

unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/4f/ab/0bcfebdfc3bfa8554b2b2c97a555569c4c1ebc74ea288741ea8326c51906/setuptools-68.1.2-py3-none-any.whl (from https://pypi.org/simple/setuptools/)>
  ✔ Install setuptools 68.1.2 successful
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/c5/55/51844dd50c4fc7a33b653bfaba4c2456f06955289ca770a5dbd5fd267374/cfgv-3.4.0-py2.py3-none-any.whl (from https://pypi.org/simple/cfgv/)>
  ✔ Install cfgv 3.4.0 successful
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/52/90/45223db4e1df30ff14e8aebf9a1bf0222da2e7b49e53692c968f36817812/filelock-3.12.3-py3-none-any.whl (from https://pypi.org/simple/filelock/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/43/a0/9ba967fdbd55293bacfc1507f58e316f740a3b231fc00e3d86dc39bc185a/distlib-0.3.7-py2.py3-none-any.whl (from https://pypi.org/simple/distlib/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/05/66/f65626f8e1fd835941851503f0dac65460b3f1332f7fffc85cbf548d5209/identify-2.5.27-py2.py3-none-any.whl (from https://pypi.org/simple/identify/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/14/51/fe5a0d6ea589f0d4a1b97824fb518962ad48b27cd346dcdfa2405187997a/platformdirs-3.10.0-py3-none-any.whl (from https://pypi.org/simple/platformdirs/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/58/56/3b24f8641c39021218ca16115a9cd88512ae16eab790513e832a36269e90/pre_commit-3.4.0-py2.py3-none-any.whl (from https://pypi.org/simple/pre-commit/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/1a/e6/6d2ead760a9ddb35e65740fd5a57e46aadd7b0c49861ab24f94812797a1c/nodeenv-1.8.0-py2.py3-none-any.whl (from https://pypi.org/simple/nodeenv/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/29/61/bf33c6c85c55bc45a29eee3195848ff2d518d84735eb0e2d8cb42e0d285e/PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from https://pypi.org/simple/pyyaml/)>
  ✔ Install filelock 3.12.3 successful
  ✔ Install platformdirs 3.10.0 successful
  ✔ Install nodeenv 1.8.0 successful
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl (from https://pypi.org/simple/typing-extensions/)>
  ✔ Install identify 2.5.27 successful
  ✔ Install typing-extensions 4.7.1 successful
  ✔ Install distlib 0.3.7 successful
  ✔ Install pre-commit 3.4.0 successful
  ✔ Install pyyaml 6.0.1 successful
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/48/87/0ff871ebe003075d61e1abeab67c21d50edf44dbfdeabd107bef30a9e027/virtualenv-20.24.4-py3-none-any.whl (from https://pypi.org/simple/virtualenv/)>
  ✔ Install virtualenv 20.24.4 successful
Installing the project as an editable package...
pdm.termui: Preparing isolated env for PEP 517 build...
pdm.termui: Running PEP 517 backend to build a wheel for <Link file:///tmp/54e8047482db16bef4b2177068aede3c (from None)>
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   wheel
pdm.termui:   setuptools>=40.8.0
pdm.termui:   python>=3.10.12,<3.10.13
pdm.termui:   Adding requirement wheel
pdm.termui:   Adding requirement setuptools>=40.8.0
pdm.termui:   Adding requirement python>=3.10.12,<3.10.13
pdm.termui: ======== Starting round 0 ========
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui: Pinning: setuptools 68.1.2
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: Pinning: wheel 0.41.2
pdm.termui: ======== Ending round 2 ========
pdm.termui: ======== Starting round 3 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:       python None
pdm.termui:   setuptools 68.1.2
pdm.termui:        wheel 0.41.2
pdm.termui: Installing [email protected]...
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/4f/ab/0bcfebdfc3bfa8554b2b2c97a555569c4c1ebc74ea288741ea8326c51906/setuptools-68.1.2-py3-none-any.whl (from https://pypi.org/simple/setuptools/)>
pdm.termui: Installing [email protected]...
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/b8/8b/31273bf66016be6ad22bb7345c37ff350276cfd46e389a0c2ac5da9d9073/wheel-0.41.2-py3-none-any.whl (from https://pypi.org/simple/wheel/)>
pdm.termui: Synchronization complete.
pdm.termui: Traceback (most recent call last):
pdm.termui:   File "/home/alois/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
pdm.termui:     main()
pdm.termui:   File "/home/alois/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
pdm.termui:     json_out['return_val'] = hook(**hook_input['kwargs'])
pdm.termui:   File "/home/alois/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
pdm.termui:     return hook(config_settings)
pdm.termui:   File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 468, in get_requires_for_build_editable
pdm.termui:     return self.get_requires_for_build_wheel(config_settings)
pdm.termui:   File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
pdm.termui:     return self._get_build_requires(config_settings, requirements=['wheel'])
pdm.termui:   File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
pdm.termui:     self.run_setup()
pdm.termui:   File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 507, in run_setup
pdm.termui:     super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
pdm.termui:   File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in run_setup
pdm.termui:     exec(code, locals())
pdm.termui:   File "<string>", line 2, in <module>
pdm.termui: Exception: setup.py script was called
  ✖ Install pdm-v2.9.0-test 1.0.0 failed
Traceback (most recent call last):
  File "/home/alois/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/core.py", line 290, in main
    return Core().main(args or sys.argv[1:])
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/core.py", line 208, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/core.py", line 203, in main
    self.handle(project, options)
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/core.py", line 157, in handle
    command.handle(project, options)
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/cli/commands/install.py", line 95, in handle
    actions.do_sync(
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/cli/actions.py", line 213, in do_sync
    synchronizer.synchronize()
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/installers/synchronizers.py", line 462, in synchronize
    self.install_candidate(self_key, progress)
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/installers/synchronizers.py", line 283, in install_candidate
    self.manager.install(can)
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/installers/manager.py", line 33, in install
    installer(str(prepared.build()), self.environment, prepared.direct_url())
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/models/candidates.py", line 395, in build
    self.wheel = Path(builder.build(build_dir, metadata_directory=self._metadata_dir))
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/builders/editable.py", line 39, in build
    requires = self._hook.get_requires_for_build_editable(config_settings)
  File "/home/alois/.local/lib/python3.10/site-packages/pyproject_hooks/_impl.py", line 226, in get_requires_for_build_editable
    return self._call_hook('get_requires_for_build_editable', {
  File "/home/alois/.local/lib/python3.10/site-packages/pyproject_hooks/_impl.py", line 311, in _call_hook
    self._subprocess_runner(
  File "/home/alois/.local/lib/python3.10/site-packages/pdm/builders/base.py", line 260, in subprocess_runner
    return log_subprocessor(cmd, cwd, extra_environ=env)
  File "/home/alois/.local/lib/python3.10/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:
  File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=['wheel'])
  File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
    self.run_setup()
  File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 507, in run_setup
    super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
  File "/tmp/pdm-build-env-lv0k6a2l-shared/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in run_setup
    exec(code, locals())
  File "<string>", line 2, in <module>
Exception: setup.py script was called

Expected behavior

The same behavior as in PDM v2.8.2. E.g., pdm install --no-default installs development dependencies, but DOES NOT RUN A PEP 517 build.

It's not too big of a deal, we can easily just add a --no-self option, but it's probably worth documenting this change in the v2.9.0 changelog.

E.g., in v2.9.0 pdm install --no-default --no-self works exactly how pdm install --no-default worked in v2.8.2.

verbose logs
alois@pc (main)$ pdm install --no-default --verbose
STATUS: Resolving packages from lockfile...
The saved Python interpreter doesn't match the project's requirement. Trying to find another one.
python.use_venv is on, creating a virtualenv for this project...
Run command: ['/usr/bin/python3', '-m', 'virtualenv', '/tmp/54e8047482db16bef4b2177068aede3c/.venv', '-p', '/usr/bin/python3', 
'--prompt=54e8047482db16bef4b2177068aede3c-3.10', '--no-pip', '--no-setuptools', '--no-wheel']
created virtual environment CPython3.10.12.final.0-64 in 23ms
  creator CPython3Posix(dest=/tmp/54e8047482db16bef4b2177068aede3c/.venv, clear=False, no_vcs_ignore=False, global=False)
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Virtualenv is created successfully at /tmp/54e8047482db16bef4b2177068aede3c/.venv
STATUS: Fetching hashes for resolved packages...
Synchronizing working set with lock file: 11 to add, 0 to update, 0 to remove

unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/4f/ab/0bcfebdfc3bfa8554b2b2c97a555569c4c1ebc74ea288741ea8326c51906/setuptools-68.1.2-py3-none-any.whl (from https://pypi.org/simple/setuptools/)>
  ✔ Install setuptools 68.1.2 successful
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/c5/55/51844dd50c4fc7a33b653bfaba4c2456f06955289ca770a5dbd5fd267374/cfgv-3.4.0-py2.py3-none-any.whl (from https://pypi.org/simple/cfgv/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/14/51/fe5a0d6ea589f0d4a1b97824fb518962ad48b27cd346dcdfa2405187997a/platformdirs-3.10.0-py3-none-any.whl (from https://pypi.org/simple/platformdirs/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/43/a0/9ba967fdbd55293bacfc1507f58e316f740a3b231fc00e3d86dc39bc185a/distlib-0.3.7-py2.py3-none-any.whl (from https://pypi.org/simple/distlib/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/52/90/45223db4e1df30ff14e8aebf9a1bf0222da2e7b49e53692c968f36817812/filelock-3.12.3-py3-none-any.whl (from https://pypi.org/simple/filelock/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/29/61/bf33c6c85c55bc45a29eee3195848ff2d518d84735eb0e2d8cb42e0d285e/PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (from https://pypi.org/simple/pyyaml/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/05/66/f65626f8e1fd835941851503f0dac65460b3f1332f7fffc85cbf548d5209/identify-2.5.27-py2.py3-none-any.whl (from https://pypi.org/simple/identify/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/1a/e6/6d2ead760a9ddb35e65740fd5a57e46aadd7b0c49861ab24f94812797a1c/nodeenv-1.8.0-py2.py3-none-any.whl (from https://pypi.org/simple/nodeenv/)>
  ✔ Install cfgv 3.4.0 successful
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/58/56/3b24f8641c39021218ca16115a9cd88512ae16eab790513e832a36269e90/pre_commit-3.4.0-py2.py3-none-any.whl (from https://pypi.org/simple/pre-commit/)>
  ✔ Install platformdirs 3.10.0 successful
  ✔ Install filelock 3.12.3 successful
  ✔ Install nodeenv 1.8.0 successful
  ✔ Install identify 2.5.27 successful
  ✔ Install pre-commit 3.4.0 successful
  ✔ Install distlib 0.3.7 successful
  ✔ Install pyyaml 6.0.1 successful
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl (from https://pypi.org/simple/typing-extensions/)>
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/48/87/0ff871ebe003075d61e1abeab67c21d50edf44dbfdeabd107bef30a9e027/virtualenv-20.24.4-py3-none-any.whl (from https://pypi.org/simple/virtualenv/)>
  ✔ Install typing-extensions 4.7.1 successful
  ✔ Install virtualenv 20.24.4 successful

🎉 All complete!

PDM 2.8.2 is installed, while 2.9.1 is available.
Please run `pdm self update` to upgrade.
Run `pdm config check_update false` to disable the check.

Environment Information

alois@pc:/tmp/54e8047482db16bef4b2177068aede3c (main)$ pdm info && pdm info --env
PDM version:
  2.9.1
Python Interpreter:
  /tmp/54e8047482db16bef4b2177068aede3c/.venv/bin/python (3.10)
Project Root:
  /tmp/54e8047482db16bef4b2177068aede3c
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.12",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.19.0-45-generic",
  "platform_system": "Linux",
  "platform_version": "#46~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 7 15:06:04 UTC 20",
  "python_full_version": "3.10.12",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "linux"
}
@aloisklink aloisklink added the 🐛 bug Something isn't working label Sep 4, 2023
aloisklink added a commit to nqminds/nqm-irimager that referenced this issue Sep 4, 2023
PDM v2.9.0 changed how the `pdm install --no-default` command worked,
as it now installs dev dependencies, and it runs a [PEP 517][] build.

In order to get the old behaviour, where it only installs dev
dependencies (without the build), we now need to add a `--no-self`
option.

[PEP 517]: https://peps.python.org/pep-0517/

See: pdm-project/pdm#2230
@frostming frostming self-assigned this Sep 15, 2023
frostming added a commit that referenced this issue Sep 15, 2023
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