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

Never ignore URL dependencies in PEP 723 noxfiles #935

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions nox/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def check_dependencies(dependencies: list[str]) -> bool:
version = importlib.metadata.version(dep.name)
if not dep.specifier.contains(version):
return False
if dep.url:
return False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could make this smarter, given the suggestion in build and importlib.metadata's .origin?


return True

Expand Down
14 changes: 14 additions & 0 deletions tests/resources/noxfile_script_mode_url_req.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# /// script
# dependencies = ["nox @ git+https://github.com/wntrblm/[email protected]"]
# ///

# The Nox version pinned above should be the second-most-recent version or older.

import importlib.metadata

import nox


@nox.session(python=False)
def example(session: nox.Session) -> None:
print(importlib.metadata.version("nox"))
22 changes: 22 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,3 +1065,25 @@ def test_noxfile_no_script_mode() -> None:
)
assert job.returncode == 1
assert "No module named 'cowsay'" in job.stderr


def test_noxfile_script_mode_url_req() -> None:
job = subprocess.run(
[
sys.executable,
"-m",
"nox",
"-f",
Path(RESOURCES) / "noxfile_script_mode_url_req.py",
"-s",
"example",
],
check=False,
capture_output=True,
text=True,
encoding="utf-8",
)
print(job.stdout)
print(job.stderr)
assert job.returncode == 0
assert job.stdout.rstrip() == "2024.10.9"
Loading