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 by ngoldbaum · Pull Request #27819 · numpy/numpy

CI: add windows free-threaded CI #27819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
rgommers merged 7 commits into numpy:main from ngoldbaum:windows-nogil-ci
Nov 25, 2024

Uh oh!

There was an error while loading. Please reload this page.

Merged

CI: add windows free-threaded CI #27819

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
7 commits
Select commit Hold shift + click to select a range
aaabf2d
MNT: add free-threaded windows CI
ngoldbaum Nov 22, 2024
e6c163f
MNT: fix extbuild on windows free-threaded build
ngoldbaum Nov 22, 2024
b7dcfcf
CI: try to fix 3.11 builds
ngoldbaum Nov 22, 2024
24e7cf0
fix linter
ngoldbaum Nov 22, 2024
3080a51
TST: use py.extension_module to simplify extbuild helper
ngoldbaum Nov 25, 2024
cc8350a
CI: use only two windows CI jobs
ngoldbaum Nov 25, 2024
1bea58b
MNT: respond to Ralf's comments
ngoldbaum Nov 25, 2024
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

23 changes: 16 additions & 7 deletions 23 .github/workflows/windows.yml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
strategy:
fail-fast: false
matrix:
compiler: ["MSVC", "Clang-cl"]
compiler-pyversion:
- ["MSVC", "3.11"]
- ["Clang-cl", "3.13t"]

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -31,9 +34,15 @@ jobs:
fetch-tags: true

- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: quansight-labs/setup-python@b9ab292c751a42bcd2bb465b7fa202ea2c3f5796 # v5.3.1
with:
python-version: '3.11'
python-version: ${{ matrix.compiler-pyversion[1] }}

# TODO: remove cython nightly install when cython does a release
- name: Install nightly Cython
if: matrix.compiler-pyversion[1] == '3.13t'
run: |
pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython

- name: Install build dependencies from PyPI
run: |
Expand All @@ -43,24 +52,24 @@ jobs:
run: |
choco install -y --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
echo "PKG_CONFIG_PATH=${{ github.workspace }}/.openblas" >> $env:GITHUB_ENV


- name: Install Clang-cl
if: matrix.compiler == 'Clang-cl'
if: matrix.compiler-pyversion[0] == 'Clang-cl'
run: |
# llvm is preinstalled, but leave
# this here in case we need to pin the
# version at some point.
#choco install llvm -y

- name: Install NumPy (MSVC)
if: matrix.compiler == 'MSVC'
if: matrix.compiler-pyversion[0] == 'MSVC'
run: |
pip install -r requirements/ci_requirements.txt
spin build --with-scipy-openblas=32 -j2 -- --vsenv

