Skip to content

Commit d630e3e

Browse files
committed
🚧 respect pip-constraints while creating sdists
1 parent 66f1f33 commit d630e3e

7 files changed

+405
-247
lines changed

‎.pre-commit-config.yaml

+45-44
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
4-
hooks:
5-
- id: check-ast
6-
- id: check-case-conflict
7-
- id: check-executables-have-shebangs
8-
- id: check-json
9-
- id: check-merge-conflict
10-
- id: check-shebang-scripts-are-executable
11-
- id: check-symlinks
12-
- id: check-toml
13-
- id: check-yaml
14-
- id: destroyed-symlinks
15-
- id: end-of-file-fixer
16-
- id: fix-byte-order-marker
17-
- id: mixed-line-ending
18-
- id: pretty-format-json
19-
args: [--autofix, --no-ensure-ascii, --no-sort-keys]
20-
- id: trailing-whitespace
21-
args: [--markdown-linebreak-ext=md]
22-
- repo: https://github.com/Lucas-C/pre-commit-hooks
23-
rev: v1.5.4
24-
hooks:
25-
- id: remove-tabs
26-
exclude: ^an_website/static/humans.txt$
27-
- id: insert-license
28-
files: ^.+\.py$
29-
args:
30-
- --license-filepath
31-
- license_header.txt # defaults to: LICENSE.txt
32-
#- id: insert-license
33-
# files: \*\.css$
34-
# args:
35-
# - --license-filepath
36-
# - license_header.txt # defaults to: LICENSE.txt
37-
# - --comment-style
38-
# - /*| *| */ # defaults to: #
39-
#- id: insert-license
40-
# files: \*\.html$
41-
# args:
42-
# - --license-filepath
43-
# - license_header.txt # defaults to: LICENSE.txt
44-
# - --comment-style
45-
# - '{#||#}' # defaults to: #
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: check-ast
6+
- id: check-case-conflict
7+
- id: check-executables-have-shebangs
8+
- id: check-json
9+
- id: check-merge-conflict
10+
- id: check-shebang-scripts-are-executable
11+
- id: check-symlinks
12+
- id: check-toml
13+
- id: check-yaml
14+
- id: destroyed-symlinks
15+
- id: end-of-file-fixer
16+
- id: fix-byte-order-marker
17+
- id: mixed-line-ending
18+
- id: pretty-format-json
19+
args: [--autofix, --no-ensure-ascii, --no-sort-keys]
20+
exclude: ^Pipfile.lock$
21+
- id: trailing-whitespace
22+
args: [--markdown-linebreak-ext=md]
23+
- repo: https://github.com/Lucas-C/pre-commit-hooks
24+
rev: v1.5.4
25+
hooks:
26+
- id: remove-tabs
27+
exclude: ^an_website/static/humans.txt$
28+
- id: insert-license
29+
files: ^.+\.py$
30+
args:
31+
- --license-filepath
32+
- license_header.txt # defaults to: LICENSE.txt
33+
#- id: insert-license
34+
# files: \*\.css$
35+
# args:
36+
# - --license-filepath
37+
# - license_header.txt # defaults to: LICENSE.txt
38+
# - --comment-style
39+
# - /*| *| */ # defaults to: #
40+
#- id: insert-license
41+
# files: \*\.html$
42+
# args:
43+
# - --license-filepath
44+
# - license_header.txt # defaults to: LICENSE.txt
45+
# - --comment-style
46+
# - '{#||#}' # defaults to: #

‎Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ types-regex = "==2024.11.6.*"
101101
types-setuptools = "==70.*"
102102
types-zstd = "==1.*"
103103
zopflipy = "==1.*"
104+
zstd = "==1.*"

‎Pipfile.lock

+322-182
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pip-constraints.txt

