Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit 14f94fe

Browse files
authored
Merge pull request #151 from tylerjereddy/treddy_verify_init
MAINT, CI: check _distributor_init.py contents
2 parents f1d2caa + cc17ad7 commit 14f94fe

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

appveyor.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ build_script:
143143
$cwd = Get-Location
144144
ls $cwd
145145
rm -Force $cwd/scipy/scipy/_distributor_init.py
146-
mv $cwd/_distributor_init.py $cwd/scipy/scipy/
146+
cp $cwd/_distributor_init.py $cwd/scipy/scipy/
147147
cd scipy
148148
# Append license text relevant for the built wheel
149149
- type ..\LICENSE_win32.txt >> LICENSE.txt
@@ -198,6 +198,10 @@ test_script:
198198
- python ..\run_scipy_tests.py %TEST_MODE% -- -n6 --junitxml=%cd%\junit-results.xml -rfEX
199199

200200
after_test:
201+
- cd ..
202+
- ls scipy\dist
203+
- python verify_init.py scipy\dist
204+
- cd tmp_test
201205
# Upload test results to Appveyor
202206
- ps: |
203207
If (Test-Path .\junit-results.xml) {

azure-posix.yml

+5
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ jobs:
8888
displayName: "Rename MacOS arm64 wheels for version 12.0 minimum"
8989
condition: eq(variables['PLAT'], 'arm64')
9090
91+
- bash: |
92+
set -xe
93+
python verify_init.py ./wheelhouse
94+
displayName: "Check for appropriate contents of _distributor_init.py"
95+
9196
- bash: |
9297
echo "##vso[task.prependpath]$CONDA/bin"
9398
sudo chown -R $USER $CONDA

patch_code.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ if [ -z "$IS_OSX" ]; then
1313
cat LICENSE_linux.txt >> $repo_dir/LICENSE.txt
1414
else
1515
cat LICENSE_osx.txt >> $repo_dir/LICENSE.txt
16-
cp _distributor_init.py scipy/_distributor_init.py
16+
cp _distributor_init.py scipy/scipy/_distributor_init.py
1717
fi

verify_init.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Small CLI script that accepts the path to a directory containing one
3+
or more wheel files.
4+
5+
Check that a wheel appropriately includes/excludes
6+
_distributor_init.py with the contents of that same
7+
file in the wheels repo.
8+
"""
9+
10+
import sys
11+
import pathlib
12+
from zipfile import ZipFile
13+
14+
15+
def check_for_dist_init(input_dir):
16+
p = pathlib.Path(input_dir)
17+
wheel_files = p.glob('**/*.whl')
18+
for wheel_file in wheel_files:
19+
with ZipFile(wheel_file) as zipf:
20+
file_names = zipf.namelist()
21+
dist_init_found = 0
22+
for file_name in file_names:
23+
if "_distributor_init.py" in file_name:
24+
dist_init_found += 1
25+
with zipf.open(file_name) as actual_file:
26+
with open("_distributor_init.py", 'rb') as reference_file:
27+
# currently just MacOS and Windows should have _distributor_init.py
28+
# copied in from wheels repo; Linux should just have a generic
29+
# version of the file
30+
if "-macosx" in str(wheel_file) or "-win" in str(wheel_file):
31+
actual_content = actual_file.read()
32+
expected_content = reference_file.read()
33+
if not actual_content == expected_content:
34+
raise ValueError(f"Contents of _distributor_init.py incorrect for {wheel_file}")
35+
if not dist_init_found:
36+
raise FileNotFoundError(f"_distributor_init.py missing from {wheel_file}")
37+
38+
if __name__ == "__main__":
39+
input_dir = sys.argv[1]
40+
check_for_dist_init(input_dir=input_dir)

0 commit comments

Comments
 (0)