pdm-project / pdm

A modern Python package and dependency manager supporting the latest PEP standards
https://pdm-project.org
MIT License
6.64k stars 341 forks source link

pyproject.toml better management idea #2862

Open darkworks opened 2 weeks ago

darkworks commented 2 weeks ago

Ok so am new two PDM i found to problems i will highlight it

1 ) initially when u do pdm init it ask for python interpreter which it fetch from system let say u select v3.9 from the list. later when u switch like

pdm python install 3.10
pdm use 3.10

it switch however it not update the entry in pyprojet.tom file i mean requires-python = ">=3.9" will be still 3.9

2 ) if you add invalid package let say pdm add skimage it will end up with failed installation because this package not exist however it will store this entry in pyproject.toml file which it should not . it should only store valid packages entries in dependencies block

thanks

pawamoy commented 2 weeks ago

it switch however it not update the entry in pyprojet.tom file i mean requires-python = ">=3.9" will be still 3.9

There's a difference between what Python version you use locally and what Python versions your project supports. Switching between different local Python versions should never change requires-python.

if you add invalid package let say pdm add invalid_pkg1234 it will end up with failed installation because this package not exist however it will store this entry in pyproject.toml file which it should not

I cannot reproduce this behavior.

% cat pyproject.toml 
[project]
name = "p"
version = "0.1.0"
description = "Default template for PDM package"
authors = [
    {name = "Timothée Mazzucotelli", email = "dev@pawamoy.fr"},
]
dependencies = []
requires-python = "==3.11.*"
readme = "README.md"
license = {text = "MIT"}

[tool.pdm]
distribution = false
% pdm add invalidpackage123
Adding packages to default dependencies: invalidpackage123
See /home/pawamoy/.local/state/pdm/log/pdm-lock-ch3p_rpi.log for detailed debug log.
[CandidateNotFound]: Unable to find candidates for invalidpackage123. There may exist some issues with the package name or network condition.
WARNING: Add '-v' to see the detailed traceback
% cat pyproject.toml       
[project]
name = "p"
version = "0.1.0"
description = "Default template for PDM package"
authors = [
    {name = "Timothée Mazzucotelli", email = "dev@pawamoy.fr"},
]
dependencies = []
requires-python = "==3.11.*"
readme = "README.md"
license = {text = "MIT"}

[tool.pdm]
distribution = false
frostming commented 2 weeks ago

it switch however it not update the entry in pyprojet.tom file i mean requires-python = ">=3.9" will be still 3.9

Why it should be updated? Library authors usually need to test against multiple python versions to make sure the project is compatible within a range of python versions. He should often run pdm use <version>, and doesn't expect requires-python to be changed. Changing that value means a significant upgrade of your library interfaces, and should be done manually(by hand). You may misunderstand the meaning of this property

2) can't be reproduced either.

darkworks commented 2 weeks ago

it switch however it not update the entry in pyprojet.tom file i mean requires-python = ">=3.9" will be still 3.9

There's a difference between what Python version you use locally and what Python versions your project supports. Switching between different local Python versions should never change requires-python.

if you add invalid package let say pdm add invalid_pkg1234 it will end up with failed installation because this package not exist however it will store this entry in pyproject.toml file which it should not

I cannot reproduce this behavior.

% cat pyproject.toml 
[project]
name = "p"
version = "0.1.0"
description = "Default template for PDM package"
authors = [
    {name = "Timothée Mazzucotelli", email = "dev@pawamoy.fr"},
]
dependencies = []
requires-python = "==3.11.*"
readme = "README.md"
license = {text = "MIT"}

