Skip to content

Commit f1f7481

Browse files
committed
MVP Rust in CPython
1 parent a486d45 commit f1f7481

File tree

17 files changed

+1029
-39
lines changed

17 files changed

+1029
-39
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,6 @@ CLAUDE.local.md
178178
#### main branch only stuff below this line, things to backport go above. ####
179179
# main branch only: ABI files are not checked/maintained.
180180
Doc/data/python*.abi
181+
182+
# Rust build artifacts
183+
/target/

Cargo.lock

Lines changed: 242 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[workspace]
2+
resolver = "3"
3+
members = [
4+
"Modules/_base64",
5+
"Modules/cpython-sys"
6+
]

Makefile.pre.in

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ DTRACE_HEADERS= @DTRACE_HEADERS@
5858
DTRACE_OBJS= @DTRACE_OBJS@
5959
DSYMUTIL= @DSYMUTIL@
6060
DSYMUTIL_PATH= @DSYMUTIL_PATH@
61+
CARGO_HOME=@CARGO_HOME@
62+
CARGO_TARGET_DIR=@CARGO_TARGET_DIR@
63+
CARGO_PROFILE=@CARGO_PROFILE@
6164

6265
GNULD= @GNULD@
6366

@@ -1649,6 +1652,10 @@ Makefile Modules/config.c: Makefile.pre \
16491652
@mv config.c Modules
16501653
@echo "The Makefile was updated, you may need to re-run make."
16511654

1655+
.PHONY: regen-rust-wrapper-h
1656+
regen-rust-wrapper-h: $(PYTHON_HEADERS)
1657+
PYTHON_HEADERS="$(PYTHON_HEADERS)" $(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/regen-rust-wrapper-h.py
1658+
16521659
.PHONY: regen-test-frozenmain
16531660
regen-test-frozenmain: $(BUILDPYTHON)
16541661
# Regenerate Programs/test_frozenmain.h
@@ -3254,8 +3261,15 @@ profile-removal:
32543261
rm -f profile-run-stamp
32553262
rm -f profile-bolt-stamp
32563263

3264+
.PHONY: clean-rust
3265+
clean-rust:
3266+
@if test @CARGO_HOME@ != ''; then \
3267+
echo Running cargo clean...; \
3268+
$(CARGO_HOME)/bin/cargo clean; \
3269+
fi
3270+
32573271
.PHONY: clean
3258-
clean: clean-retain-profile clean-bolt
3272+
clean: clean-retain-profile clean-bolt clean-rust
32593273
@if test @DEF_MAKE_ALL_RULE@ = profile-opt -o @DEF_MAKE_ALL_RULE@ = bolt-opt; then \
32603274
rm -f profile-gen-stamp profile-clean-stamp; \
32613275
$(MAKE) profile-removal; \

Modules/Setup

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ PYTHONPATH=$(COREPYTHONPATH)
182182
#_codecs_tw cjkcodecs/_codecs_tw.c
183183
#_multibytecodec cjkcodecs/multibytecodec.c
184184
#unicodedata unicodedata.c
185+
#_base64 _base64/Cargo.toml _base64/src/lib.rs lib_base64.a
185186

186187
# Modules with some UNIX dependencies
187188

Modules/Setup.stdlib.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@
117117
@MODULE__MULTIBYTECODEC_TRUE@_multibytecodec cjkcodecs/multibytecodec.c
118118
@MODULE_UNICODEDATA_TRUE@unicodedata unicodedata.c
119119

120+
############################################################################
121+
# Rust modules
122+
#
123+
@MODULE__BASE64_TRUE@_base64 _base64/Cargo.toml _base64/src/lib.rs lib_base64.a
124+
120125
############################################################################
121126
# Modules with some UNIX dependencies
122127
#

Modules/_base64/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "_base64"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
base64 = "0.22.1"
8+
cpython-sys ={ path = "../cpython-sys" }
9+
10+
[lib]
11+
name = "_base64"
12+
crate-type = ["staticlib"]

0 commit comments

Comments
 (0)