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

Packages add/remove with --dev does not work if custom scripts configuration block defined [tool.pdm.scripts] #2056

Closed
mrx88 opened this issue Jun 26, 2023 · 6 comments
Assignees
Labels
🐛 bug Something isn't working

Comments

@mrx88
Copy link

mrx88 commented Jun 26, 2023

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

Steps to reproduce

  1. Add tool.pdm.scripts to pyproject.toml:
    [tool.pdm.scripts] hello = {shell = "echo hello"}
  2. Add or Remove package from dev, e.g pytest:
    pdm add pytest --dev
  3. Package not added/removed under [tool.pdm.dev-dependencies] "dev" section. Package also not installed or removed.

Note: if removing [tool.pdm.scripts] section, step 2 works fine.

Actual behavior

--dev packages add/remove does not work if custom scripts configuration block defined [tool.pdm.scripts]

Expected behavior

--dev packages add/remove should work if custom scripts defined under [tool.pdm.scripts]

Environment Information

# Paste the output of `pdm info && pdm info --env` below:

PDM version:
  5.7.4
Python Interpreter:
  /home/asd/azdevops/apps/asd/.venv/bin/python (3.9)
Project Root:
  /home/asd/azdevops/apps/asd
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.9.2",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.90.1-microsoft-standard-WSL2",
  "platform_system": "Linux",
  "platform_version": "#1 SMP Fri Jan 27 02:56:13 UTC 2023",
  "python_full_version": "3.9.2",
  "platform_python_implementation": "CPython",
  "python_version": "3.9",
  "sys_platform": "linux"
}
@mrx88 mrx88 added the 🐛 bug Something isn't working label Jun 26, 2023
@frostming
Copy link
Collaborator

frostming commented Jun 27, 2023

This bug report makes no sense to me, nor can I reproduce it. There should be some problem on your side, can you provide a example repository(or docker image) to reproduce this issue?

A rough guess is you might open the file for change but not saved yet. The IDE or editor you use always show the un-saved content.

@frostming frostming added 🤔 waiting for feedback Requires more information to clarify the issue and removed 🐛 bug Something isn't working labels Jun 27, 2023
@mrx88
Copy link
Author

mrx88 commented Jun 27, 2023

Yes it is strange one, but I have not figured it out yet, therefore created this issue to get more ideas. Strange that happens with my work laptop and I can`t reproduce it on my personal one. In the example I am using python 3.9.2 (which has issues, Win 10, WSL, VS Code) and in personal project python 3.11(no issues, Win 11, WSL, VS Code)

pdm list |grep pytest

│ pytest │ 7.4.0 │ │

pdm remove pytest --dev
Removing packages from dev dev-dependencies: pytest
Changes are written to pyproject.toml.
🔒 Lock successful
Changes are written to pdm.lock.
All packages are synced to date, nothing to do.

🎉 All complete!

Package still in the list:
pdm list |grep pytest
│ pytest │ 7.4.0 │ │

Also not removed from .toml conf under tool.pdm.dev-dependencies section.

venv path is correct.

After commenting out "[tool.pdm.scripts]" in toml config:

pdm list |grep pytest
│ pytest │ 7.4.0 │ │

pdm remove pytest --dev
Removing packages from dev dev-dependencies: pytest
Changes are written to pyproject.toml.
🔒 Lock successful
Changes are written to pdm.lock.
Synchronizing working set with lock file: 0 to add, 0 to update, 4 to remove

✔ Remove exceptiongroup 1.1.1 successful
✔ Remove iniconfig 2.0.0 successful
✔ Remove pluggy 1.2.0 successful
✔ Remove pytest 7.4.0 successful

🎉 All complete!

pdm list |grep pytest

Package was removed, also from toml config.

@frostming
Copy link
Collaborator

@mrx88 This doesn't help at all. You may need to do some investigation yourself.

@mrx88
Copy link
Author

mrx88 commented Jun 27, 2023

I figured out how to fix it:

[tool.pdm.scripts] block was under [build-system] in toml config, when moving it above [build-system] package remove/add and toml config update works as expected. Not sure if such behavior is expected or it`s a bug.

@frostming
Copy link
Collaborator

So you mean such structure:

[tool.pdm.dev-dependencies]
dev = ["pytest"]

[build-system]
...

[tool.pdm.scripts]
...

Noted, will try it tomorrow.

@frostming frostming added 🐛 bug Something isn't working and removed 🤔 waiting for feedback Requires more information to clarify the issue labels Jun 28, 2023
@frostming frostming self-assigned this Jun 28, 2023
@frostming
Copy link
Collaborator

Fixed by #2061

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

2 participants