+9-8
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ cfgv==3.4.0
1111
charset-normalizer==3.4.1
1212
click==8.1.8
1313
coverage==7.6.12
14-
cryptography==44.0.1
14+
cryptography==44.0.2
1515
dill==0.3.9
1616
distlib==0.3.9
1717
docutils==0.21.2
18-
dulwich==0.22.7
18+
dulwich==0.22.8
1919
faker==22.7.0
2020
filelock==3.17.0
2121
flake8==7.1.2
@@ -86,7 +86,7 @@ tornado==6.4.2
8686
trove-classifiers==2024.10.16
8787
twine==6.1.0
8888
types-beautifulsoup4==4.12.0.20250204
89-
types-cffi==1.16.0.20241221
89+
types-cffi==1.16.0.20250307
9090
types-emoji==2.1.0.3
9191
types-html5lib==1.1.11.20241018
9292
types-lxml==2023.10.21
@@ -97,17 +97,18 @@ types-pyopenssl==24.1.0.20240722
9797
types-python-dateutil==2.9.0.20241206
9898
types-pyyaml==6.0.12.20241230
9999
types-redis==4.6.0.20241004
100-
types-regex==2024.11.6.20241221
100+
types-regex==2024.11.6.20250305
101101
types-setuptools==70.3.0.20240710
102-
types-zstd==1.5.6.4.20250224
102+
types-zstd==1.5.6.6.20250306
103103
typing-extensions==4.12.2
104104
urllib3==2.3.0
105-
virtualenv==20.29.2
105+
virtualenv==20.29.3
106106
webencodings==0.5.1
107107
zopflipy==1.11
108+
zstd==1.5.6.6
108109
accept-types==0.4.1
109110
aiodns==3.2.0
110-
aiohappyeyeballs==2.4.6
111+
aiohappyeyeballs==2.5.0
111112
aiohttp==3.11.13
112113
aiosignal==1.3.2
113114
ansi2html==1.9.2
@@ -147,7 +148,7 @@ pysocks==1.7.1
147148
python-geoip-geolite2-yplan==2019.1224
148149
python-geoip-yplan==1.2
149150
pytz==2025.1
150-
rapidfuzz==3.12.1
151+
rapidfuzz==3.12.2
151152
redis==5.2.1
152153
regex==2024.11.6
153154
setproctitle==1.3.5

‎pip-dev-requirements.txt

+9-8
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ cfgv==3.4.0; python_version >= '3.8'
1111
charset-normalizer==3.4.1; python_version >= '3.7'
1212
click==8.1.8; python_version >= '3.7'
1313
coverage[toml]==7.6.12; python_version >= '3.9'
14-
cryptography==44.0.1; python_version >= '3.7' and python_full_version not in '3.9.0, 3.9.1'
14+
cryptography==44.0.2; python_version >= '3.7' and python_full_version not in '3.9.0, 3.9.1'
1515
dill==0.3.9; python_version >= '3.8'
1616
distlib==0.3.9
1717
docutils==0.21.2; python_version >= '3.9'
18-
dulwich==0.22.7; python_version >= '3.9'
18+
dulwich==0.22.8; python_version >= '3.9'
1919
faker==22.7.0; python_version >= '3.8'
2020
filelock==3.17.0; python_version >= '3.9'
2121
flake8==7.1.2; python_full_version >= '3.8.1'
@@ -86,7 +86,7 @@ tornado==6.4.2; python_version >= '3.8'
8686
trove-classifiers==2024.10.16
8787
twine==6.1.0; python_version >= '3.8'
8888
types-beautifulsoup4==4.12.0.20250204; python_version >= '3.9'
89-
types-cffi==1.16.0.20241221; python_version >= '3.8'
89+
types-cffi==1.16.0.20250307; python_version >= '3.9'
9090
types-emoji==2.1.0.3
9191
types-html5lib==1.1.11.20241018; python_version >= '3.8'
9292
types-lxml==2023.10.21; python_version >= '3.8'
@@ -97,17 +97,18 @@ types-pyopenssl==24.1.0.20240722; python_version >= '3.8'
9797
types-python-dateutil==2.9.0.20241206; python_version >= '3.8'
9898
types-pyyaml==6.0.12.20241230; python_version >= '3.8'
9999
types-redis==4.6.0.20241004; python_version >= '3.8'
100-
types-regex==2024.11.6.20241221; python_version >= '3.8'
100+
types-regex==2024.11.6.20250305; python_version >= '3.9'
101101
types-setuptools==70.3.0.20240710; python_version >= '3.8'
102-
types-zstd==1.5.6.4.20250224; python_version >= '3.9'
102+
types-zstd==1.5.6.6.20250306; python_version >= '3.9'
103103
typing-extensions==4.12.2; python_version >= '3.8'
104104
urllib3==2.3.0; python_version >= '3.9'
105-
virtualenv==20.29.2; python_version >= '3.8'
105+
virtualenv==20.29.3; python_version >= '3.8'
106106
webencodings==0.5.1
107107
zopflipy==1.11; python_version >= '3.9'
108+
zstd==1.5.6.6
108109
accept-types==0.4.1
109110
aiodns==3.2.0
110-
aiohappyeyeballs==2.4.6; python_version >= '3.9'
111+
aiohappyeyeballs==2.5.0; python_version >= '3.9'
111112
aiohttp[speedups]==3.11.13; python_version >= '3.9'
112113
aiosignal==1.3.2; python_version >= '3.9'
113114
ansi2html==1.9.2; python_version >= '3.7'
@@ -147,7 +148,7 @@ pysocks==1.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2
147148
python-geoip-geolite2-yplan==2019.1224
148149
python-geoip-yplan==1.2
149150
pytz==2025.1
150-
rapidfuzz==3.12.1; python_version >= '3.9'
151+
rapidfuzz==3.12.2; python_version >= '3.9'
151152
redis[hiredis]==5.2.1; python_version >= '3.8'
152153
regex==2024.11.6; python_version >= '3.8'
153154
setproctitle==1.3.5; python_version >= '3.8'