[tool.pdm]
distribution = false
% pdm add invalidpackage123
Adding packages to default dependencies: invalidpackage123
See /home/pawamoy/.local/state/pdm/log/pdm-lock-ch3p_rpi.log for detailed debug log.
[CandidateNotFound]: Unable to find candidates for invalidpackage123. There may exist some issues with the package name or network condition.
WARNING: Add '-v' to see the detailed traceback
% cat pyproject.toml       
[project]
name = "p"
version = "0.1.0"
description = "Default template for PDM package"
authors = [
    {name = "Timothée Mazzucotelli", email = "dev@pawamoy.fr"},
]
dependencies = []
requires-python = "==3.11.*"
readme = "README.md"
license = {text = "MIT"}

[tool.pdm]
distribution = false

can you try with this : pdm add skimage in my project file i have

dependencies = [
    "gvxr>=2.0.7",
    "numpy>=1.26.4",
    "matplotlib>=3.8.4",
    "tifffile>=2024.4.24",
    "scikit-image>=0.23.2",
    "SimpleITK>=2.3.1",
    "skimage>=0.0",
]
darkworks commented 2 weeks ago

it switch however it not update the entry in pyprojet.tom file i mean requires-python = ">=3.9" will be still 3.9

Why it should be updated? Library authors usually need to test against multiple python versions to make sure the project is compatible within a range of python versions. He should often run pdm use <version>, and doesn't expect requires-python to be changed. Changing that value means a significant upgrade of your library interfaces, and should be done manually(by hand). You may misunderstand the meaning of this property

  1. can't be reproduced either.

Ok got it point 1 is valid.

for point 2 can u try with : pdm add skimage

darkworks commented 2 weeks ago
pawamoy commented 2 weeks ago

also it will be cool if pdm run command without parameters directly execute main script like src/project_name/init.py

You mean running the main project script if it's the only defined script?

[project.scripts]
your_script = "your_package.your_module:your_function
pdm run  # equivalent to pdm run your_script?

I prefer explicit over implicit but I don't have strong opinions here.

add some nooobies instructions to readme file on executing pdm build when by default README.md file have just project name and user have not added any custom info to it. like

You mean when running pdm init you would like the README to contain more information? What do you have in mind? :slightly_smiling_face: Project description, and a quick section about installing dependencies maybe (pdm install)?

goyalyashpal commented 1 week ago
  • pdm run command without parameters directly execute main script like src/project_name/__init__.py

i would be against this. it would open a wormcan of buggy behaviour. somebody would configure it in some contrived way, someone else would expect smth else, and things would diverge. difficult to rollback.

darkworks commented 1 week ago

also it will be cool if pdm run command without parameters directly execute main script like src/project_name/init.py

You mean running the main project script if it's the only defined script?

[project.scripts]
your_script = "your_package.your_module:your_function
pdm run  # equivalent to pdm run your_script?

I prefer explicit over implicit but I don't have strong opinions here.

add some nooobies instructions to readme file on executing pdm build when by default README.md file have just project name and user have not added any custom info to it. like

You mean when running pdm init you would like the README to contain more information? What do you have in mind? 🙂 Project description, and a quick section about installing dependencies maybe (pdm install)?

yes such noobs instructions on project title description and installation tips etc will be good .

2 ) if you add invalid package let say pdm add skimage it will end up with failed installation because this package not exist however it will store this entry inpyproject.toml file which it should not . it should only store valid packages entries in dependencies block

pawamoy commented 1 week ago

pdm add skimage

It's done in two phases IIUC:

  1. first it tries to resolve the skimage dependency: it succeeds because it actually exists (https://pypi.org/project/skimage/)
  2. then it tries to install it: it fails because skimage raises a SystemExit from its setup.py file:
import sys

if not 'sdist' in sys.argv:
    sys.exit('\n*** Please install the `scikit-image` package '
            '(instead of `skimage`) ***\n')

from setuptools import setup

setup(
    name='skimage',
    version='0.0',
    description='Dummy package that points to scikit-image',
    url='https://github.com/scikit-image/scikit-image',
    author='Stefan van der Walt',
    author_email='stefanv@berkeley.edu'
)

So this case is kinda specific to skimage. Not sure about other more generic cases where locking succeeds but install fails: should the project be listed in pyproject.toml? I don't know.