From 3e67fc775e93166600c84a5183ab6a86afff84b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 20 May 2024 22:51:02 +0200 Subject: [PATCH 1/5] Work around `platform.python_version()` returning non PEP 440 compliant version for non-tagged CPython builds (#802) --- src/packaging/markers.py | 6 ++++++ tests/test_markers.py | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/packaging/markers.py b/src/packaging/markers.py index 2d60bdf2..7ac7bb69 100644 --- a/src/packaging/markers.py +++ b/src/packaging/markers.py @@ -309,6 +309,12 @@ def evaluate(self, environment: dict[str, str] | None = None) -> bool: """ current_environment = cast("dict[str, str]", default_environment()) current_environment["extra"] = "" + # Work around platform.python_version() returning something that is not PEP 440 + # compliant for non-tagged Python builds. We preserve default_environment()'s + # behavior of returning platform.python_version() verbatim, and leave it to the + # caller to provide a syntactically valid version if they want to override it. + if current_environment["python_full_version"].endswith("+"): + current_environment["python_full_version"] += "local" if environment is not None: current_environment.update(environment) # The API used to allow setting extra to None. We need to handle this diff --git a/tests/test_markers.py b/tests/test_markers.py index a2f92b30..775b51fd 100644 --- a/tests/test_markers.py +++ b/tests/test_markers.py @@ -8,6 +8,7 @@ import platform import sys from typing import cast +from unittest import mock import pytest @@ -19,6 +20,7 @@ default_environment, format_full_version, ) +from packaging.version import InvalidVersion VARIABLES = [ "extra", @@ -384,3 +386,14 @@ def test_extra_str_normalization(self): assert str(Marker(lhs)) == f'"{normalized_name}" == extra' assert str(Marker(rhs)) == f'extra == "{normalized_name}"' + + def test_python_full_version_untagged_user_provided(self): + """A user-provided python_full_version ending with a + fails to parse.""" + with pytest.raises(InvalidVersion): + Marker("python_full_version < '3.12'").evaluate( + {"python_full_version": "3.11.1+"} + ) + + def test_python_full_version_untagged(self): + with mock.patch("platform.python_version", return_value="3.11.1+"): + assert Marker("python_full_version < '3.12'").evaluate() From 85442b8032cb7bae72866dfd7782234a98dd2fb7 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Mon, 10 Jun 2024 00:18:48 +0100 Subject: [PATCH 2/5] Bump for release --- CHANGELOG.rst | 4 ++-- src/packaging/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c0d78f86..afc671bb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,8 +1,8 @@ Changelog --------- -*unreleased* -~~~~~~~~~~~~ +24.1 - 2024-06-10 +~~~~~~~~~~~~~~~~~ No unreleased changes. diff --git a/src/packaging/__init__.py b/src/packaging/__init__.py index 658836a9..9ba41d83 100644 --- a/src/packaging/__init__.py +++ b/src/packaging/__init__.py @@ -6,7 +6,7 @@ __summary__ = "Core utilities for Python packages" __uri__ = "https://github.com/pypa/packaging" -__version__ = "24.1.dev0" +__version__ = "24.1" __author__ = "Donald Stufft and individual contributors" __email__ = "donald@stufft.io" From 88b6be43eba94f43477bb7a77817e97669d430df Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Mon, 10 Jun 2024 00:18:49 +0100 Subject: [PATCH 3/5] Bump for development --- CHANGELOG.rst | 5 +++++ src/packaging/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index afc671bb..620ee1b8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ Changelog --------- +*unreleased* +~~~~~~~~~~~~ + +No unreleased changes. + 24.1 - 2024-06-10 ~~~~~~~~~~~~~~~~~ diff --git a/src/packaging/__init__.py b/src/packaging/__init__.py index 9ba41d83..9c054695 100644 --- a/src/packaging/__init__.py +++ b/src/packaging/__init__.py @@ -6,7 +6,7 @@ __summary__ = "Core utilities for Python packages" __uri__ = "https://github.com/pypa/packaging" -__version__ = "24.1" +__version__ = "24.2.dev0" __author__ = "Donald Stufft and individual contributors" __email__ = "donald@stufft.io" From 209de2db1f62a672d2190e47a80612895380cdbc Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 15 Jun 2024 01:46:01 +0200 Subject: [PATCH 4/5] The source is auto-formatted with ruff, not black (#798) I had forgotten to change that in cb8fd38. Co-authored-by: Brett Cannon --- docs/development/submitting-patches.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/development/submitting-patches.rst b/docs/development/submitting-patches.rst index d05637a6..79536458 100644 --- a/docs/development/submitting-patches.rst +++ b/docs/development/submitting-patches.rst @@ -18,7 +18,7 @@ follow the directions on the :doc:`security page `. Code ---- -This project's source is auto-formatted with |black|. You can check if your +This project's source is auto-formatted with |ruff|. You can check if your code meets our requirements by running our linters against it with ``nox -s lint`` or ``pre-commit run --all-files``. @@ -67,8 +67,8 @@ So, specifically: * Use Sphinx parameter/attribute documentation `syntax`_. -.. |black| replace:: ``black`` -.. _black: https://pypi.org/project/black/ +.. |ruff| replace:: ``ruff`` +.. _ruff: https://astral.sh/ruff .. _`Write comments as complete sentences.`: https://nedbatchelder.com/blog/201401/comments_should_be_sentences.html .. _`syntax`: https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html .. _`Studies have shown`: https://www.microsoft.com/en-us/research/publication/characteristics-of-useful-code-reviews-an-empirical-study-at-microsoft/ From 793ee28b4c70886e8de5731e24e444388916b3ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:30:46 -0700 Subject: [PATCH 5/5] Bump the github-actions group across 1 directory with 3 updates (#813) Bumps the github-actions group with 3 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [github/codeql-action](https://github.com/github/codeql-action) and [actions/upload-artifact](https://github.com/actions/upload-artifact). Updates `actions/checkout` from 4.1.2 to 4.1.7 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/9bb56186c3b09b4f86b1c65136769dd318469633...692973e3d937129bcbf40652eb9f2f61becf3332) Updates `github/codeql-action` from 3.24.9 to 3.25.11 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/1b1aada464948af03b950897e5eb522f92603cc2...b611370bb5703a7efb587f9d136a52ea24c5c38c) Updates `actions/upload-artifact` from 4.3.1 to 4.3.3 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/5d5d22a31266ced268874388b861e4b58bb5c2f3...65462800fd760344b1a7b4382951275a0abb4808) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeql.yml | 8 ++++---- .github/workflows/docs.yml | 2 +- .github/workflows/lint.yml | 6 +++--- .github/workflows/test.yml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9c94ae31..a697274b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -31,11 +31,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 + uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -47,9 +47,9 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - name: Autobuild - uses: github/codeql-action/autobuild@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 + uses: github/codeql-action/autobuild@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 + uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1480b2aa..3f6b4c4d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 name: Install Python diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 444eb796..aa975c96 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 name: Install Python @@ -46,13 +46,13 @@ jobs: needs: lint steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Build run: pipx run build - name: Archive files - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: dist path: dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b20b071e..b75d9e50 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.8", "pypy3.9", "pypy3.10"] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 name: Install Python ${{ matrix.python_version }}