Skip to content

Commit 2a7b728

Browse files
kostyafarberMarcoGorelli
authored andcommitted
ENH: Add pre-commit check for setup.cfg options.extras_require (pandas-dev#49261)
* Add dependency check for setup.cfg * improve diff alert, add install mapping, remove test deps * align versions across min version files * fix version issues for boto3, s3fs and pyqt5. Small change to script * fix version equality, modify script for CI check * fix version typo in min version yaml and update min version script * bump fsspec, gcsfs to match in whats new * Revert "bump fsspec, gcsfs to match in whats new" This reverts commit 52efecb. * align fastparquet, lowercase PyQt5 * ENH: align matplotlib versions * ENH: align matplotlib in setup.cfg * bump s3fs across min version files * Update scripts/validate_min_versions_in_sync.py Co-authored-by: Marco Edward Gorelli <[email protected]> Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent 572c485 commit 2a7b728

File tree

4 files changed

+77
-23
lines changed

4 files changed

+77
-23
lines changed

ci/deps/actions-38-minimum_versions.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies:
3636
- numba=0.53.1
3737
- numexpr=2.7.3
3838
- odfpy=1.4.1
39+
- qtpy=2.2.0
3940
- openpyxl=3.0.7
4041
- pandas-gbq=0.15.0
4142
- psycopg2=2.8.6
@@ -54,3 +55,6 @@ dependencies:
5455
- xlrd=2.0.1
5556
- xlsxwriter=1.4.3
5657
- zstandard=0.15.2
58+
59+
- pip:
60+
- pyqt5==5.15.1

pandas/compat/_optional.py

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"xlsxwriter": "1.4.3",
4747
"zstandard": "0.15.2",
4848
"tzdata": "2022.1",
49+
"qtpy": "2.2.0",
50+
"pyqt5": "5.15.1",
4951
}
5052

5153
# A mapping from import name to package name (on PyPI) for packages where

scripts/validate_min_versions_in_sync.py

