Skip to content
Merged
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
32 changes: 24 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# `cargo test` compiles weavepy-pylib's source into a unit-test
# harness but never emits the cdylib artifact, so build it
# explicitly: the windows_dll integration battery (RFC 0064 WS5)
# needs target/debug/python313.dll next to the shim exe.
- run: cargo build -p weavepy-pylib
- run: cargo test --workspace --all-targets --all-features
- run: cargo test --workspace --doc

Expand Down Expand Up @@ -90,8 +95,12 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build weavepy CLI
run: cargo build --release -p weavepy-cli
- name: Build weavepy CLI + runtime library
# weavepy-pylib builds python313.dll — on Windows the exe is a
# thin shim over it (RFC 0064 WS1), so the DLL must sit next to
# the exe. Building it on all three OSes keeps the cdylib
# honest everywhere.
run: cargo build --release -p weavepy-cli -p weavepy-pylib
- name: Run bundled regrtests (subprocess, parallel)
shell: bash
run: |
Expand Down Expand Up @@ -134,8 +143,10 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Build weavepy CLI + bench harness
run: cargo build --release -p weavepy-cli -p weavepy-bench
- name: Build weavepy CLI + runtime library + bench harness
# weavepy-pylib: python313.dll, the runtime the Windows shim
# exe loads (RFC 0064 WS1).
run: cargo build --release -p weavepy-cli -p weavepy-pylib -p weavepy-bench
- name: Run bench gate
# Linux and Windows have no committed per-platform baseline
# yet, so the gate is advisory there (--allow-missing-baseline
Expand Down Expand Up @@ -194,8 +205,10 @@ jobs:
with:
path: target/ecosystem-wheels
key: ecosystem-wheels-${{ runner.os }}-${{ hashFiles('tests/ecosystem/manifest.toml') }}
- name: Build weavepy CLI
run: cargo build --release -p weavepy-cli
- name: Build weavepy CLI + runtime library
# weavepy-pylib: python313.dll, the runtime the Windows shim
# exe loads (RFC 0064 WS1).
run: cargo build --release -p weavepy-cli -p weavepy-pylib
- name: Fetch ecosystem wheels (no-op on cache hit)
# `python`, not `python3`: setup-python exposes both on
# ubuntu/macos (same 3.13 interpreter) but only `python` on
Expand Down Expand Up @@ -234,8 +247,11 @@ jobs:
with:
path: target/ecosystem-wheels
key: ecosystem-wheels-${{ runner.os }}-${{ hashFiles('tests/ecosystem/manifest.toml') }}
- name: Build weavepy CLI
run: cargo build --release -p weavepy-cli
- name: Build weavepy CLI + runtime library
# weavepy-pylib: python313.dll — the Windows artifact ships it
# at the prefix root with libs\python313.lib (RFC 0064 WS3),
# and the builder refuses to package a shim exe without it.
run: cargo build --release -p weavepy-cli -p weavepy-pylib
- name: Fetch ecosystem wheels (no-op on cache hit)
# `python`, not `python3`: setup-python exposes both on
# ubuntu/macos (same 3.13 interpreter) but only `python` on
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"crates/weavepy-jit",
"crates/weavepy-lexer",
"crates/weavepy-parser",
"crates/weavepy-pylib",
"crates/weavepy-vm",
"vendor/expat-sys",
]
Expand All @@ -26,6 +27,7 @@ default-members = [
"crates/weavepy-compiler",
"crates/weavepy-lexer",
"crates/weavepy-parser",
"crates/weavepy-pylib",
"crates/weavepy-vm",
]

Expand All @@ -49,6 +51,7 @@ categories = ["compilers", "development-tools", "parser-implementations"]
# Internal crates (path deps so the workspace builds without publishing).
weavepy = { path = "crates/weavepy", version = "0.0.0" }
weavepy-capi = { path = "crates/weavepy-capi", version = "0.0.0" }
weavepy-cli = { path = "crates/weavepy-cli", version = "0.0.0" }
weavepy-compiler = { path = "crates/weavepy-compiler", version = "0.0.0" }
weavepy-conformance = { path = "crates/weavepy-conformance", version = "0.0.0" }
weavepy-jit = { path = "crates/weavepy-jit", version = "0.0.0" }
Expand Down
6 changes: 6 additions & 0 deletions crates/weavepy-capi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ num-bigint = { workspace = true }
num-traits = { workspace = true }
thiserror = { workspace = true }

# RFC 0064 WS2 — the Windows extension loader calls `LoadLibraryExW`
# directly (CPython's dynload_win.c flag set + `GetLastError` for the
# CPython-shaped ImportError message).
[target.'cfg(windows)'.dependencies]
windows-sys = { workspace = true }

[build-dependencies]
cc = "1.0"

Expand Down
157 changes: 157 additions & 0 deletions crates/weavepy-capi/include/pyconfig/pyconfig-windows.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/* pyconfig.h for WeavePy on Windows (RFC 0064 WS3).
*
* CPython ships a hand-maintained `PC/pyconfig.h` on Windows (there
* is no autoconf step); this is WeavePy's equivalent, shaped after
* CPython 3.13's file: the same platform macros, LLP64 type sizes,
* shared-core markers, and — critically — the MSVC autolink pragma
* that makes `cl /LD ext.c /I{Include}` pull `python313.lib` off the
* `/LIBPATH` without the build script naming it. setuptools points
* `/LIBPATH:` at `{sys.base_exec_prefix}\libs`, where the WeavePy
* artifact ships the import library for `python313.dll`.
*/

