Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Requires-python checks don't work with pre-release Python versions #2034

Closed
freakboy3742 opened this issue Oct 15, 2024 · 3 comments · Fixed by #2035
Closed

Requires-python checks don't work with pre-release Python versions #2034

freakboy3742 opened this issue Oct 15, 2024 · 3 comments · Fixed by #2035
Labels
bug A crash or error in behavior.

Comments

@freakboy3742
Copy link
Member

freakboy3742 commented Oct 15, 2024

Describe the bug

#2029 added support for PEP 621 requires-python declarations. However, these version checks appear to always fail if the Python version is a prerelease.

Steps to reproduce

  1. Use a prerelease Python (e.g. 3.13.0.rc2, or 3.14.0a1)
  2. Run the Briefcase test suite.

In this CI run, using Python 3.14.0a1, there are 4 test failures:

=========================== short test summary info ============================
FAILED tests/commands/base/test_verify_requires_python.py::test_requires_python_met[!= 3.2] - briefcase.exceptions.UnsupportedPythonVersion: Unable to run Briefcase command. The project configuration requires Python versions != 3.2, but the environment's Python version is 3.14.0a0. Please run Briefcase using a Python version that satisfies the project's requirements.
FAILED tests/commands/base/test_verify_requires_python.py::test_requires_python_met[>= 3.2] - briefcase.exceptions.UnsupportedPythonVersion: Unable to run Briefcase command. The project configuration requires Python versions >= 3.2, but the environment's Python version is 3.14.0a0. Please run Briefcase using a Python version that satisfies the project's requirements.
FAILED tests/commands/base/test_verify_requires_python.py::test_requires_python_met[> 3.2] - briefcase.exceptions.UnsupportedPythonVersion: Unable to run Briefcase command. The project configuration requires Python versions > 3.2, but the environment's Python version is 3.14.0a0. Please run Briefcase using a Python version that satisfies the project's requirements.
FAILED tests/commands/base/test_verify_requires_python.py::test_requires_python_met[< 3.100] - briefcase.exceptions.UnsupportedPythonVersion: Unable to run Briefcase command. The project configuration requires Python versions < 3.100, but the environment's Python version is 3.14.0a0. Please run Briefcase using a Python version that satisfies the project's requirements.

Expected behavior

3.14.0a1 should pass requires-python checks that require !=3.2, >3.2, and <3.100.

Screenshots

No response

Environment

  • Operating System: Any
  • Python version: Any pre-release version (3.14.0a1 tested)
  • Software versions:
    • Briefcase: 0.3.20+

Logs


Additional context

This came up in the context of trying to add Python 3.14 to Briefcase's CI matrix.

@freakboy3742 freakboy3742 added the bug A crash or error in behavior. label Oct 15, 2024
@freakboy3742
Copy link
Member Author

Tagging @sarayourfriend since you were working on this recently; no obligation to look into it, but if you've got the interest and spare cycles.

@sarayourfriend
Copy link
Contributor

Interesting! I think it will be an easy fix by passing preeleases=True to spec.contains. I'll try that out and open a PR here shortly if it works.

@sarayourfriend
Copy link
Contributor

I'll drop a note here to the PyPA docs on pre-release handling in version specifiers, because the defaults/intentions here were new to me: https://packaging.python.org/en/latest/specifications/version-specifiers/#handling-of-pre-releases

It's somewhat different for Briefcase's requires-python check because it isn't trying to resolve a particular version of a dependency, rather just checking that the active one matches the specifier. In that case, "accept already installed pre-releases for all version specifiers" from the set of default behaviours makes sense to follow.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants