Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
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 }}

Copy link
Copy Markdown

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 👍 / 👎.


- name: run snippets
run: python -m pip install -r requirements.txt && pytest -v
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-caches.yml
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 Lib/test/test_ctypes/test_python_api.py
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 Lib/test/test_frame.py
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 Lib/test/test_threading.py
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 build.rs
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.
}

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