#ifndef Py_CONFIG_H
#define Py_CONFIG_H

/* --- platform identification -------------------------------------- */

#define MS_WIN32 /* only support win32 and greater. */
#define MS_WINDOWS
#ifdef _WIN64
#define MS_WIN64
#endif

#define _Py_STRINGIZE(X) _Py_STRINGIZE1(X)
#define _Py_STRINGIZE1(X) #X

/* set the COMPILER and support tier (1 for x64, 3 elsewhere;
* WeavePy's shipped target is x86_64-pc-windows-msvc) */
#ifdef MS_WIN64
#if defined(_M_X64) || defined(_M_AMD64)
#define COMPILER ("[MSC v." _Py_STRINGIZE(_MSC_VER) " 64 bit (AMD64)]")
#define PY_SUPPORT_TIER 1
#elif defined(_M_ARM64)
#define COMPILER ("[MSC v." _Py_STRINGIZE(_MSC_VER) " 64 bit (ARM64)]")
#define PY_SUPPORT_TIER 3
#else
#define COMPILER ("[MSC v." _Py_STRINGIZE(_MSC_VER) " 64 bit (Unknown)]")
#define PY_SUPPORT_TIER 0
#endif
#endif /* MS_WIN64 */

/* Debug builds: MSVC's _DEBUG selects CPython's debug ABI. WeavePy
* does not ship python313_d.dll, so a Debug extension build fails at
* link with a clear missing-python313_d.lib error — the same failure
* a release-only CPython install produces. */
#ifdef _DEBUG
#define Py_DEBUG 1
#endif

/* --- shared core + autolink ---------------------------------------- */

/* The Python runtime is a DLL (python313.dll — RFC 0064 WS1). */
#define MS_COREDLL 1
#define Py_ENABLE_SHARED 1

/* Declspec shaping for the stock headers' PyAPI_FUNC/PyAPI_DATA. */
#define HAVE_DECLSPEC_DLL

#ifdef MS_COREDLL
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
/* not building the core — must be an extension or embedder: have
* MSVC pull the import library automatically. */
#if defined(_MSC_VER)
#if defined(_DEBUG)
#pragma comment(lib, "python313_d.lib")
#elif defined(Py_LIMITED_API)
/* CPython points the limited API at python3.lib (the stable-ABI
* forwarder DLL's import library). WeavePy does not ship the
* forwarder yet (RFC 0064 Future work), so limited-API builds link
* the full runtime library — the resulting .pyd imports
* python313.dll and works on WeavePy 3.13. */
#pragma comment(lib, "python313.lib")
#else
#pragma comment(lib, "python313.lib")
#endif /* _DEBUG */
#endif /* _MSC_VER */
#endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */

/* --- type sizes (LLP64) -------------------------------------------- */

#define SIZEOF_SHORT 2
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
#define SIZEOF_WCHAR_T 2
#define SIZEOF_FPOS_T 8
#define SIZEOF_TIME_T 8
/* off_t is 32 bits on Windows; large files go through fpos_t. */
#define SIZEOF_OFF_T 4
#define HAVE_LARGEFILE_SUPPORT 1

#ifdef MS_WIN64
#define SIZEOF_VOID_P 8
#define SIZEOF_SIZE_T 8
#define SIZEOF_HKEY 8
#define SIZEOF_PID_T 4
#else
#define SIZEOF_VOID_P 4
#define SIZEOF_SIZE_T 4
#define SIZEOF_HKEY 4
#define SIZEOF_PID_T 4
#endif

#define WORD_BIT 32

/* MSVC provides ssize_t via SSIZE_T (BaseTsd.h); the stock headers
* only need the macro that says the typedef exists once pyport.h has
* mapped it. CPython's PC/pyconfig.h does exactly this. */
#if defined(MS_WIN64)
typedef __int64 ssize_t;
#else
typedef _W64 int ssize_t;
#endif
#define HAVE_SSIZE_T 1

/* --- capabilities the stock headers key off ------------------------ */

#define WITH_DOC_STRINGS 1
#define HAVE_DYNAMIC_LOADING 1
#define HAVE_STRERROR 1
#define HAVE_CLOCK 1
#define HAVE_IO_H 1
#define HAVE_SYS_UTIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_ERRNO_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#define HAVE_WCHAR_H 1
#define HAVE_FCNTL_H 1
#define HAVE_DIRECT_H 1
#define HAVE_PROCESS_H 1
#define HAVE_SIGNAL_H 1

/* Threading: native NT threads, exactly one flavour. */
#define NT_THREADS 1
#define WITH_THREAD 1

/* IEEE-754 doubles, little-endian (every supported Windows arch). */
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1

/* IPv6 (Winsock2 has shipped it since XP). */
#define ENABLE_IPV6 1

/* Sockets are real handles on NT. */
#define USE_SOCKET 1

/* Not a debug/free-threaded/tracing build (mirrors
* _weave_sysconfigdata). */
/* #undef Py_GIL_DISABLED */
/* #undef Py_TRACE_REFS */
/* #undef Py_REF_DEBUG */

#endif /* !Py_CONFIG_H */
Loading
Loading