‎pip-requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
accept-types==0.4.1
22
aiodns==3.2.0
3-
aiohappyeyeballs==2.4.6; python_version >= '3.9'
3+
aiohappyeyeballs==2.5.0; python_version >= '3.9'
44
aiohttp[speedups]==3.11.13; python_version >= '3.9'
55
aiosignal==1.3.2; python_version >= '3.9'
66
ansi2html==1.9.2; python_version >= '3.7'
@@ -49,7 +49,7 @@ python-geoip-geolite2-yplan==2019.1224
4949
python-geoip-yplan==1.2
5050
pytz==2025.1
5151
pyyaml==6.0.2; python_version >= '3.8'
52-
rapidfuzz==3.12.1; python_version >= '3.9'
52+
rapidfuzz==3.12.2; python_version >= '3.9'
5353
redis[hiredis]==5.2.1; python_version >= '3.8'
5454
regex==2024.11.6; python_version >= '3.8'
5555
setproctitle==1.3.5; python_version >= '3.8'

‎scripts/compress_static_files.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_missing_dependencies(self) -> Iterable[str]:
9797
import zopfli # noqa: F401
9898
except ModuleNotFoundError as exc:
9999
assert exc.name == "zopfli"
100-
yield "zopflipy==1.11"
100+
yield "zopflipy"
101101

102102

103103
class ZstdFileCompressor(FileCompressor):
@@ -127,7 +127,7 @@ def get_missing_dependencies(self) -> Iterable[str]:
127127
import zstd # noqa: F401
128128
except ModuleNotFoundError as exc:
129129
assert exc.name == "zstd"
130-
yield "zstd==1.5.6.2"
130+
yield "zstd"
131131

132132

133133
def compress_dir(
@@ -158,10 +158,24 @@ def get_compressors() -> Collection[FileCompressor]:
158158
return ZstdFileCompressor(), GzipFileCompressor()
159159

160160

161+
def _get_constraints() -> list[str]:
162+
"""Get the constraints for the libraries."""
163+
# TODO: parse properly with packaging
164+
file = Path(__file__).absolute().parent.parent / "pip-constraints.txt"
165+
return file.read_text().splitlines()
166+
167+
161168
def get_missing_dependencies() -> Iterable[str]:
162169
"""Get the missing dependencies."""
170+
constraints = _get_constraints()
163171
for compressor in get_compressors():
164-
yield from compressor.get_missing_dependencies()
172+
for dep in compressor.get_missing_dependencies():
173+
for const in constraints:
174+
if const.startswith(f"{dep}=="):
175+
yield const
176+
break
177+
else:
178+
raise AssertionError(f"Could not get version of {dep}")
165179

166180

167181
def compress_static_files() -> Iterable[CompressionResult]:

0 commit comments

Comments
 (0)