GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CI: add windows free-threaded CI (#27819) · numpy/numpy@cf95985

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • windows.yml
  • numpy/testing/_private
    • extbuild.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/windows.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/windows.yml
+16-7Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
compiler: ["MSVC", "Clang-cl"]
25+
compiler-pyversion:
26+
- ["MSVC", "3.11"]
27+
- ["Clang-cl", "3.13t"]
28+
2629
steps:
2730
- name: Checkout
2831
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -31,9 +34,15 @@ jobs:
3134
fetch-tags: true
3235

3336
- name: Setup Python
34-
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
37+
uses: quansight-labs/setup-python@b9ab292c751a42bcd2bb465b7fa202ea2c3f5796 # v5.3.1
3538
with:
36-
python-version: '3.11'
39+
python-version: ${{ matrix.compiler-pyversion[1] }}
40+
41+
# TODO: remove cython nightly install when cython does a release
42+
- name: Install nightly Cython
43+
if: matrix.compiler-pyversion[1] == '3.13t'
44+
run: |
45+
pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython
3746
3847
- name: Install build dependencies from PyPI
3948
run: |
@@ -43,24 +52,24 @@ jobs:
4352
run: |
4453
choco install -y --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
4554
echo "PKG_CONFIG_PATH=${{ github.workspace }}/.openblas" >> $env:GITHUB_ENV
46-
55+
4756
4857
- name: Install Clang-cl
49-
if: matrix.compiler == 'Clang-cl'
58+
if: matrix.compiler-pyversion[0] == 'Clang-cl'
5059
run: |
5160
# llvm is preinstalled, but leave
5261
# this here in case we need to pin the
5362
# version at some point.
5463
#choco install llvm -y
5564
5665
- name: Install NumPy (MSVC)
57-
if: matrix.compiler == 'MSVC'
66+
if: matrix.compiler-pyversion[0] == 'MSVC'
5867
run: |
5968
pip install -r requirements/ci_requirements.txt
6069
spin build --with-scipy-openblas=32 -j2 -- --vsenv
6170
6271
- name: Install NumPy (Clang-cl)
63-
if: matrix.compiler == 'Clang-cl'
72+
if: matrix.compiler-pyversion[0] == 'Clang-cl'
6473
run: |
6574
"[binaries]","c = 'clang-cl'","cpp = 'clang-cl'","ar = 'llvm-lib'","c_ld = 'lld-link'","cpp_ld = 'lld-link'" | Out-File $PWD/clang-cl-build.ini -Encoding ascii
6675
pip install -r requirements/ci_requirements.txt
Collapse file

‎numpy/testing/_private/extbuild.py‎

Copy file name to clipboardExpand all lines: numpy/testing/_private/extbuild.py
+30-38Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
def build_and_import_extension(
1818
modname, functions, *, prologue="", build_dir=None,
19-
include_dirs=[], more_init=""):
19+
include_dirs=None, more_init=""):
2020
"""
2121
Build and imports a c-extension module `modname` from a list of function
2222
fragments `functions`.
@@ -53,6 +53,8 @@ def build_and_import_extension(
5353
>>> assert not mod.test_bytes('abc')
5454
>>> assert mod.test_bytes(b'abc')
5555
"""
56+
if include_dirs is None:
57+
include_dirs = []
5658
body = prologue + _make_methods(functions, modname)
5759
init = """
5860
PyObject *mod = PyModule_Create(&moduledef);
@@ -68,12 +70,8 @@ def build_and_import_extension(
6870
init += more_init
6971
init += "\nreturn mod;"
7072
source_string = _make_source(modname, init, body)
71-
try:
72-
mod_so = compile_extension_module(
73-
modname, build_dir, include_dirs, source_string)
74-
except Exception as e:
75-
# shorten the exception chain
76-
raise RuntimeError(f"could not compile in {build_dir}:") from e
73+
mod_so = compile_extension_module(
74+
modname, build_dir, include_dirs, source_string)
7775
import importlib.util
7876
spec = importlib.util.spec_from_file_location(modname, mod_so)
7977
foo = importlib.util.module_from_spec(spec)
@@ -83,7 +81,7 @@ def build_and_import_extension(
8381

8482
def compile_extension_module(
8583
name, builddir, include_dirs,
86-
source_string, libraries=[], library_dirs=[]):
84+
source_string, libraries=None, library_dirs=None):
8785
"""
8886
Build an extension module and return the filename of the resulting
8987
native code file.
@@ -106,11 +104,14 @@ def compile_extension_module(
106104
dirname = builddir / name
107105
dirname.mkdir(exist_ok=True)
108106
cfile = _convert_str_to_file(source_string, dirname)
109-
include_dirs = include_dirs + [sysconfig.get_config_var('INCLUDEPY')]
107+
include_dirs = include_dirs if include_dirs else []
108+
libraries = libraries if libraries else []
109+
library_dirs = library_dirs if library_dirs else []
110110

111111
return _c_compile(
112112
cfile, outputfilename=dirname / modname,
113-
include_dirs=include_dirs, libraries=[], library_dirs=[],
113+
include_dirs=include_dirs, libraries=libraries,
114+
library_dirs=library_dirs,
114115
)
115116

116117

@@ -182,35 +183,23 @@ def _make_source(name, init, body):
182183
return code
183184

184185

185-
def _c_compile(cfile, outputfilename, include_dirs=[], libraries=[],
186-
library_dirs=[]):
186+
def _c_compile(cfile, outputfilename, include_dirs, libraries,
187+
library_dirs):
188+
link_extra = []
187189
if sys.platform == 'win32':
188190
compile_extra = ["/we4013"]
189-
link_extra = ["/LIBPATH:" + os.path.join(sys.base_prefix, 'libs')]
191+
link_extra.append('/DEBUG') # generate .pdb file
190192
elif sys.platform.startswith('linux'):
191193
compile_extra = [
192194
"-O0", "-g", "-Werror=implicit-function-declaration", "-fPIC"]
193-
link_extra = []
194195
else:
195-
compile_extra = link_extra = []
196+
compile_extra = []
196197
pass
197-
if sys.platform == 'win32':
198-
link_extra = link_extra + ['/DEBUG'] # generate .pdb file
199-
if sys.platform == 'darwin':
200-
# support Fink & Darwinports
201-
for s in ('/sw/', '/opt/local/'):
202-
if (s + 'include' not in include_dirs
203-
and os.path.exists(s + 'include')):
204-
include_dirs.append(s + 'include')
205-
if s + 'lib' not in library_dirs and os.path.exists(s + 'lib'):
206-
library_dirs.append(s + 'lib')
207-
208-
outputfilename = outputfilename.with_suffix(get_so_suffix())
209-
build(
198+
199+
return build(
210200
cfile, outputfilename,
211201
compile_extra, link_extra,
212202
include_dirs, libraries, library_dirs)
213-
return outputfilename
214203

215204

216205
def build(cfile, outputfilename, compile_extra, link_extra,
@@ -219,18 +208,17 @@ def build(cfile, outputfilename, compile_extra, link_extra,
219208

220209
build_dir = cfile.parent / "build"
221210
os.makedirs(build_dir, exist_ok=True)
222-
so_name = outputfilename.parts[-1]
223211
with open(cfile.parent / "meson.build", "wt") as fid:
224-
includes = ['-I' + d for d in include_dirs]
225212
link_dirs = ['-L' + d for d in library_dirs]
226213
fid.write(textwrap.dedent(f"""\
227214
project('foo', 'c')
228-
shared_module('{so_name}', '{cfile.parts[-1]}',
229-
c_args: {includes} + {compile_extra},
230-
link_args: {link_dirs} + {link_extra},
231-
link_with: {libraries},
232-
name_prefix: '',
233-
name_suffix: 'dummy',
215+
py = import('python').find_installation(pure: false)
216+
py.extension_module(
217+
'{outputfilename.parts[-1]}',
218+
'{cfile.parts[-1]}',
219+
c_args: {compile_extra},
220+
link_args: {link_dirs},
221+
include_directories: {include_dirs},
234222
)
235223
"""))
236224
if sys.platform == "win32":
@@ -243,8 +231,12 @@ def build(cfile, outputfilename, compile_extra, link_extra,
243231
subprocess.check_call(["meson", "setup", "--vsenv", ".."],
244232
cwd=build_dir
245233
)
234+
235+
so_name = outputfilename.parts[-1] + get_so_suffix()
246236
subprocess.check_call(["meson", "compile"], cwd=build_dir)
247-
os.rename(str(build_dir / so_name) + ".dummy", cfile.parent / so_name)
237+
os.rename(str(build_dir / so_name), cfile.parent / so_name)
238+
return cfile.parent / so_name
239+
248240

249241
def get_so_suffix():
250242
ret = sysconfig.get_config_var('EXT_SUFFIX')

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.