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 — Enable capi when running CPython tests by bschoenmaeckers · Pull Request #9270 · RustPython/RustPython

Enable capi when running CPython tests #9270

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

Open
bschoenmaeckers wants to merge 5 commits into RustPython:main
base: main
Loading
Loading
from bschoenmaeckers:c-api-python-tests

Uh oh!

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

Open

Enable capi when running CPython tests #9270

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
5 commits
Select commit Hold shift + click to select a range
bb886b1
Enable capi when testing CPython tests
bschoenmaeckers Oct 21, 2026
94373cc
Try fix windows exports
bschoenmaeckers Oct 21, 2026
b7b777b
Review
bschoenmaeckers Oct 21, 2026
c46b1ce
Use static export list instead
bschoenmaeckers Oct 22, 2026
3069020
Add PyOS_snprintf/PyOS_vsnprintf
bschoenmaeckers Oct 28, 2026
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

2 changes: 1 addition & 1 deletion 2 .github/workflows/ci.yaml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ jobs:

# Keep features in sync with update-caches.yml CARGO_ARGS.
- name: build rustpython
run: cargo build --locked --release --verbose --features=threading,jit ${{ env.CARGO_ARGS }}
run: cargo build --locked --release --verbose --features=threading,jit,capi ${{ env.CARGO_ARGS }}
Comment thread

@chatgpt-codex-connector chatgpt-codex-connector Bot Oct 21, 2026

Copy link
Copy Markdown

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.

P2 Badge Preserve xfails for builds without the C-API

For the documented default-feature test command, the three newly un-xfailed tests still have no C-API: this line enables capi only for the Run snippets and cpython tests release binary, while capi is absent from Cargo.toml's default feature list and src/lib.rs takes the non-CAPI path without it. Consequently a normal cargo run --release -- -m test test_ctypes.test_python_api (and likewise test_frame or test_threading) now fails at ctypes.pythonapi symbol lookup; make the expectation conditional on C-API availability or enable the feature in every supported test build.

AGENTS.md reference: AGENTS.md:L280-L282

Useful? React with 👍 / 👎.

Sorry, something went wrong.

Uh oh!

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

All reactions

- name: run snippets
run: python -m pip install -r requirements.txt && pytest -v
Expand Down
2 changes: 1 addition & 1 deletion 2 .github/workflows/update-caches.yml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_RELEASE_DEBUG: 0
# Keep feature list in sync with CI's release build in .github/workflows/ci.yaml.
CARGO_ARGS: --workspace --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,threading,jit,doc --exclude rustpython_wasm --exclude rustpython-venvlauncher
CARGO_ARGS: --workspace --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,threading,jit,doc,capi --exclude rustpython_wasm --exclude rustpython-venvlauncher

jobs:
build-caches:
Expand Down
2 changes: 0 additions & 2 deletions 2 Lib/test/test_ctypes/test_python_api.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class PythonAPITestCase(unittest.TestCase):
@unittest.expectedFailure # TODO: RUSTPYTHON; - requires pythonapi (Python C API)
def test_PyBytes_FromStringAndSize(self):
PyBytes_FromStringAndSize = pythonapi.PyBytes_FromStringAndSize

Expand Down Expand Up @@ -58,7 +57,6 @@ def test_PyObj_FromPtr(self):
del pyobj
self.assertEqual(sys.getrefcount(s), ref)

@unittest.expectedFailure # TODO: RUSTPYTHON; - requires pythonapi (Python C API)
def test_PyOS_snprintf(self):
PyOS_snprintf = pythonapi.PyOS_snprintf
PyOS_snprintf.argtypes = POINTER(c_char), c_size_t, c_char_p
Expand Down
1 change: 0 additions & 1 deletion 1 Lib/test/test_frame.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ def test_eq(self):


class TestFrameCApi(unittest.TestCase):
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_basic(self):
x = 1
ctypes = import_helper.import_module('ctypes')
Expand Down
1 change: 0 additions & 1 deletion 1 Lib/test/test_threading.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ def fail_new_thread(*args, **kwargs):
finally:
threading._start_joinable_thread = _start_joinable_thread

@unittest.expectedFailure # TODO: RUSTPYTHON; ctypes.pythonapi is not supported
def test_finalize_running_thread(self):
# Issue 1402: the PyGILState_Ensure / _Release functions may be called
# very late on python exit: on deallocation of a running thread for
Expand Down
22 changes: 22 additions & 0 deletions 22 build.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ fn main() {
println!("cargo:rustc-link-arg-bin=rustpython=-Wl,-export_dynamic");
}
"windows" => {
if capi_enabled {
export_capi_symbols_for_windows_exe();
}

println!("cargo:rerun-if-changed=logo.ico");
let mut res = winresource::WindowsResource::new();
if std::path::Path::new("logo.ico").exists() {
Expand All @@ -27,3 +31,21 @@ fn main() {
_ => {}
}
}

fn export_capi_symbols_for_windows_exe() {
let exports_def_filename = "rustpython-capi-exports.def";
println!("cargo:rerun-if-changed={exports_def_filename}");

let exports = std::fs::read_to_string(exports_def_filename)
.expect("Failed to read exports definition file");

for export in exports
.lines()
.skip(1)
.filter(|line| !line.trim().is_empty())
{
println!("cargo:rustc-link-arg-bin=rustpython=/INCLUDE:{export}");
Comment thread
bschoenmaeckers marked this conversation as resolved.
Resolved

Uh oh!

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

}

println!("cargo:rustc-link-arg-bin=rustpython=/DEF:{exports_def_filename}",);
}
Loading
Oops, something went wrong.

Uh oh!

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

Loading
Oops, something went wrong.

Uh oh!

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

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 01402503 — 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.