Skip to content

Commit a995607

Browse files
committed
Fix parsing of requirements.txt entries that aren't using '==' specifiers
1 parent 6a1e8c4 commit a995607

File tree

6 files changed

+32
-128
lines changed

6 files changed

+32
-128
lines changed

THIRDPARTYLICENSES

Lines changed: 2 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Start of 'THIRDPARTYLICENSES' generated by Python third_party_license_generator at 2025-06-18 04:59:56.875233
1+
Start of 'THIRDPARTYLICENSES' generated by Python third_party_license_generator at 2025-06-18 13:53:21.492828
22

33
----------------------------------------
44

@@ -60,36 +60,6 @@ one at http://mozilla.org/MPL/2.0/.
6060

6161
----------------------------------------
6262

63-
Package: charset-normalizer
64-
License: MIT
65-
Requires: n/a
66-
Author: (unknown) <"Ahmed R. TAHRI" <tahri.ahmed@proton.me>>
67-
Home page: None
68-
69-
MIT License
70-
71-
Copyright (c) 2025 TAHRI Ahmed R.
72-
73-
Permission is hereby granted, free of charge, to any person obtaining a copy
74-
of this software and associated documentation files (the "Software"), to deal
75-
in the Software without restriction, including without limitation the rights
76-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77-
copies of the Software, and to permit persons to whom the Software is
78-
furnished to do so, subject to the following conditions:
79-
80-
The above copyright notice and this permission notice shall be included in all
81-
copies or substantial portions of the Software.
82-
83-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
84-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
85-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
86-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
87-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
88-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
89-
SOFTWARE.
90-
91-
----------------------------------------
92-
9363
Package: idna
9464
License: BSD-3-clause
9565
Requires: n/a
@@ -130,35 +100,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
130100

131101
----------------------------------------
132102

133-
Package: pip
134-
License: MIT
135-
Requires: n/a
136-
Author: The pip developers <distutils-sig@python.org>
137-
Home page: https://pip.pypa.io/
138-
139-
Copyright (c) 2008-present The pip developers (see AUTHORS.txt file)
140-
141-
Permission is hereby granted, free of charge, to any person obtaining
142-
a copy of this software and associated documentation files (the
143-
"Software"), to deal in the Software without restriction, including
144-
without limitation the rights to use, copy, modify, merge, publish,
145-
distribute, sublicense, and/or sell copies of the Software, and to
146-
permit persons to whom the Software is furnished to do so, subject to
147-
the following conditions:
148-
149-
The above copyright notice and this permission notice shall be
150-
included in all copies or substantial portions of the Software.
151-
152-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
153-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
154-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
155-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
156-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
157-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
158-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
159-
160-
----------------------------------------
161-
162103
Package: requests
163104
License: Apache-2.0
164105
Requires: charset_normalizer, idna, urllib3, certifi
@@ -342,34 +283,6 @@ Apache License
342283

343284
----------------------------------------
344285

345-
Package: setuptools
346-
License: MIT
347-
Requires: n/a
348-
Author: Python Packaging Authority <distutils-sig@python.org>
349-
Home page: https://github.com/pypa/setuptools
350-
351-
Copyright Jason R. Coombs
352-
353-
Permission is hereby granted, free of charge, to any person obtaining a copy
354-
of this software and associated documentation files (the "Software"), to
355-
deal in the Software without restriction, including without limitation the
356-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
357-
sell copies of the Software, and to permit persons to whom the Software is
358-
furnished to do so, subject to the following conditions:
359-
360-
The above copyright notice and this permission notice shall be included in
361-
all copies or substantial portions of the Software.
362-
363-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
364-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
365-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
366-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
367-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
368-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
369-
IN THE SOFTWARE.
370-
371-
----------------------------------------
372-
373286
Package: urllib3
374287
License: MIT
375288
Requires: n/a
@@ -400,34 +313,4 @@ SOFTWARE.
400313

401314
----------------------------------------
402315