+57-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
ci/deps/actions-.*-minimum_versions.yaml
66
pandas/compat/_optional.py
7+
setup.cfg
78
89
TODO: doc/source/getting_started/install.rst
910
@@ -13,6 +14,7 @@
1314
"""
1415
from __future__ import annotations
1516

17+
import configparser
1618
import pathlib
1719
import sys
1820

@@ -21,6 +23,7 @@
2123
pathlib.Path("ci/deps").absolute().glob("actions-*-minimum_versions.yaml")
2224
)
2325
CODE_PATH = pathlib.Path("pandas/compat/_optional.py").resolve()
26+
SETUP_PATH = pathlib.Path("setup.cfg").resolve()
2427
EXCLUDE_DEPS = {"tzdata"}
2528
# pandas package is not available
2629
# in pre-commit environment
@@ -57,29 +60,76 @@ def get_versions_from_ci(content: list[str]) -> tuple[dict[str, str], dict[str,
5760
seen_required = True
5861
elif "# optional dependencies" in line:
5962
seen_optional = True
63+
elif "- pip:" in line:
64+
continue
6065
elif seen_required and line.strip():
61-
package, version = line.strip().split("=")
66+
if "==" in line:
67+
package, version = line.strip().split("==")
68+
69+
else:
70+
package, version = line.strip().split("=")
6271
package = package[2:]
6372
if package in EXCLUDE_DEPS:
6473
continue
6574
if not seen_optional:
66-
required_deps[package] = version
75+
required_deps[package.casefold()] = version
6776
else:
68-
optional_deps[package] = version
77+
optional_deps[package.casefold()] = version
6978
return required_deps, optional_deps
7079

7180

81+
def get_versions_from_setup() -> dict[str, str]:
82+
install_map = _optional.INSTALL_MAPPING
83+
optional_dependencies = {}
84+
85+
parser = configparser.ConfigParser()
86+
parser.read(SETUP_PATH)
87+
setup_optional = parser["options.extras_require"]["all"]
88+
dependencies = setup_optional[1:].split("\n")
89+
90+
# remove test dependencies
91+
test = parser["options.extras_require"]["test"]
92+
test_dependencies = set(test[1:].split("\n"))
93+
dependencies = [
94+
package for package in dependencies if package not in test_dependencies
95+
]
96+
97+
for dependency in dependencies:
98+
package, version = dependency.strip().split(">=")
99+
optional_dependencies[install_map.get(package, package).casefold()] = version
100+
101+
for item in EXCLUDE_DEPS:
102+
optional_dependencies.pop(item)
103+
104+
return optional_dependencies
105+
106+
72107
def main():
73108
with open(CI_PATH, encoding="utf-8") as f:
74109
_, ci_optional = get_versions_from_ci(f.readlines())
75110
code_optional = get_versions_from_code()
76-
diff = set(ci_optional.items()).symmetric_difference(code_optional.items())
111+
setup_optional = get_versions_from_setup()
112+
113+
diff = (ci_optional.items() | code_optional.items() | setup_optional.items()) - (
114+
ci_optional.items() & code_optional.items() & setup_optional.items()
115+
)
116+
77117
if diff:
78-
sys.stdout.write(
118+
packages = {package for package, _ in diff}
119+
out = sys.stdout
120+
out.write(
79121
f"The follow minimum version differences were found between "
80-
f"{CI_PATH} and {CODE_PATH}. Please ensure these are aligned: "
81-
f"{diff}\n"
122+
f"{CI_PATH}, {CODE_PATH} AND {SETUP_PATH}. "
123+
f"Please ensure these are aligned: \n\n"
82124
)
125+
126+
for package in packages:
127+
out.write(
128+
f"{package}\n"
129+
f"{CI_PATH}: {ci_optional.get(package, 'Not specified')}\n"
130+
f"{CODE_PATH}: {code_optional.get(package, 'Not specified')}\n"
131+
f"{SETUP_PATH}: {setup_optional.get(package, 'Not specified')}\n\n"
132+
)
83133
sys.exit(1)
84134
sys.exit(0)
85135

setup.cfg

+14-16
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,19 @@ test =
6060
# see: doc/source/getting_started/install.rst
6161
performance =
6262
bottleneck>=1.3.2
63-
numba>=0.53.0
63+
numba>=0.53.1
6464
numexpr>=2.7.1
6565
timezone =
6666
tzdata>=2022.1
6767
computation =
6868
scipy>=1.7.1
6969
xarray>=0.19.0
7070
fss =
71-
fsspec>=2021.7.0
71+
fsspec>=2021.07.0
7272
aws =
73-
boto3>=1.22.7
74-
s3fs>=0.4.0
73+
s3fs>=2021.08.0
7574
gcp =
76-
gcsfs>=2021.05.0
75+
gcsfs>=2021.07.0
7776
pandas-gbq>=0.15.0
7877
excel =
7978
odfpy>=1.4.1
@@ -105,7 +104,7 @@ html =
105104
xml =
106105
lxml>=4.6.3
107106
plot =
108-
matplotlib>=3.3.2
107+
matplotlib>=3.6.1
109108
output_formatting =
110109
jinja2>=3.0.0
111110
tabulate>=0.8.9
@@ -123,19 +122,18 @@ compression =
123122
all =
124123
beautifulsoup4>=4.9.3
125124
blosc>=1.21.0
126-
bottleneck>=1.3.1
127-
boto3>=1.22.7
125+
bottleneck>=1.3.2
128126
brotlipy>=0.7.0
129-
fastparquet>=0.4.0
130-
fsspec>=2021.7.0
131-
gcsfs>=2021.05.0
127+
fastparquet>=0.6.3
128+
fsspec>=2021.07.0
129+
gcsfs>=2021.07.0
132130
html5lib>=1.1
133-
hypothesis>=5.5.3
131+
hypothesis>=6.13.0
134132
jinja2>=3.0.0
135133
lxml>=4.6.3
136-
matplotlib>=3.3.2
137-
numba>=0.53.0
138-
numexpr>=2.7.1
134+
matplotlib>=3.6.1
135+
numba>=0.53.1
136+
numexpr>=2.7.3
139137
odfpy>=1.4.1
140138
openpyxl>=3.0.7
141139
pandas-gbq>=0.15.0
@@ -151,7 +149,7 @@ all =
151149
pyxlsb>=1.0.8
152150
qtpy>=2.2.0
153151
scipy>=1.7.1
154-
s3fs>=0.4.0
152+
s3fs>=2021.08.0
155153
SQLAlchemy>=1.4.16
156154
tables>=3.6.1
157155
tabulate>=0.8.9

0 commit comments

Comments
 (0)