- name: Install NumPy (Clang-cl)
if: matrix.compiler == 'Clang-cl'
if: matrix.compiler-pyversion[0] == 'Clang-cl'
run: |
"[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
pip install -r requirements/ci_requirements.txt
Expand Down
68 changes: 30 additions & 38 deletions 68 numpy/testing/_private/extbuild.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def build_and_import_extension(
modname, functions, *, prologue="", build_dir=None,
include_dirs=[], more_init=""):
include_dirs=None, more_init=""):
"""
Build and imports a c-extension module `modname` from a list of function
fragments `functions`.
Expand Down Expand Up @@ -53,6 +53,8 @@ def build_and_import_extension(
>>> assert not mod.test_bytes('abc')
>>> assert mod.test_bytes(b'abc')
"""
if include_dirs is None:
include_dirs = []
body = prologue + _make_methods(functions, modname)
init = """
PyObject *mod = PyModule_Create(&moduledef);
Expand All @@ -68,12 +70,8 @@ def build_and_import_extension(
init += more_init
init += "\nreturn mod;"
source_string = _make_source(modname, init, body)
try:
mod_so = compile_extension_module(
modname, build_dir, include_dirs, source_string)
except Exception as e:
# shorten the exception chain
raise RuntimeError(f"could not compile in {build_dir}:") from e
mod_so = compile_extension_module(
modname, build_dir, include_dirs, source_string)
import importlib.util
spec = importlib.util.spec_from_file_location(modname, mod_so)
foo = importlib.util.module_from_spec(spec)
Expand All @@ -83,7 +81,7 @@ def build_and_import_extension(

def compile_extension_module(
name, builddir, include_dirs,
source_string, libraries=[], library_dirs=[]):
source_string, libraries=None, library_dirs=None):
"""
Build an extension module and return the filename of the resulting
native code file.
Expand All @@ -106,11 +104,14 @@ def compile_extension_module(
dirname = builddir / name
dirname.mkdir(exist_ok=True)
cfile = _convert_str_to_file(source_string, dirname)
include_dirs = include_dirs + [sysconfig.get_config_var('INCLUDEPY')]
include_dirs = include_dirs if include_dirs else []
libraries = libraries if libraries else []
library_dirs = library_dirs if library_dirs else []

return _c_compile(
cfile, outputfilename=dirname / modname,
include_dirs=include_dirs, libraries=[], library_dirs=[],
include_dirs=include_dirs, libraries=libraries,
library_dirs=library_dirs,
)


Expand Down Expand Up @@ -182,35 +183,23 @@ def _make_source(name, init, body):
return code


def _c_compile(cfile, outputfilename, include_dirs=[], libraries=[],
library_dirs=[]):
def _c_compile(cfile, outputfilename, include_dirs, libraries,
library_dirs):
link_extra = []
if sys.platform == 'win32':
compile_extra = ["/we4013"]
link_extra = ["/LIBPATH:" + os.path.join(sys.base_prefix, 'libs')]
link_extra.append('/DEBUG') # generate .pdb file
Comment thread

@rgommers rgommers Nov 25, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this will be robust, but I don't mind adding it if CI is happy

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ngoldbaum ngoldbaum Nov 25, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just keeping the behavior we had before, there's another sys.platform == 'win32' block below I merged with this one.

I did delete the LIBPATH stuff because meson handles this now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rgommers reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
elif sys.platform.startswith('linux'):
compile_extra = [
"-O0", "-g", "-Werror=implicit-function-declaration", "-fPIC"]
link_extra = []
else:
compile_extra = link_extra = []
compile_extra = []
pass
if sys.platform == 'win32':
link_extra = link_extra + ['/DEBUG'] # generate .pdb file
if sys.platform == 'darwin':
# support Fink & Darwinports
for s in ('/sw/', '/opt/local/'):
if (s + 'include' not in include_dirs
and os.path.exists(s + 'include')):
include_dirs.append(s + 'include')
if s + 'lib' not in library_dirs and os.path.exists(s + 'lib'):
library_dirs.append(s + 'lib')
Comment thread

@rgommers rgommers Nov 25, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mess can indeed go now I think.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

outputfilename = outputfilename.with_suffix(get_so_suffix())
build(

return build(
cfile, outputfilename,
compile_extra, link_extra,
include_dirs, libraries, library_dirs)
return outputfilename


def build(cfile, outputfilename, compile_extra, link_extra,
Expand All @@ -219,18 +208,17 @@ def build(cfile, outputfilename, compile_extra, link_extra,

build_dir = cfile.parent / "build"
os.makedirs(build_dir, exist_ok=True)
so_name = outputfilename.parts[-1]
with open(cfile.parent / "meson.build", "wt") as fid:
includes = ['-I' + d for d in include_dirs]
link_dirs = ['-L' + d for d in library_dirs]
fid.write(textwrap.dedent(f"""\
project('foo', 'c')
shared_module('{so_name}', '{cfile.parts[-1]}',
c_args: {includes} + {compile_extra},
link_args: {link_dirs} + {link_extra},
link_with: {libraries},
name_prefix: '',
name_suffix: 'dummy',
py = import('python').find_installation(pure: false)
py.extension_module(
'{outputfilename.parts[-1]}',
'{cfile.parts[-1]}',
c_args: {compile_extra},
link_args: {link_dirs},
include_directories: {include_dirs},
)
"""))
if sys.platform == "win32":
Expand All @@ -243,8 +231,12 @@ def build(cfile, outputfilename, compile_extra, link_extra,
subprocess.check_call(["meson", "setup", "--vsenv", ".."],
Comment thread
rgommers marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

cwd=build_dir
)

so_name = outputfilename.parts[-1] + get_so_suffix()
subprocess.check_call(["meson", "compile"], cwd=build_dir)
os.rename(str(build_dir / so_name) + ".dummy", cfile.parent / so_name)
os.rename(str(build_dir / so_name), cfile.parent / so_name)
return cfile.parent / so_name


def get_so_suffix():
ret = sysconfig.get_config_var('EXT_SUFFIX')
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.