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

pyproject.toml better management idea #2862

Open
darkworks opened this issue Apr 30, 2024 · 9 comments
Open

pyproject.toml better management idea #2862

darkworks opened this issue Apr 30, 2024 · 9 comments
Labels
⭐ enhancement Improvements for existing features

Comments

@darkworks
Copy link

darkworks commented Apr 30, 2024

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

@darkworks darkworks added the ⭐ enhancement Improvements for existing features label Apr 30, 2024
@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Apr 30, 2024

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
Copy link
Collaborator

frostming commented Apr 30, 2024

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.

@darkworks
Copy link
Author

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
Copy link
Author

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
Copy link
Author

darkworks commented Apr 30, 2024

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

  • 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

cd project_dir
pdm install
pdm run src/project_name/__init__.py

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Apr 30, 2024

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)?

@goyalyashpal
Copy link

  • 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
Copy link
Author

darkworks commented May 6, 2024

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 .

  • can you pls retest the 2nd issue i highlighted

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
Copy link
Sponsor Contributor

pawamoy commented May 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐ enhancement Improvements for existing features
Projects
None yet
Development

No branches or pull requests

4 participants