Skip to content

Commit

Permalink
Fix bdist version parsing (#124)
Browse files Browse the repository at this point in the history
* Fix bdist version parsing

* Refactor version tag parsing; update changelog & project version
  • Loading branch information
pilosus authored Jan 15, 2023
1 parent db9c344 commit e0e139a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ This change log follows the conventions of [keepachangelog.com](http://keepachan

## [Unreleased]

## [0.42.1] - 2023-01-15

### Changed
- Addressed a bug in version parsing for PEP517-non-compliant package
filenames
[#123](https://github.com/pilosus/pip-license-checker/issues/123)

## [0.42.0] - 2023-01-10

### Changed
Expand Down Expand Up @@ -381,7 +388,8 @@ weak copyleft types.
### Added
- Structure for Leiningen app project

[Unreleased]: https://github.com/pilosus/pip-license-checker/compare/0.42.0...HEAD
[Unreleased]: https://github.com/pilosus/pip-license-checker/compare/0.42.1...HEAD
[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
[0.42.0-SNAPSHOT]: https://github.com/pilosus/pip-license-checker/compare/0.41.1...0.42.0-SNAPSHOT
[0.41.1]: https://github.com/pilosus/pip-license-checker/compare/0.41.0...0.41.1
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject org.pilosus/pip-license-checker "0.42.0"
(defproject org.pilosus/pip-license-checker "0.42.1-SNAPSHOT"
: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"
Expand Down
12 changes: 9 additions & 3 deletions src/pip_license_checker/version.clj
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,20 @@
(defmethod get-dist-version :sdist [filename project]
(trim-filename-version filename project))

(defmethod get-dist-version :wheel [filename project]
(defn- get-version-tag
"Get version tag from the filename for eggs and wheels filenames"
[filename project]
(let [tags (-> filename
(trim-filename-version project)
(str/split #"-"))]
(first tags)))

(defmethod get-dist-version :default [filename _]
(first (re-find regex-version filename)))
(defmethod get-dist-version :wheel [filename project]
(get-version-tag filename project))

(defmethod get-dist-version :default [filename project]
(let [version (get-version-tag filename project)]
(first (re-find regex-version version))))

;; version parsing

Expand Down
20 changes: 18 additions & 2 deletions test/pip_license_checker/version_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
"bdist, project name denormalized, filename normalized"]
["Aiohttp-2.0.6-1.zip"
"AIOHTTP"
"2.0.6-1"
"2.0.6"
"bdist, project name denormalized, filename denormalized"]
["Distutils-1.0.12.manilinux.rpm"
"distutils"
Expand All @@ -408,7 +408,23 @@
["test-0.1.2-build-python-abi-platform-nonsuchtag-evenmoretags.whl"
"test"
"0.1.2"
"wheel, broken naming convention"]])
"wheel, broken naming convention"]
["pyasn1-0.4.8-py3.5.egg"
"pyasn1"
"0.4.8"
"egg, project name normilized, filename normalized"]
["iso3166-0.7.zip"
"iso3166"
"0.7"
"zip, project name normilized, filename normalized"]
["pyasn1_modules-0.0.1a-py2.4.egg"
"pyasn1-modules"
"0.0.1a"
"tar gzipped, project name normilized, filename denormalized"]
["pyasn1-modules-0.0.1a.tar.gz"
"pyasn1-modules"
"0.0.1a"
"tar gzipped, project name normilized, filename normalized"]])

(deftest test-get-dist-version
(testing "Get distribution version from the filename"
Expand Down

0 comments on commit e0e139a

Please sign in to comment.