From 5f0dc7e6b3e7fbdd38f700fd02f25c8f2ffd4cac Mon Sep 17 00:00:00 2001 From: Vitaly Samigullin Date: Sat, 25 Feb 2023 12:49:51 +0100 Subject: [PATCH] Allow pre-release versions for Python native packages in case of == and === specifiers (#133) --- CHANGELOG.md | 10 +++++++++- project.clj | 2 +- src/pip_license_checker/version.clj | 13 ++++++++++--- test/pip_license_checker/version_test.clj | 16 +++++++++++++++- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f33c4be..cb0c091 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ This change log follows the conventions of [keepachangelog.com](http://keepachan ## [Unreleased] +## [0.44.0] - 2023-02-25 + +### Fixed +- Allow pre-release versions for Python native packages in case of + exact equal (`==`) or arbitrary string equal (`===`) specifiers + ([#132](https://github.com/pilosus/pip-license-checker/issues/132)) + ## [0.43.0] - 2023-02-10 ### Fixed @@ -406,7 +413,8 @@ weak copyleft types. ### Added - Structure for Leiningen app project -[Unreleased]: https://github.com/pilosus/pip-license-checker/compare/0.43.0...HEAD +[Unreleased]: https://github.com/pilosus/pip-license-checker/compare/0.44.0...HEAD +[0.44.0]: https://github.com/pilosus/pip-license-checker/compare/0.43.0...0.44.0 [0.43.0]: https://github.com/pilosus/pip-license-checker/compare/0.42.1...0.43.0 [0.42.1]: https://github.com/pilosus/pip-license-checker/compare/0.42.0...0.42.1 [0.42.0]: https://github.com/pilosus/pip-license-checker/compare/0.42.0-SNAPSHOT...0.42.0 diff --git a/project.clj b/project.clj index b53bad7..f7b2119 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.pilosus/pip-license-checker "0.43.1-SNAPSHOT" +(defproject org.pilosus/pip-license-checker "0.44.0" :description "License compliance tool to identify dependencies license names and types: permissive, copyleft, proprietory, etc." :url "https://github.com/pilosus/pip-license-checker" :license {:name "Eclipse Public License 2.0 OR GNU GPL v2+ with Classpath exception" diff --git a/src/pip_license_checker/version.clj b/src/pip_license_checker/version.clj index 055a035..52a92b3 100644 --- a/src/pip_license_checker/version.clj +++ b/src/pip_license_checker/version.clj @@ -501,22 +501,29 @@ result (and version-not-pre? version-not-dev?)] result)) +(defn- contains-eq-specifier? + "Return true if the specifiers vector contains `==` or `===`" + [specifiers] + (some #(contains? #{eq arbitrary-eq} (first %)) specifiers)) + (defn remove-yanked-versions "Remove yanked versions for non-exact specifiers" [specifiers versions] - (if (some #(contains? #{eq arbitrary-eq} (first %)) specifiers) + (if (contains-eq-specifier? specifiers) versions (remove #(= (get-in % [:meta :yanked]) true) versions))) (defn filter-versions "Return lazy seq of parsed versions that satisfy specifiers" [specifiers versions & {:keys [pre] :or {pre true}}] - (let [versions' + (let [pre-release-included? + (or pre (contains-eq-specifier? specifiers)) + versions' (->> versions (filter #(version-ok? specifiers %)) (remove-yanked-versions specifiers))] - (if pre + (if pre-release-included? versions' (filter version-stable? versions')))) diff --git a/test/pip_license_checker/version_test.clj b/test/pip_license_checker/version_test.clj index af3e6b0..221a1f2 100644 --- a/test/pip_license_checker/version_test.clj +++ b/test/pip_license_checker/version_test.clj @@ -314,7 +314,21 @@ ["1.48.2" {:yanked false}]] false ["1.48.0"] - "use yanked version for arbitrary-string equal specifier"]]) + "use yanked version for arbitrary-string equal specifier"] + [[["==" "0.0.2a32"]] + [["0.0.1" {:yanked false}] + ["0.0.2a32" {:yanked false}] + ["0.0.3" {:yanked false}]] + false + ["0.0.2a32"] + "use pre-release version for exact equal specifier with --no-pre option"] + [[["===" "0.0.2a32"]] + [["0.0.1" {:yanked false}] + ["0.0.2a32" {:yanked false}] + ["0.0.3" {:yanked false}]] + false + ["0.0.2a32"] + "use pre-release version for arbitrary-string equal specifier with --no-pre option"]]) (deftest test-filter-versions (testing "Check versions filtering"