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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,6 @@ CLAUDE.local.md
#### main branch only stuff below this line, things to backport go above. ####
# main branch only: ABI files are not checked/maintained.
Doc/data/python*.abi

# Rust build artifacts
/target/
235 changes: 235 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]
resolver = "3"
members = [
"Modules/_base64",
"Modules/cpython-sys"
]
16 changes: 15 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ DTRACE_HEADERS= @DTRACE_HEADERS@
DTRACE_OBJS= @DTRACE_OBJS@
DSYMUTIL= @DSYMUTIL@
DSYMUTIL_PATH= @DSYMUTIL_PATH@
CARGO_HOME=@CARGO_HOME@
CARGO_TARGET_DIR=@CARGO_TARGET_DIR@
CARGO_PROFILE=@CARGO_PROFILE@
CARGO_TARGET=@CARGO_TARGET@

GNULD= @GNULD@

Expand Down Expand Up @@ -3254,8 +3258,15 @@ profile-removal:
rm -f profile-run-stamp
rm -f profile-bolt-stamp

.PHONY: clean-rust
clean-rust:
@if test @CARGO_HOME@ != ''; then \
echo Running cargo clean...; \
$(CARGO_HOME)/bin/cargo clean; \
fi

.PHONY: clean
clean: clean-retain-profile clean-bolt
clean: clean-retain-profile clean-bolt clean-rust
@if test @DEF_MAKE_ALL_RULE@ = profile-opt -o @DEF_MAKE_ALL_RULE@ = bolt-opt; then \
rm -f profile-gen-stamp profile-clean-stamp; \
$(MAKE) profile-removal; \
Expand Down Expand Up @@ -3362,6 +3373,9 @@ Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
##########################################################################
# Module dependencies and platform-specific files

cpython-sys: Modules/cpython-sys/Cargo.toml Modules/cpython-sys/build.rs Modules/cpython-sys/wrapper.h Modules/cpython-sys/parser.h
CARGO_TARGET_DIR=$(abs_builddir)/target PYTHON_BUILD_DIR=$(abs_builddir) \$(CARGO_HOME)/bin/cargo build --lib --locked --package cpython-sys --profile $(CARGO_PROFILE) $(if $(CARGO_TARGET),--target=$(CARGO_TARGET)) --manifest-path $(srcdir)/Cargo.toml

# force rebuild when header file or module build flavor (static/shared) is changed
MODULE_DEPS_STATIC=Modules/config.c
MODULE_DEPS_SHARED=@MODULE_DEPS_SHARED@
Expand Down
1 change: 1 addition & 0 deletions Modules/Setup
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ PYTHONPATH=$(COREPYTHONPATH)
#_codecs_tw cjkcodecs/_codecs_tw.c
#_multibytecodec cjkcodecs/multibytecodec.c
#unicodedata unicodedata.c
#_base64 _base64/Cargo.toml _base64/src/lib.rs lib_base64.a

# Modules with some UNIX dependencies

Expand Down
5 changes: 5 additions & 0 deletions Modules/Setup.stdlib.in
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@
@MODULE__MULTIBYTECODEC_TRUE@_multibytecodec cjkcodecs/multibytecodec.c
@MODULE_UNICODEDATA_TRUE@unicodedata unicodedata.c

############################################################################
# Rust modules
#
@MODULE__BASE64_TRUE@_base64 _base64/Cargo.toml _base64/src/lib.rs lib_base64.a

############################################################################
# Modules with some UNIX dependencies
#
Expand Down
11 changes: 11 additions & 0 deletions Modules/_base64/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "_base64"
version = "0.1.0"
edition = "2024"

[dependencies]
cpython-sys ={ path = "../cpython-sys" }
Copy link

Choose a reason for hiding this comment

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

I think we should specify this as a workspace dep for simplicity.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Agreed!


[lib]
name = "_base64"
crate-type = ["staticlib"]
Loading
Loading