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

PEP 723 support is faulty: uses wrong TOML field name #1187

Closed
flying-sheep opened this issue Jan 4, 2024 · 5 comments
Closed

PEP 723 support is faulty: uses wrong TOML field name #1187

flying-sheep opened this issue Jan 4, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@flying-sheep
Copy link
Contributor

Describe the bug
#1100 implemented PEP 723 wrong:

for requirement in pyproject.get("run", {}).get("requirements", []):

this should be "dependencies", not "requirements".

How to reproduce

Create a PEP 723 compliant script:

#!/usr/bin/env -S pipx run
# /// pyproject
# run.dependencies = ["httpx"]
# ///
import httpx

and run it using pipx run ./script.py. You’ll see

Traceback (most recent call last):
  File "<string>", line 11, in <module>
ModuleNotFoundError: No module named 'requests'

Expected behavior

pipx should run it in a temporary environment.

Also the traceback should contain the file name, not <string>

@dukecat0
Copy link
Member

dukecat0 commented Jan 4, 2024

Fixed in #1180.

@flying-sheep
Copy link
Contributor Author

Ah, indeed. I searched the issues, but apparently not the PRs

@dukecat0
Copy link
Member

dukecat0 commented Jan 4, 2024

Also the traceback should contain the file name, not <string>

However, I think this issue still exists.

@maxwell-k
Copy link
Contributor

The example in the issue report is unfortunately also out of date the most recent change to PEP 723 was to change:

-# /// pyproject
+# /// script

I don't want to write an example and risk getting it wrong myself, instead I will point to the example in the PEP
https://peps.python.org/pep-0723/#how-to-teach-this

For the background on this change please see https://discuss.python.org/t/how-would-you-like-to-declare-runtime-dependencies-and-python-requirements-for-pep-723/40418/70

@henryiii
Copy link
Contributor

henryiii commented Jan 5, 2024

@maxwell-k this is also fixed in #1180.

@chrysle chrysle added the bug Something isn't working label Jan 12, 2024
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

5 participants