Skip to content

Commit d8d8d71

Browse files
committed
Refactor Numpy version getting
1 parent da8a623 commit d8d8d71

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

.github/workflows/wheels-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
with:
5757
python-version: ${{ matrix.python }}
5858
- name: Set Numpy version
59-
run: echo "BUILD_DEPENDS=$(./get_numpy_version.py)" >> $GITHUB_ENV
59+
run: echo "BUILD_DEPENDS=$(./get_numpy_version.py ${{ matrix.python }})" >> $GITHUB_ENV
6060
- name: Build Wheel
6161
run: .github/workflows/build.sh
6262
- uses: actions/upload-artifact@v3

.github/workflows/wheels-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
python-version: ${{ matrix.python }}
4040
- name: Set Numpy version
4141
run: |
42-
$np_dep = python .\get_numpy_version.py
42+
$np_dep = python .\get_numpy_version.py ${{ matrix.python }}
4343
echo "BUILD_DEPENDS=$np_dep" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
4444
- name: Build Wheel
4545
run: .github/workflows/build.ps1

get_numpy_version.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"""
44

55
import os
6-
import sys
76

87
from argparse import ArgumentParser, RawDescriptionHelpFormatter
98

109

1110
def get_parser():
1211
parser = ArgumentParser(description=__doc__, # Usage from docstring
1312
formatter_class=RawDescriptionHelpFormatter)
13+
parser.add_argument("py_ver",
14+
help='Python version e.g. 3.11')
1415
parser.add_argument('-t', '--type', default='build',
1516
help='Dependency type')
1617
return parser
@@ -19,9 +20,10 @@ def get_parser():
1920
def main():
2021
parser = get_parser()
2122
args = parser.parse_args()
22-
major, minor, *_ = sys.version_info
23-
assert major == 3
23+
major, minor, *_ = args.py_ver.split('.')
24+
assert major == "3"
2425
np_version = "1.22.2"
26+
minor = int(minor)
2527
if minor >= 12:
2628
np_version = "1.26.0"
2729
elif minor >= 11:

0 commit comments

Comments
 (0)