From 9a2de89fb19f5f6570b6f2ffba3760505e04abb6 Mon Sep 17 00:00:00 2001 From: Emma Harper Smith Date: Sun, 16 Nov 2025 16:09:53 -0800 Subject: [PATCH 1/4] Update Rust detection and binding generation This commit updates the build system to automatically detect cargo and enable/disable _base64 without needing to pass a flag. It also updates cpython-sys to use a hand written header (which is what Linux seems to do) and splits off the parser bindings to be handled in the future (since the files are included differently). --- Makefile.pre.in | 7 ++-- Modules/cpython-sys/build.rs | 26 +++++++------ Modules/cpython-sys/parser.h | 11 ++++++ Modules/cpython-sys/src/lib.rs | 5 ++- Modules/makesetup | 2 +- Python/remote_debug.h | 1 - Tools/build/regen-rust-wrapper-h.py | 34 ---------------- configure | 60 +++++++++++------------------ configure.ac | 59 ++++++++++++---------------- 9 files changed, 80 insertions(+), 125 deletions(-) create mode 100644 Modules/cpython-sys/parser.h delete mode 100644 Tools/build/regen-rust-wrapper-h.py diff --git a/Makefile.pre.in b/Makefile.pre.in index 6d113d14f31630..a27a9709330772 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1652,10 +1652,6 @@ Makefile Modules/config.c: Makefile.pre \ @mv config.c Modules @echo "The Makefile was updated, you may need to re-run make." -.PHONY: regen-rust-wrapper-h -regen-rust-wrapper-h: $(PYTHON_HEADERS) - PYTHON_HEADERS="$(PYTHON_HEADERS)" $(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/regen-rust-wrapper-h.py - .PHONY: regen-test-frozenmain regen-test-frozenmain: $(BUILDPYTHON) # Regenerate Programs/test_frozenmain.h @@ -3376,6 +3372,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 build --lib --locked --package cpython-sys --profile $(CARGO_PROFILE) + # 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@ diff --git a/Modules/cpython-sys/build.rs b/Modules/cpython-sys/build.rs index c45ccc0b2684c7..de79d3c4940c9a 100644 --- a/Modules/cpython-sys/build.rs +++ b/Modules/cpython-sys/build.rs @@ -4,25 +4,29 @@ use std::path::{Path, PathBuf}; fn main() { let curdir = std::env::current_dir().unwrap(); let srcdir = curdir.parent().and_then(Path::parent).unwrap(); + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + generate_c_api_bindings(srcdir, &out_path.as_path()); + // TODO(emmatyping): generate bindings to the internal parser API + // The parser includes things slightly differently, so we should generate + // it's bindings independently + //generate_parser_bindings(srcdir, &out_path.as_path()); +} + +fn generate_c_api_bindings(srcdir: &Path, out_path: &Path) { let bindings = bindgen::Builder::default() .header("wrapper.h") .clang_arg(format!("-I{}", srcdir.as_os_str().to_str().unwrap())) .clang_arg(format!("-I{}/Include", srcdir.as_os_str().to_str().unwrap())) - .clang_arg(format!("-I{}/Include/internal", srcdir.as_os_str().to_str().unwrap())) - .allowlist_function("Py.*") - .allowlist_function("_Py.*") - .allowlist_type("Py.*") - .allowlist_type("_Py.*") - .allowlist_var("Py.*") - .allowlist_var("_Py.*") + .allowlist_function("_?Py.*") + .allowlist_type("_?Py.*") + .allowlist_var("_?Py.*") .blocklist_type("^PyMethodDef$") .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) .generate() .expect("Unable to generate bindings"); - // Write the bindings to the $OUT_DIR/bindings.rs file. - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + // Write the bindings to the $OUT_DIR/c_api.rs file. bindings - .write_to_file(out_path.join("bindings.rs")) + .write_to_file(out_path.join("c_api.rs")) .expect("Couldn't write bindings!"); -} +} \ No newline at end of file diff --git a/Modules/cpython-sys/parser.h b/Modules/cpython-sys/parser.h new file mode 100644 index 00000000000000..e58539b7236611 --- /dev/null +++ b/Modules/cpython-sys/parser.h @@ -0,0 +1,11 @@ +/* Private APIs */ +#define Py_BUILD_CORE + +// Parser +#include "Parser/pegen.h" +#include "Parser/string_parser.h" +#include "Parser/lexer/buffer.h" +#include "Parser/lexer/lexer.h" +#include "Parser/lexer/state.h" +#include "Parser/tokenizer/tokenizer.h" +#include "Parser/tokenizer/helpers.h" diff --git a/Modules/cpython-sys/src/lib.rs b/Modules/cpython-sys/src/lib.rs index 6c0b84d70ebc87..d3e21662a68472 100644 --- a/Modules/cpython-sys/src/lib.rs +++ b/Modules/cpython-sys/src/lib.rs @@ -6,7 +6,10 @@ use std::ffi::{c_char, c_int, c_void}; -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); +include!(concat!(env!("OUT_DIR"), "/c_api.rs")); + +// TODO(emmatyping): include parser bindings (see build.rs) +//include!(concat!(env!("OUT_DIR"), "/parser.rs")); /* Flag passed to newmethodobject */ /* #define METH_OLDARGS 0x0000 -- unsupported now */ pub const METH_VARARGS: c_int = 0x0001; diff --git a/Modules/makesetup b/Modules/makesetup index 773de9117f4a22..b5fb40994a010b 100755 --- a/Modules/makesetup +++ b/Modules/makesetup @@ -286,7 +286,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | done libs= # depends on the headers through cpython-sys - rule="$objs: \$(srcdir)/Cargo.toml \$(srcdir)/Cargo.lock \$(srcdir)/$srcdir/$manifest Modules/cpython-sys/wrapper.h $prefixed_srcs \$(PYTHON_HEADERS)" + rule="$objs: cpython-sys \$(srcdir)/Cargo.toml \$(srcdir)/Cargo.lock \$(srcdir)/$srcdir/$manifest $prefixed_srcs \$(PYTHON_HEADERS)" rule="$rule; cargo build --lib --locked --package ${mods} --profile \$(CARGO_PROFILE)" echo "$rule" >>$rulesf for mod in $mods diff --git a/Python/remote_debug.h b/Python/remote_debug.h index eac7f2aee132eb..e7676013197fa9 100644 --- a/Python/remote_debug.h +++ b/Python/remote_debug.h @@ -29,7 +29,6 @@ extern "C" { #include "pyconfig.h" #include "internal/pycore_ceval.h" -#include "internal/pycore_debug_offsets.h" #ifdef __linux__ # include diff --git a/Tools/build/regen-rust-wrapper-h.py b/Tools/build/regen-rust-wrapper-h.py deleted file mode 100644 index 998d808ea40ac2..00000000000000 --- a/Tools/build/regen-rust-wrapper-h.py +++ /dev/null @@ -1,34 +0,0 @@ -import os -import re -from pathlib import Path - -ROOT = Path(__file__).resolve().parents[2] -WRAPPER_H = ROOT / "Modules" / "cpython-sys" / "wrapper.h" -SKIP_PREFIXES = ("cpython/",) -SKIP_EXACT = { - "internal/pycore_crossinterp_data_registry.h", -} - -def normalize_path(header: str) -> str: - return re.sub(r'(:?\.\/)(:?Include\/)?', '', header) - -def main(output: str = WRAPPER_H) -> None: - headers = os.environ.get("PYTHON_HEADERS") - if headers is None: - raise RuntimeError("Unable to read $PYTHON_HEADERS!") - with open(output, "w") as f: - f.write("#define Py_BUILD_CORE\n") - f.write("#include \"Modules/expat/expat.h\"\n") - for header in headers.split(): - normalized_path = normalize_path(header) - if normalized_path.startswith(SKIP_PREFIXES): - continue - if normalized_path in SKIP_EXACT: - continue - f.write(f"#include \"{normalized_path}\"\n") - if normalized_path == "Python/remote_debug.h": - f.write("#undef UNUSED\n") - -if __name__ == "__main__": - import sys - main(*sys.argv[1:]) diff --git a/configure b/configure index 0a114e20c00c30..26272126bc0209 100755 --- a/configure +++ b/configure @@ -1122,7 +1122,6 @@ with_libs with_system_expat with_system_libmpdec with_decimal_contextvar -with_rust_base64 enable_loadable_sqlite_extensions with_dbmliborder enable_ipv6 @@ -1924,8 +1923,6 @@ Optional Packages: --with-decimal-contextvar build _decimal module using a coroutine-local rather than a thread-local context (default is yes) - --with-rust-base64 build _base64 module using the SIMD accelerated Rust - implementation --with-dbmliborder=db1:db2:... override order to check db backends for dbm; a valid value is a colon separated string with the backend @@ -16043,28 +16040,14 @@ fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-rust-base64" >&5 -printf %s "checking for --with-rust-base64... " >&6; } - -# Check whether --with-rust_base64 was given. -if test ${with_rust_base64+y} -then : - withval=$with_rust_base64; rust_base64="yes" -else case e in #( - e) rust_base64="no" ;; -esac +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Rust" >&5 +printf %s "checking for Rust... " >&6; } +CARGO_TARGET_DIR= +CARGO_PROFILE= +if test "x$CARGO_HOME" = "x"; then + CARGO_HOME="$HOME/.cargo" fi - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $rust_base64" >&5 -printf "%s\n" "$rust_base64" >&6; } - -if test "x$rust_base64" = xyes -then : - - if test "$CARGO_HOME+set" != "set"; then - CARGO_HOME="$HOME/.cargo" - fi - # Extract the first word of "cargo", so it can be a program name with args. +# Extract the first word of "cargo", so it can be a program name with args. set dummy cargo; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } @@ -16108,22 +16091,23 @@ printf "%s\n" "no" >&6; } fi - if test $HAS_CARGO = "not-found"; then - as_fn_error $? "Could not find cargo. Please re-run configure with \$CARGO_HOME set" "$LINENO" 5 - fi - if test "$Py_OPT" = 'true'; then - CARGO_TARGET_DIR='release' - CARGO_PROFILE='release' - else - CARGO_TARGET_DIR='debug' - CARGO_PROFILE='dev' - fi - - +if test $HAS_CARGO = "not-found"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: n/a" >&5 +printf "%s\n" "n/a" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Could not find the cargo executable. It can be installed via rustup" >&5 +printf "%s\n" "$as_me: WARNING: Could not find the cargo executable. It can be installed via rustup" >&2;} +else + if test "$Py_OPT" = 'true'; then + CARGO_TARGET_DIR='release' + CARGO_PROFILE='release' + else + CARGO_TARGET_DIR='debug' + CARGO_PROFILE='dev' + fi +fi -fi @@ -33577,7 +33561,7 @@ then : if true then : - if test "$rust_base64" = "yes" + if test "$HAS_CARGO" = "found" then : py_cv_module__base64=yes else case e in #( diff --git a/configure.ac b/configure.ac index 9b1a035f0ccc2f..248cfe9270dfc7 100644 --- a/configure.ac +++ b/configure.ac @@ -4309,40 +4309,29 @@ AC_SUBST([LIBMPDEC_INTERNAL]) dnl Try to detect cargo in the environment. Cargo and rustup dnl install into CARGO_HOME and RUSTUP_HOME, so check for those initially -AC_MSG_CHECKING([for --with-rust-base64]) -AC_ARG_WITH( - [rust_base64], - [AS_HELP_STRING( - [--with-rust-base64], - [build _base64 module using the SIMD accelerated Rust implementation] - )], - [rust_base64="yes"], - [rust_base64="no"]) -AC_MSG_RESULT([$rust_base64]) - -AS_VAR_IF( - [rust_base64], [yes], - [ - if test "$CARGO_HOME+set" != "set"; then - dnl try to guess the default UNIX value of ~/.cargo - CARGO_HOME="$HOME/.cargo" - fi - AC_CHECK_PROG(HAS_CARGO, [cargo], ["$CARGO_HOME"], [found], [not-found]) - if test $HAS_CARGO = "not-found"; then - AC_MSG_ERROR([Could not find cargo. Please re-run configure with \$CARGO_HOME set]) - fi - if test "$Py_OPT" = 'true'; then - CARGO_TARGET_DIR='release' - CARGO_PROFILE='release' - else - CARGO_TARGET_DIR='debug' - CARGO_PROFILE='dev' - fi - AC_SUBST([CARGO_HOME]) - AC_SUBST([CARGO_TARGET_DIR]) - AC_SUBST([CARGO_PROFILE]) - ] -) +AC_MSG_CHECKING([for Rust]) +CARGO_TARGET_DIR= +CARGO_PROFILE= +if test "x$CARGO_HOME" = "x"; then + dnl try to guess the default UNIX value of ~/.cargo + CARGO_HOME="$HOME/.cargo" +fi +AC_CHECK_PROG(HAS_CARGO, [cargo], ["$CARGO_HOME"], [found], [not-found]) +if test $HAS_CARGO = "not-found"; then + AC_MSG_RESULT([n/a]) + AC_MSG_WARN([Could not find the cargo executable. It can be installed via rustup]) +else + if test "$Py_OPT" = 'true'; then + CARGO_TARGET_DIR='release' + CARGO_PROFILE='release' + else + CARGO_TARGET_DIR='debug' + CARGO_PROFILE='dev' + fi +fi +AC_SUBST([CARGO_HOME]) +AC_SUBST([CARGO_TARGET_DIR]) +AC_SUBST([CARGO_PROFILE]) dnl detect sqlite3 from Emscripten emport @@ -8194,7 +8183,7 @@ PY_STDLIB_MOD([_uuid], [$LIBUUID_CFLAGS], [$LIBUUID_LIBS]) PY_STDLIB_MOD([_base64], - [], [test "$rust_base64" = "yes"], + [], [test "$HAS_CARGO" = "found"], [], []) dnl compression libs From eafc06508241da710741f29e7d9182cc9a8d61f6 Mon Sep 17 00:00:00 2001 From: Emma Harper Smith Date: Sun, 16 Nov 2025 16:13:14 -0800 Subject: [PATCH 2/4] Add missing newline --- Modules/cpython-sys/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/cpython-sys/build.rs b/Modules/cpython-sys/build.rs index de79d3c4940c9a..71b73b477fd34d 100644 --- a/Modules/cpython-sys/build.rs +++ b/Modules/cpython-sys/build.rs @@ -29,4 +29,4 @@ fn generate_c_api_bindings(srcdir: &Path, out_path: &Path) { bindings .write_to_file(out_path.join("c_api.rs")) .expect("Couldn't write bindings!"); -} \ No newline at end of file +} From 4ed45efb04b87820efdeb89c196fcbb3da66a104 Mon Sep 17 00:00:00 2001 From: Emma Harper Smith Date: Sun, 16 Nov 2025 17:15:50 -0800 Subject: [PATCH 3/4] Add wrapper.h file --- Modules/cpython-sys/.gitignore | 1 - Modules/cpython-sys/wrapper.h | 177 +++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 1 deletion(-) delete mode 100644 Modules/cpython-sys/.gitignore create mode 100644 Modules/cpython-sys/wrapper.h diff --git a/Modules/cpython-sys/.gitignore b/Modules/cpython-sys/.gitignore deleted file mode 100644 index 3536502b83a7c0..00000000000000 --- a/Modules/cpython-sys/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/wrapper.h \ No newline at end of file diff --git a/Modules/cpython-sys/wrapper.h b/Modules/cpython-sys/wrapper.h new file mode 100644 index 00000000000000..f79a44f0580633 --- /dev/null +++ b/Modules/cpython-sys/wrapper.h @@ -0,0 +1,177 @@ +/* Public APIs */ +#include "Python.h" + +// Misc + +// OS macros used in C, not necessary in Rust +//#include "osdefs.h" + +// Valgrind / analysis tools macros and functions +#include "dynamic_annotations.h" +// Macros for error codes +// #include "errcode.h" +// Macros to define symbol visibility +// #include "exports.h" +// Includes pyframe.h and cpython/frameobject.h +#include "frameobject.h" +// Includes cpython/marshal.h +#include "marshal.h" +// Macros defining opcodes +#include "opcode.h" +// More macros defining opcodes +#include "opcode_ids.h" +// Dtrace probes +#include "pydtrace.h" +//New code should use descrobject.h +//#include "structmember.h" + +// List of all stdlib names, autogenerated +#include "Python/stdlib_module_names.h" + +/* Private APIs */ +#define Py_BUILD_CORE + +// Internal +#include "internal/pycore_parser.h" +#include "internal/pycore_mimalloc.h" +#include "internal/mimalloc/mimalloc.h" +#include "internal/mimalloc/mimalloc/atomic.h" +#include "internal/mimalloc/mimalloc/internal.h" +#include "internal/mimalloc/mimalloc/prim.h" +#include "internal/mimalloc/mimalloc/track.h" +#include "internal/mimalloc/mimalloc/types.h" +#include "internal/pycore_abstract.h" +#include "internal/pycore_asdl.h" +#include "internal/pycore_ast.h" +#include "internal/pycore_ast_state.h" +#include "internal/pycore_atexit.h" +#include "internal/pycore_audit.h" +#include "internal/pycore_backoff.h" +#include "internal/pycore_bitutils.h" +#include "internal/pycore_blocks_output_buffer.h" +#include "internal/pycore_brc.h" +#include "internal/pycore_bytes_methods.h" +#include "internal/pycore_bytesobject.h" +#include "internal/pycore_call.h" +#include "internal/pycore_capsule.h" +#include "internal/pycore_cell.h" +#include "internal/pycore_ceval.h" +#include "internal/pycore_ceval_state.h" +#include "internal/pycore_code.h" +#include "internal/pycore_codecs.h" +#include "internal/pycore_compile.h" +#include "internal/pycore_complexobject.h" +#include "internal/pycore_condvar.h" +#include "internal/pycore_context.h" +#include "internal/pycore_critical_section.h" +#include "internal/pycore_crossinterp.h" +#include "internal/pycore_debug_offsets.h" +#include "internal/pycore_descrobject.h" +#include "internal/pycore_dict.h" +#include "internal/pycore_dict_state.h" +#include "internal/pycore_dtoa.h" +#include "internal/pycore_exceptions.h" +#include "internal/pycore_faulthandler.h" +#include "internal/pycore_fileutils.h" +#include "internal/pycore_floatobject.h" +#include "internal/pycore_flowgraph.h" +#include "internal/pycore_format.h" +#include "internal/pycore_frame.h" +#include "internal/pycore_freelist.h" +#include "internal/pycore_freelist_state.h" +#include "internal/pycore_function.h" +#include "internal/pycore_gc.h" +#include "internal/pycore_genobject.h" +#include "internal/pycore_getopt.h" +#include "internal/pycore_gil.h" +#include "internal/pycore_global_objects.h" +#include "internal/pycore_global_objects_fini_generated.h" +#include "internal/pycore_global_strings.h" +#include "internal/pycore_hamt.h" +#include "internal/pycore_hashtable.h" +#include "internal/pycore_import.h" +#include "internal/pycore_importdl.h" +#include "internal/pycore_index_pool.h" +#include "internal/pycore_initconfig.h" +#include "internal/pycore_instruments.h" +#include "internal/pycore_instruction_sequence.h" +#include "internal/pycore_interp.h" +#include "internal/pycore_interp_structs.h" +#include "internal/pycore_interpframe.h" +#include "internal/pycore_interpframe_structs.h" +#include "internal/pycore_interpolation.h" +#include "internal/pycore_intrinsics.h" +#include "internal/pycore_jit.h" +#include "internal/pycore_list.h" +#include "internal/pycore_llist.h" +#include "internal/pycore_lock.h" +#include "internal/pycore_long.h" +#include "internal/pycore_memoryobject.h" +#include "internal/pycore_mimalloc.h" +#include "internal/pycore_modsupport.h" +#include "internal/pycore_moduleobject.h" +#include "internal/pycore_namespace.h" +#include "internal/pycore_object.h" +#include "internal/pycore_object_alloc.h" +#include "internal/pycore_object_deferred.h" +#include "internal/pycore_object_stack.h" +#include "internal/pycore_object_state.h" +#include "internal/pycore_obmalloc.h" +#include "internal/pycore_obmalloc_init.h" +#include "internal/pycore_opcode_metadata.h" +#include "internal/pycore_opcode_utils.h" +#include "internal/pycore_optimizer.h" +#include "internal/pycore_parking_lot.h" +#include "internal/pycore_parser.h" +#include "internal/pycore_pathconfig.h" +#include "internal/pycore_pyarena.h" +#include "internal/pycore_pyatomic_ft_wrappers.h" +#include "internal/pycore_pybuffer.h" +#include "internal/pycore_pyerrors.h" +#include "internal/pycore_pyhash.h" +#include "internal/pycore_pylifecycle.h" +#include "internal/pycore_pymath.h" +#include "internal/pycore_pymem.h" +#include "internal/pycore_pymem_init.h" +#include "internal/pycore_pystate.h" +#include "internal/pycore_pystats.h" +#include "internal/pycore_pythonrun.h" +#include "internal/pycore_pythread.h" +#include "internal/pycore_qsbr.h" +#include "internal/pycore_range.h" +#include "internal/pycore_runtime.h" +#include "internal/pycore_runtime_init.h" +#include "internal/pycore_runtime_init_generated.h" +#include "internal/pycore_runtime_structs.h" +#include "internal/pycore_semaphore.h" +#include "internal/pycore_setobject.h" +#include "internal/pycore_signal.h" +#include "internal/pycore_sliceobject.h" +#include "internal/pycore_stats.h" +#include "internal/pycore_strhex.h" +#include "internal/pycore_stackref.h" +#include "internal/pycore_structs.h" +#include "internal/pycore_structseq.h" +#include "internal/pycore_symtable.h" +#include "internal/pycore_sysmodule.h" +#include "internal/pycore_template.h" +#include "internal/pycore_time.h" +#include "internal/pycore_token.h" +#include "internal/pycore_traceback.h" +#include "internal/pycore_tracemalloc.h" +#include "internal/pycore_tstate.h" +#include "internal/pycore_tuple.h" +#include "internal/pycore_typedefs.h" +#include "internal/pycore_typeobject.h" +#include "internal/pycore_typevarobject.h" +#include "internal/pycore_ucnhash.h" +#include "internal/pycore_unicodectype.h" +#include "internal/pycore_unicodeobject.h" +#include "internal/pycore_unicodeobject_generated.h" +#include "internal/pycore_unionobject.h" +#include "internal/pycore_uniqueid.h" +#include "internal/pycore_uop.h" +#include "internal/pycore_uop_ids.h" +#include "internal/pycore_uop_metadata.h" +#include "internal/pycore_warnings.h" +#include "internal/pycore_weakref.h" From 91ae8454958360a128ed4805a7d9a9521606b496 Mon Sep 17 00:00:00 2001 From: Emma Harper Smith Date: Sun, 16 Nov 2025 22:54:49 -0800 Subject: [PATCH 4/4] Disable _base64 if Rust is unavailable --- configure | 28 ++++++++++++++-------------- configure.ac | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 26272126bc0209..fb959ad79bf6cb 100755 --- a/configure +++ b/configure @@ -890,7 +890,7 @@ LIBSQLITE3_CFLAGS CARGO_PROFILE CARGO_TARGET_DIR CARGO_HOME -HAS_CARGO +HAVE_CARGO LIBMPDEC_INTERNAL LIBMPDEC_LIBS LIBMPDEC_CFLAGS @@ -16051,15 +16051,15 @@ fi set dummy cargo; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_HAS_CARGO+y} +if test ${ac_cv_prog_HAVE_CARGO+y} then : printf %s "(cached) " >&6 else case e in #( - e) if test -n "$HAS_CARGO"; then - ac_cv_prog_HAS_CARGO="$HAS_CARGO" # Let the user override the test. + e) if test -n "$HAVE_CARGO"; then + ac_cv_prog_HAVE_CARGO="$HAVE_CARGO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in not-found +for as_dir in no do IFS=$as_save_IFS case $as_dir in #((( @@ -16069,7 +16069,7 @@ do esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_HAS_CARGO=""$CARGO_HOME"" + ac_cv_prog_HAVE_CARGO=""$CARGO_HOME"" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi @@ -16077,21 +16077,21 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_prog_HAS_CARGO" && ac_cv_prog_HAS_CARGO="found" + test -z "$ac_cv_prog_HAVE_CARGO" && ac_cv_prog_HAVE_CARGO="yes" fi ;; esac fi -HAS_CARGO=$ac_cv_prog_HAS_CARGO -if test -n "$HAS_CARGO"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $HAS_CARGO" >&5 -printf "%s\n" "$HAS_CARGO" >&6; } +HAVE_CARGO=$ac_cv_prog_HAVE_CARGO +if test -n "$HAVE_CARGO"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $HAVE_CARGO" >&5 +printf "%s\n" "$HAVE_CARGO" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi -if test $HAS_CARGO = "not-found"; then +if test $HAVE_CARGO = "no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: n/a" >&5 printf "%s\n" "n/a" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Could not find the cargo executable. It can be installed via rustup" >&5 @@ -33559,9 +33559,9 @@ printf %s "checking for stdlib extension module _base64... " >&6; } if test "$py_cv_module__base64" != "n/a" then : - if true + if test "$HAVE_CARGO" = yes then : - if test "$HAS_CARGO" = "found" + if test "$HAVE_CARGO" = yes then : py_cv_module__base64=yes else case e in #( diff --git a/configure.ac b/configure.ac index 248cfe9270dfc7..83a4c006c4feca 100644 --- a/configure.ac +++ b/configure.ac @@ -4316,8 +4316,8 @@ if test "x$CARGO_HOME" = "x"; then dnl try to guess the default UNIX value of ~/.cargo CARGO_HOME="$HOME/.cargo" fi -AC_CHECK_PROG(HAS_CARGO, [cargo], ["$CARGO_HOME"], [found], [not-found]) -if test $HAS_CARGO = "not-found"; then +AC_CHECK_PROG(HAVE_CARGO, [cargo], ["$CARGO_HOME"], [yes], [no]) +if test $HAVE_CARGO = "no"; then AC_MSG_RESULT([n/a]) AC_MSG_WARN([Could not find the cargo executable. It can be installed via rustup]) else @@ -8183,7 +8183,7 @@ PY_STDLIB_MOD([_uuid], [$LIBUUID_CFLAGS], [$LIBUUID_LIBS]) PY_STDLIB_MOD([_base64], - [], [test "$HAS_CARGO" = "found"], + [test "$HAVE_CARGO" = yes], [test "$HAVE_CARGO" = yes], [], []) dnl compression libs