403-
Package: wheel
404-
License: MIT
405-
Requires: n/a
406-
Author: (unknown) <Daniel Holth <dholth@fastmail.fm>>
407-
Home page: None
408-
409-
MIT License
410-
411-
Copyright (c) 2012 Daniel Holth <dholth@fastmail.fm> and contributors
412-
413-
Permission is hereby granted, free of charge, to any person obtaining a
414-
copy of this software and associated documentation files (the "Software"),
415-
to deal in the Software without restriction, including without limitation
416-
the rights to use, copy, modify, merge, publish, distribute, sublicense,
417-
and/or sell copies of the Software, and to permit persons to whom the
418-
Software is furnished to do so, subject to the following conditions:
419-
420-
The above copyright notice and this permission notice shall be included
421-
in all copies or substantial portions of the Software.
422-
423-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
424-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
425-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
426-
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
427-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
428-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
429-
OTHER DEALINGS IN THE SOFTWARE.
430-
431-
----------------------------------------
432-
433-
End of 'THIRDPARTYLICENSES' generated by Python third_party_license_generator at 2025-06-18 04:59:56.875292
316+
End of 'THIRDPARTYLICENSES' generated by Python third_party_license_generator at 2025-06-18 13:53:21.493234

build-tag-and-push.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ fi
1414

1515
docker build --build-arg "VERSION=${python_version}" -f ./Dockerfile -t "${image}" .
1616

17-
docker run --rm --name "${container}" -v "${HOME}/.pypirc:/root/.pypirc" --workdir "/srv/python-third-party-license-file-generator" --entrypoint bash "${image}" -c "python setup.py sdist && twine upload dist/*"
17+
command="python setup.py sdist && ls -al dist/* && twine upload dist/*"
18+
if [[ "${SKIP_PUSH}" == "1" ]]; then
19+
command="python setup.py sdist && ls -al dist/*"
20+
fi
21+
22+
docker run --rm --name "${container}" -e "VERSION_OVERRIDE=${VERSION}" -v "${HOME}/.pypirc:/root/.pypirc" --workdir "/srv/python-third-party-license-file-generator" --entrypoint bash "${image}" -c "${command}"

check_third_party_licenses.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
with open("THIRDPARTYLICENSES", "r") as f:
2+
data = f.read()
3+
4+
parts = data.split("----------------------------------------\n")
5+
6+
parts = parts[1:-1]
7+
8+
data = "----------------------------------------\n".join(parts).strip()
9+
10+
if not data:
11+
raise AssertionError("THIRDPARTYLICENSES contains no actual licences! (only the header and footer)")

docker-entrypoint.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@ python -u -m third_party_license_file_generator \
88
--do-not-skip-not-required-packages \
99
--permit-gpl
1010

11-
echo ""
12-
1311
if ! test -e THIRDPARTYLICENSES; then
1412
echo "error: couldn't find THIRDPARTYLICENSES- something has gone badly wrong"
1513

1614
exit 1
1715
fi
1816

19-
cat THIRDPARTYLICENSES
20-
21-
echo ""
17+
python3 /srv/python-third-party-license-file-generator/check_third_party_licenses.py

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# To use a consistent encoding
1010
from codecs import open
11-
from os import path
11+
from os import path, getenv
1212

1313
# Always prefer setuptools over distutils
1414
from setuptools import find_packages, setup
@@ -36,7 +36,8 @@
3636
# Versions should comply with PEP440. For a discussion on single-sourcing
3737
# the version across setup.py and the project code, see
3838
# https://packaging.python.org/en/latest/single_source_version.html
39-
version="{}.{}.{}".format(
39+
version=getenv("VERSION_OVERRIDE")
40+
or "{}.{}.{}".format(
4041
now.year,
4142
now.month,
4243
now.day,

third_party_license_file_generator/site_packages.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import shutil
44
import os
5+
import re
56
import shlex
67
import signal
78
import subprocess
@@ -175,7 +176,14 @@ def _read_requirements(self, requirements_path):
175176
elif "--" in line:
176177
continue
177178
else:
178-
self._root_module_names.add(line.split("==")[0].strip())
179+
matches = [x for x in re.finditer(r"(^[\w|-|_]+).*$", line)]
180+
181+
for match in matches:
182+
if not match:
183+
continue
184+
185+
for group in match.groups():
186+
self._root_module_names.add(group)
179187

180188
def _get_site_packages_folder(self):
181189
out, err, returncode = _run_subprocess("{0} -m site".format(self._python_path))

0 commit comments

Comments
 (0)