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

fix: PDM fails running a script with PEP723 metadata with uv #3383

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/3382.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a dummy project name to the script environment pyproject.toml.
2 changes: 1 addition & 1 deletion src/pdm/cli/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _get_script_env(self, script_file: str) -> BaseEnvironment:
return self.project.environment
tool_config = metadata.pop("tool", {})
script_project = self.project.core.create_project()
script_project.pyproject.set_data({"project": metadata, "tool": tool_config})
script_project.pyproject.set_data({"project": {"name": "temp-project", **metadata}, "tool": tool_config})
md5_kwargs = {"usedforsecurity": False}
venv_name = hashlib.md5(os.path.realpath(script_file).encode("utf-8"), **md5_kwargs).hexdigest()
venv_backend = BACKENDS[script_project.config["venv.backend"]](script_project, None)
Expand Down
1 change: 1 addition & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def get_python_versions():
def test_basic_integration(python_version, core, tmp_path, pdm):
"""An e2e test case to ensure PDM works on all supported Python versions"""
project = core.create_project(tmp_path)
project.project_config["python.use_venv"] = True
project.pyproject.set_data(PYPROJECT)
project.root.joinpath("foo.py").write_text("import django\n")
project._environment = None
Expand Down
Loading