From ba0bbc2f7c13c3b4f99ae8934bf0013335f20234 Mon Sep 17 00:00:00 2001 From: messense Date: Sat, 25 Feb 2023 09:48:29 +0800 Subject: [PATCH 01/10] Record `generate-ci` command arguments in generate configuration --- src/ci.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/ci.rs b/src/ci.rs index d4ec73066..2896a7b55 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -149,8 +149,23 @@ impl GenerateCI { | BridgeModel::Cffi | BridgeModel::UniFfi ); + let gen_cmd = std::env::args() + .enumerate() + .map(|(i, arg)| { + if i == 0 { + env!("CARGO_PKG_NAME").to_string() + } else { + arg + } + }) + .collect::>() + .join(" "); let mut conf = format!( - "# Generated by maturin v{version} + "# This file is autogenerated by maturin v{version} +# To update, run +# +# {gen_cmd} +# on: push: branches: @@ -429,7 +444,7 @@ mod tests { .generate_github("example", &BridgeModel::Bindings("pyo3".to_string(), 7)) .unwrap() .lines() - .skip(1) + .skip(5) .collect::>() .join("\n"); let expected = indoc! {r#" @@ -533,7 +548,7 @@ mod tests { .generate_github("example", &BridgeModel::BindingsAbi3(3, 7)) .unwrap() .lines() - .skip(1) + .skip(5) .collect::>() .join("\n"); let expected = indoc! {r#" @@ -642,7 +657,7 @@ mod tests { .generate_github("example", &BridgeModel::Bindings("pyo3".to_string(), 7)) .unwrap() .lines() - .skip(1) + .skip(5) .collect::>() .join("\n"); let expected = indoc! {r#" @@ -785,7 +800,7 @@ mod tests { .generate_github("example", &BridgeModel::Bin(None)) .unwrap() .lines() - .skip(1) + .skip(5) .collect::>() .join("\n"); let expected = indoc! {r#" From 204be1da9cb61890c4db8145758f545fcdcbf0e7 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 27 Feb 2023 09:49:17 +0800 Subject: [PATCH 02/10] Build maturin with native-tls support on aarch64 Windows --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e925fd24f..28ac3328f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,7 +85,7 @@ jobs: # ring doesn't support aarch64 windows yet - name: Build wheel (windows aarch64) if: matrix.target == 'aarch64-pc-windows-msvc' - run: cargo run -- build --release -b bin -o dist --target ${{ matrix.target }} --no-default-features --features log,upload + run: cargo run -- build --release -b bin -o dist --target ${{ matrix.target }} --no-default-features --features log,upload,native-tls - name: Build wheel (without sdist) if: ${{ matrix.target != 'x86_64-unknown-linux-musl' && matrix.target != 'aarch64-pc-windows-msvc' }} From 3039f223b6c7815e2ef6e175c7d99d3235fbc696 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 27 Feb 2023 12:18:15 +0800 Subject: [PATCH 03/10] refactor: use stderr for human readable output Reserve stdout for machine-parsable output --- src/auditwheel/audit.rs | 2 +- src/build_context.rs | 16 ++++++++-------- src/build_options.rs | 16 ++++++++-------- src/develop.rs | 2 +- src/main.rs | 4 ++-- src/metadata.rs | 2 +- src/module_writer.rs | 18 +++++++++--------- src/new_project.rs | 4 ++-- src/python_interpreter/mod.rs | 2 +- src/source_distribution.rs | 4 ++-- src/upload.rs | 16 ++++++++-------- 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/auditwheel/audit.rs b/src/auditwheel/audit.rs index 3235f4d5c..72c80dc43 100644 --- a/src/auditwheel/audit.rs +++ b/src/auditwheel/audit.rs @@ -344,7 +344,7 @@ pub fn auditwheel_rs( if let Some(highest_policy) = highest_policy { // Don't recommend manylinux1 because rust doesn't support it anymore if policy.priority < highest_policy.priority && highest_policy.name != "manylinux_2_5" { - println!( + eprintln!( "📦 Wheel is eligible for a higher priority tag. \ You requested {policy} but this wheel is eligible for {highest_policy}", ); diff --git a/src/build_context.rs b/src/build_context.rs index f2e8e8221..a2fbfb90d 100644 --- a/src/build_context.rs +++ b/src/build_context.rs @@ -280,7 +280,7 @@ impl BuildContext { && self.target.is_linux() && !python_interpreter.support_portable_wheels() { - println!( + eprintln!( "🐍 Skipping auditwheel because {python_interpreter} does not support manylinux/musllinux wheels" ); return Ok((Policy::default(), Vec::new())); @@ -444,12 +444,12 @@ impl BuildContext { writer.add_file_with_permissions(libs_dir.join(new_soname), path, 0o755)?; } - println!( + eprintln!( "🖨 Copied external shared libraries to package {} directory:", libs_dir.display() ); for lib_path in libs_copied { - println!(" {}", lib_path.display()); + eprintln!(" {}", lib_path.display()); } // Currently artifact .so file always resides at ${module_name}/${module_name}.so @@ -571,7 +571,7 @@ impl BuildContext { min_minor, )?; - println!( + eprintln!( "📦 Built wheel for abi3 Python ≥ {}.{} to {}", major, min_minor, @@ -652,7 +652,7 @@ impl BuildContext { &platform_tags, external_libs, )?; - println!( + eprintln!( "📦 Built wheel for {} {}.{}{} to {}", python_interpreter.interpreter_kind, python_interpreter.major, @@ -814,7 +814,7 @@ impl BuildContext { ); } - println!("📦 Built wheel to {}", wheel_path.display()); + eprintln!("📦 Built wheel to {}", wheel_path.display()); wheels.push((wheel_path, tag)); Ok(wheels) @@ -869,7 +869,7 @@ impl BuildContext { }; let (wheel_path, tag) = self.write_uniffi_wheel(artifact, &platform_tags, external_libs)?; - println!("📦 Built wheel to {}", wheel_path.display()); + eprintln!("📦 Built wheel to {}", wheel_path.display()); wheels.push((wheel_path, tag)); Ok(wheels) @@ -1006,7 +1006,7 @@ impl BuildContext { &platform_tags, &ext_libs, )?; - println!("📦 Built wheel to {}", wheel_path.display()); + eprintln!("📦 Built wheel to {}", wheel_path.display()); wheels.push((wheel_path, tag)); Ok(wheels) diff --git a/src/build_options.rs b/src/build_options.rs index 0f1ea3596..ab23d5cdc 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -237,7 +237,7 @@ impl BuildOptions { min_python_minor, )?; let host_python = &host_interpreters[0]; - println!("🐍 Using host {host_python} for cross-compiling preparation"); + eprintln!("🐍 Using host {host_python} for cross-compiling preparation"); // pyo3 env::set_var("PYO3_PYTHON", &host_python.executable); // rust-cpython, and legacy pyo3 versions @@ -326,14 +326,14 @@ impl BuildOptions { .map(ToString::to_string) .collect::>() .join(", "); - println!("🐍 Found {interpreters_str}"); + eprintln!("🐍 Found {interpreters_str}"); Ok(interpreters) } BridgeModel::Cffi => { let interpreter = find_single_python_interpreter(bridge, interpreter, target, "cffi")?; - println!("🐍 Using {interpreter} to generate the cffi bindings"); + eprintln!("🐍 Using {interpreter} to generate the cffi bindings"); Ok(vec![interpreter]) } BridgeModel::Bin(None) | BridgeModel::UniFfi => Ok(vec![]), @@ -352,7 +352,7 @@ impl BuildOptions { if env::var_os("PYO3_CROSS_LIB_DIR").is_some() { // PYO3_CROSS_LIB_DIR should point to the `libs` directory inside base_prefix // when cross compiling, so we fake a python interpreter matching it - println!("⚠️ Cross-compiling is poorly supported"); + eprintln!("⚠️ Cross-compiling is poorly supported"); Ok(vec![PythonInterpreter { config: InterpreterConfig { major: *major as usize, @@ -375,10 +375,10 @@ impl BuildOptions { .context("Invalid PYO3_CONFIG_FILE")?; Ok(vec![PythonInterpreter::from_config(interpreter_config)]) } else if let Some(interp) = interpreters.get(0) { - println!("🐍 Using {interp} to generate to link bindings (With abi3, an interpreter is only required on windows)"); + eprintln!("🐍 Using {interp} to generate to link bindings (With abi3, an interpreter is only required on windows)"); Ok(interpreters) } else if generate_import_lib { - println!("🐍 Not using a specific python interpreter (Automatically generating windows import library)"); + eprintln!("🐍 Not using a specific python interpreter (Automatically generating windows import library)"); // fake a python interpreter Ok(vec![PythonInterpreter { config: InterpreterConfig { @@ -420,7 +420,7 @@ impl BuildOptions { Ok(interps) } })?; - println!("🐍 Not using a specific python interpreter"); + eprintln!("🐍 Not using a specific python interpreter"); if self.interpreter.is_empty() { // Fake one to make `BuildContext::build_wheels` happy for abi3 when no cpython/pypy found on host // The python interpreter config doesn't matter, as it's not used for anything @@ -744,7 +744,7 @@ fn get_min_python_minor(metadata21: &Metadata21) -> Option { .expect("Regex must only match usize"); Some(min_python_minor) } else { - println!( + eprintln!( "⚠️ Couldn't parse the value of requires-python, \ not taking it into account when searching for python interpreter. \ Note: Only `>=3.x.y` is currently supported." diff --git a/src/develop.rs b/src/develop.rs index faf50b412..bdfcd020e 100644 --- a/src/develop.rs +++ b/src/develop.rs @@ -131,7 +131,7 @@ pub fn develop( String::from_utf8_lossy(&output.stderr).trim(), ); } - println!( + eprintln!( "🛠 Installed {}-{}", build_context.metadata21.name, build_context.metadata21.version ); diff --git a/src/main.rs b/src/main.rs index ed4680645..abe40d786 100644 --- a/src/main.rs +++ b/src/main.rs @@ -393,9 +393,9 @@ fn run() -> Result<()> { // We don't know the targeted bindings yet, so we use the most lenient PythonInterpreter::find_all(&target, &BridgeModel::Cffi, None)? }; - println!("🐍 {} python interpreter found:", found.len()); + eprintln!("🐍 {} python interpreter found:", found.len()); for interpreter in found { - println!(" - {interpreter}"); + eprintln!(" - {interpreter}"); } } Opt::Develop { diff --git a/src/metadata.rs b/src/metadata.rs index 482e24c31..90f64e570 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -168,7 +168,7 @@ impl Metadata21 { // if the pyproject.toml specified the license file, // then we won't list it as automatically included if !self.license_files.contains(&license_path) { - println!("📦 Including license file \"{}\"", license_path.display()); + eprintln!("📦 Including license file \"{}\"", license_path.display()); self.license_files.push(license_path); } } diff --git a/src/module_writer.rs b/src/module_writer.rs index 33b00e588..d2f75fb2b 100644 --- a/src/module_writer.rs +++ b/src/module_writer.rs @@ -545,11 +545,11 @@ fn cffi_header(crate_dir: &Path, target_dir: &Path, tempdir: &TempDir) -> Result let maybe_header = target_dir.join("header.h"); if maybe_header.is_file() { - println!("💼 Using the existing header at {}", maybe_header.display()); + eprintln!("💼 Using the existing header at {}", maybe_header.display()); Ok(maybe_header) } else { if crate_dir.join("cbindgen.toml").is_file() { - println!( + eprintln!( "💼 Using the existing cbindgen.toml configuration. \n\ 💼 Enforcing the following settings: \n \ - language = \"C\" \n \ @@ -631,7 +631,7 @@ recompiler.make_py_source(ffi, "ffi", r"{ffi_py}") "True" => true, "False" => false, _ => { - println!( + eprintln!( "⚠️ Failed to determine whether python at {:?} is running inside a virtualenv", &python ); @@ -650,7 +650,7 @@ recompiler.make_py_source(ffi, "ffi", r"{ffi_py}") return handle_cffi_call_result(python, tempdir, &ffi_py, &output); } - println!("⚠️ cffi not found. Trying to install it"); + eprintln!("⚠️ cffi not found. Trying to install it"); // Call pip through python to don't do the wrong thing when python and pip // are coming from different environments let output = call_python( @@ -672,7 +672,7 @@ recompiler.make_py_source(ffi, "ffi", r"{ffi_py}") str::from_utf8(&output.stderr)? ); } - println!("🎁 Installed cffi"); + eprintln!("🎁 Installed cffi"); // Try again let output = call_python(python, ["-c", &cffi_invocation])?; @@ -780,7 +780,7 @@ if hasattr({module_name}, "__all__"): .rust_module .join(format!("{module_name}.pyi")); if type_stub.exists() { - println!("📖 Found type stub file at {module_name}.pyi"); + eprintln!("📖 Found type stub file at {module_name}.pyi"); writer.add_file(&module.join("__init__.pyi"), type_stub)?; writer.add_bytes(&module.join("py.typed"), b"")?; } @@ -840,7 +840,7 @@ pub fn write_cffi_module( .rust_module .join(format!("{module_name}.pyi")); if type_stub.exists() { - println!("📖 Found type stub file at {module_name}.pyi"); + eprintln!("📖 Found type stub file at {module_name}.pyi"); writer.add_file(&module.join("__init__.pyi"), type_stub)?; writer.add_bytes(&module.join("py.typed"), b"")?; } @@ -1013,7 +1013,7 @@ pub fn write_uniffi_module( .rust_module .join(format!("{module_name}.pyi")); if type_stub.exists() { - println!("📖 Found type stub file at {module_name}.pyi"); + eprintln!("📖 Found type stub file at {module_name}.pyi"); writer.add_file(&module.join("__init__.pyi"), type_stub)?; writer.add_bytes(&module.join("py.typed"), b"")?; } @@ -1155,7 +1155,7 @@ pub fn write_python_part( .iter() .filter_map(|glob_pattern| glob_pattern.targets(Format::Sdist)) { - println!("📦 Including files matching \"{pattern}\""); + eprintln!("📦 Including files matching \"{pattern}\""); for source in glob::glob(&pyproject_dir.join(pattern).to_string_lossy()) .expect("No files found for pattern") .filter_map(Result::ok) diff --git a/src/new_project.rs b/src/new_project.rs index 0c235cd3a..4820acdbc 100644 --- a/src/new_project.rs +++ b/src/new_project.rs @@ -167,7 +167,7 @@ pub fn new_project(path: String, options: GenerateProjectOptions) -> Result<()> bail!("destination `{}` already exists", project_path.display()); } generate_project(project_path, options, true)?; - println!( + eprintln!( " ✨ {} {} {}", style("Done!").bold().green(), style("New project created").bold(), @@ -185,7 +185,7 @@ pub fn init_project(path: Option, options: GenerateProjectOptions) -> Re bail!("`maturin init` cannot be run on existing projects"); } generate_project(&project_path, options, false)?; - println!( + eprintln!( " ✨ {} {} {}", style("Done!").bold().green(), style("Initialized project").bold(), diff --git a/src/python_interpreter/mod.rs b/src/python_interpreter/mod.rs index 334578257..b6af0ae06 100644 --- a/src/python_interpreter/mod.rs +++ b/src/python_interpreter/mod.rs @@ -44,7 +44,7 @@ fn windows_interpreter_no_build( // There can be 32-bit installations on a 64-bit machine, but we can't link // those for 64-bit targets if pointer_width != target_width { - println!( + eprintln!( "👽 {major}.{minor} is installed as {pointer_width}-bit, while the target is {target_width}-bit. Skipping." ); return true; diff --git a/src/source_distribution.rs b/src/source_distribution.rs index f4c44085f..1f649ffdf 100644 --- a/src/source_distribution.rs +++ b/src/source_distribution.rs @@ -698,7 +698,7 @@ pub fn source_distribution( } let mut include = |pattern| -> Result<()> { - println!("📦 Including files matching \"{pattern}\""); + eprintln!("📦 Including files matching \"{pattern}\""); for source in glob::glob(&pyproject_dir.join(pattern).to_string_lossy()) .expect("No files found for pattern") .filter_map(Result::ok) @@ -740,7 +740,7 @@ pub fn source_distribution( add_data(&mut writer, build_context.project_layout.data.as_deref())?; let source_distribution_path = writer.finish()?; - println!( + eprintln!( "📦 Built source distribution to {}", source_distribution_path.display() ); diff --git a/src/upload.rs b/src/upload.rs index f3a8d1d06..16b622445 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -152,7 +152,7 @@ fn get_password(_username: &str) -> String { } fn get_username() -> String { - println!("Please enter your username:"); + eprintln!("Please enter your username:"); let mut line = String::new(); io::stdin().read_line(&mut line).unwrap(); line.trim().to_string() @@ -200,7 +200,7 @@ fn resolve_pypi_cred( if let Some((username, password)) = registry_name.and_then(|name| load_pypi_cred_from_config(config, name)) { - println!("🔐 Using credential in pypirc for upload"); + eprintln!("🔐 Using credential in pypirc for upload"); return (username, password); } @@ -431,7 +431,7 @@ pub fn upload(registry: &Registry, wheel_path: &Path) -> Result<(), UploadError> pub fn upload_ui(items: &[PathBuf], publish: &PublishOpt) -> Result<()> { let registry = complete_registry(publish)?; - println!("🚀 Uploading {} packages", items.len()); + eprintln!("🚀 Uploading {} packages", items.len()); for i in items { let upload_result = upload(®istry, i); @@ -446,9 +446,9 @@ pub fn upload_ui(items: &[PathBuf], publish: &PublishOpt) -> Result<()> { .map(|m| m.as_str()); match title { Some(title) => { - println!("⛔ {title}"); + eprintln!("⛔ {title}"); } - None => println!("⛔ Username and/or password are wrong"), + None => eprintln!("⛔ Username and/or password are wrong"), } #[cfg(feature = "keyring")] @@ -458,7 +458,7 @@ pub fn upload_ui(items: &[PathBuf], publish: &PublishOpt) -> Result<()> { let keyring = keyring::Entry::new(env!("CARGO_PKG_NAME"), &old_username); match keyring.delete_password() { Ok(()) => { - println!("🔑 Removed wrong password from keyring") + eprintln!("🔑 Removed wrong password from keyring") } Err(keyring::Error::NoEntry) | Err(keyring::Error::NoStorageAccess(_)) @@ -475,7 +475,7 @@ pub fn upload_ui(items: &[PathBuf], publish: &PublishOpt) -> Result<()> { let filename = i.file_name().unwrap_or(i.as_os_str()); if let UploadError::FileExistsError(_) = err { if publish.skip_existing { - println!( + eprintln!( "⚠️ Note: Skipping {filename:?} because it appears to already exist" ); continue; @@ -489,7 +489,7 @@ pub fn upload_ui(items: &[PathBuf], publish: &PublishOpt) -> Result<()> { } } - println!("✨ Packages uploaded successfully"); + eprintln!("✨ Packages uploaded successfully"); #[cfg(feature = "keyring")] { From 7d45e47f9ee33b821fc31499a76ce7b5c922f7ab Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 27 Feb 2023 13:12:16 +0800 Subject: [PATCH 04/10] Add tag push event trigger to `generate-ci` output --- src/ci.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ci.rs b/src/ci.rs index 2896a7b55..554ac604d 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -171,6 +171,8 @@ on: branches: - main - master + tags: + - '*' pull_request: workflow_dispatch: @@ -453,6 +455,8 @@ mod tests { branches: - main - master + tags: + - '*' pull_request: workflow_dispatch: @@ -557,6 +561,8 @@ mod tests { branches: - main - master + tags: + - '*' pull_request: workflow_dispatch: @@ -666,6 +672,8 @@ mod tests { branches: - main - master + tags: + - '*' pull_request: workflow_dispatch: @@ -809,6 +817,8 @@ mod tests { branches: - main - master + tags: + - '*' pull_request: workflow_dispatch: From 8f2944404a02646d0fed01f9f7dbbe52393bee9f Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 27 Feb 2023 13:38:40 +0800 Subject: [PATCH 05/10] Add sdist support to `generate-ci` --- src/ci.rs | 109 +++++++++++++++++++++++++++++++++++++++++---- src/new_project.rs | 3 +- 2 files changed, 103 insertions(+), 9 deletions(-) diff --git a/src/ci.rs b/src/ci.rs index 554ac604d..a4dcc1de1 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -127,9 +127,10 @@ impl GenerateCI { let project_name = pyproject .and_then(|project| project.project_name()) .unwrap_or(&project_layout.extension_name); + let sdist = pyproject_toml.is_some(); match self.ci { - Provider::GitHub => self.generate_github(project_name, &bridge), + Provider::GitHub => self.generate_github(project_name, &bridge, sdist), } } @@ -137,6 +138,7 @@ impl GenerateCI { &self, project_name: &str, bridge_model: &BridgeModel, + sdist: bool, ) -> Result { let is_abi3 = matches!(bridge_model, BridgeModel::BindingsAbi3(..)); let is_bin = bridge_model.is_bin(); @@ -385,6 +387,44 @@ jobs:\n", conf.push('\n'); } + // build sdist + if sdist { + needs.push("sdist".to_string()); + + let maturin_args = self + .manifest_path + .as_ref() + .map(|manifest_path| { + if manifest_path != Path::new("Cargo.toml") { + format!(" --manifest-path {}", manifest_path.display()) + } else { + String::new() + } + }) + .unwrap_or_default(); + conf.push_str(&format!( + r#" sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist{maturin_args} +"# + )); + conf.push_str( + " - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist +", + ); + conf.push('\n'); + } + conf.push_str(&format!( r#" release: name: Release @@ -443,7 +483,11 @@ mod tests { #[test] fn test_generate_github() { let conf = GenerateCI::default() - .generate_github("example", &BridgeModel::Bindings("pyo3".to_string(), 7)) + .generate_github( + "example", + &BridgeModel::Bindings("pyo3".to_string(), 7), + true, + ) .unwrap() .lines() .skip(5) @@ -526,11 +570,26 @@ mod tests { name: wheels path: dist + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + release: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [linux, windows, macos] + needs: [linux, windows, macos, sdist] steps: - uses: actions/download-artifact@v3 with: @@ -549,7 +608,7 @@ mod tests { #[test] fn test_generate_github_abi3() { let conf = GenerateCI::default() - .generate_github("example", &BridgeModel::BindingsAbi3(3, 7)) + .generate_github("example", &BridgeModel::BindingsAbi3(3, 7), false) .unwrap() .lines() .skip(5) @@ -660,7 +719,11 @@ mod tests { ..Default::default() }; let conf = gen - .generate_github("example", &BridgeModel::Bindings("pyo3".to_string(), 7)) + .generate_github( + "example", + &BridgeModel::Bindings("pyo3".to_string(), 7), + true, + ) .unwrap() .lines() .skip(5) @@ -782,11 +845,26 @@ mod tests { pip install pytest pytest + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + release: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [linux, windows, macos] + needs: [linux, windows, macos, sdist] steps: - uses: actions/download-artifact@v3 with: @@ -805,7 +883,7 @@ mod tests { #[test] fn test_generate_github_bin_no_binding() { let conf = GenerateCI::default() - .generate_github("example", &BridgeModel::Bin(None)) + .generate_github("example", &BridgeModel::Bin(None), true) .unwrap() .lines() .skip(5) @@ -878,11 +956,26 @@ mod tests { name: wheels path: dist + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + release: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [linux, windows, macos] + needs: [linux, windows, macos, sdist] steps: - uses: actions/download-artifact@v3 with: diff --git a/src/new_project.rs b/src/new_project.rs index 4820acdbc..3c79f552f 100644 --- a/src/new_project.rs +++ b/src/new_project.rs @@ -51,7 +51,8 @@ impl<'a> ProjectGenerator<'a> { "uniffi" => BridgeModel::UniFfi, _ => BridgeModel::Bindings(bindings.clone(), 7), }; - let ci_config = GenerateCI::default().generate_github(&project_name, &bridge_model)?; + let ci_config = + GenerateCI::default().generate_github(&project_name, &bridge_model, true)?; Ok(Self { env, From c7e3e9a42f9feb1b17443dbe8a85d9084a468ac5 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 27 Feb 2023 14:50:20 +0800 Subject: [PATCH 06/10] Remove a unnecessary whitespace --- src/ci.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci.rs b/src/ci.rs index a4dcc1de1..720d14d35 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -366,7 +366,7 @@ jobs:\n", source .venv/bin/activate pip install {project_name} --find-links dist --force-reinstall pip install pytest - {chdir} python -m pytest + {chdir}python -m pytest " )); } else { From dca80a579fd9d827b2a6d20bb7a8cd8d0b6a48fb Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 1 Mar 2023 09:59:27 +0800 Subject: [PATCH 07/10] Enable sccache support in `generate-ci` --- src/ci.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ci.rs b/src/ci.rs index 720d14d35..bf6613b15 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -289,6 +289,7 @@ jobs:\n", with: target: {maturin_target} args: --release --out dist{maturin_args} + sccache: 'true' " )); if matches!(platform, Platform::Linux) { @@ -520,6 +521,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist --find-interpreter + sccache: 'true' manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 @@ -543,6 +545,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist --find-interpreter + sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -564,6 +567,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist --find-interpreter + sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -641,6 +645,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist + sccache: 'true' manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 @@ -664,6 +669,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist + sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -685,6 +691,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist + sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -756,6 +763,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist --find-interpreter --zig + sccache: 'true' manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 @@ -802,6 +810,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist --find-interpreter + sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -831,6 +840,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist --find-interpreter + sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -913,6 +923,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist + sccache: 'true' manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 @@ -932,6 +943,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist + sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -950,6 +962,7 @@ mod tests { with: target: ${{ matrix.target }} args: --release --out dist + sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v3 with: From 0f5c1a6e304aea6a005e45962751a4024f71cbf2 Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 1 Mar 2023 14:11:18 +0800 Subject: [PATCH 08/10] Update wasmtime dependency version to 6.0.0 Changes: https://github.com/bytecodealliance/wasmtime-py/compare/5.0.0...6.0.0 --- src/build_context.rs | 2 +- tests/run.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/build_context.rs b/src/build_context.rs index a2fbfb90d..abe0a2788 100644 --- a/src/build_context.rs +++ b/src/build_context.rs @@ -130,7 +130,7 @@ fn bin_wasi_helper( // Having the wasmtime version hardcoded is not ideal, it's easy enough to overwrite metadata21 .requires_dist - .push("wasmtime>=5.0.0,<6.0.0".to_string()); + .push("wasmtime>=6.0.0,<7.0.0".to_string()); } Ok(metadata21) diff --git a/tests/run.rs b/tests/run.rs index 0a5fe8db4..d618413b4 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -322,7 +322,7 @@ fn integration_with_data() { } #[test] -// Sourced from https://pypi.org/project/wasmtime/5.0.0/#files +// Sourced from https://pypi.org/project/wasmtime/6.0.0/#files // update with wasmtime updates #[cfg(any( all(target_os = "windows", target_arch = "x86_64"), From 3d13dd66bdc934ab775be0fda7316b60bfb19e5c Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 3 Mar 2023 13:07:53 +0800 Subject: [PATCH 09/10] Fine-grained GitHub Actions permission in `generate-ci` --- src/ci.rs | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/ci.rs b/src/ci.rs index bf6613b15..2f63fb180 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -178,6 +178,9 @@ on: pull_request: workflow_dispatch: +permissions: + contents: read + jobs:\n", version = env!("CARGO_PKG_VERSION"), ); @@ -432,20 +435,31 @@ jobs:\n", runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" needs: [{needs}] - steps: +"#, + needs = needs.join(", ") + )); + if platforms.contains(&Platform::Emscripten) { + conf.push_str( + r#" permissions: + # Used to upload release artifacts + contents: write +"#, + ); + } + conf.push_str( + r#" steps: - uses: actions/download-artifact@v3 with: name: wheels - name: Publish to PyPI uses: PyO3/maturin-action@v1 env: - MATURIN_PYPI_TOKEN: ${{{{ secrets.PYPI_API_TOKEN }}}} + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} with: command: upload args: --skip-existing * "#, - needs = needs.join(", ") - )); + ); if platforms.contains(&Platform::Emscripten) { conf.push_str( " - uses: actions/download-artifact@v3 @@ -505,6 +519,9 @@ mod tests { pull_request: workflow_dispatch: + permissions: + contents: read + jobs: linux: runs-on: ubuntu-latest @@ -629,6 +646,9 @@ mod tests { pull_request: workflow_dispatch: + permissions: + contents: read + jobs: linux: runs-on: ubuntu-latest @@ -747,6 +767,9 @@ mod tests { pull_request: workflow_dispatch: + permissions: + contents: read + jobs: linux: runs-on: ubuntu-latest @@ -910,6 +933,9 @@ mod tests { pull_request: workflow_dispatch: + permissions: + contents: read + jobs: linux: runs-on: ubuntu-latest From 5167a0ebc47b82d70a72e4e14bd8111fd8559531 Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 3 Mar 2023 16:29:52 +0800 Subject: [PATCH 10/10] Release v0.14.15 --- Cargo.lock | 83 +++++++++++++++++++++++----------------------------- Cargo.toml | 2 +- Changelog.md | 7 ++++- 3 files changed, 43 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b2fa9fe0..42537affa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,12 +122,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" dependencies = [ "event-listener", - "futures-lite", ] [[package]] @@ -221,9 +220,9 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "bytesize" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" +checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" [[package]] name = "bzip2" @@ -260,9 +259,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" +checksum = "6031a462f977dd38968b6f23378356512feeace69cef817e1a4475108093cec3" dependencies = [ "serde", ] @@ -325,9 +324,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982a0cf6a99c350d7246035613882e376d58cebe571785abc5da4f648d53ac0a" +checksum = "08a1ec454bc3eead8719cb56e15dbbfecdbc14e4b3a3ae4936cc6e31f5fc0d07" dependencies = [ "camino", "cargo-platform", @@ -606,9 +605,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -617,22 +616,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.13" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.7.1", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", ] @@ -886,9 +885,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -1106,9 +1105,9 @@ dependencies = [ [[package]] name = "goblin" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572564d6cba7d09775202c8e7eebc4d534d5ae36578ab402fb21e182a0ac9505" +checksum = "0d6b4de4a8eb6c46a8c77e1d3be942cb9a8bf073c22374578e5ba4b08ed0ff68" dependencies = [ "log", "plain", @@ -1374,7 +1373,7 @@ dependencies = [ [[package]] name = "maturin" -version = "0.14.14" +version = "0.14.15" dependencies = [ "anyhow", "base64", @@ -1452,9 +1451,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" dependencies = [ "autocfg", ] @@ -1477,9 +1476,9 @@ dependencies = [ [[package]] name = "minijinja" -version = "0.30.2" +version = "0.30.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18b0af1900a114a8183b10b4266a9a4fc2816afdb7089592492c8eadd07f1629" +checksum = "41ec399da2025bb79da141e6dcf7e5b4d73f8161ef73d3c28b99850c56620378" dependencies = [ "serde", ] @@ -1492,9 +1491,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.6.4" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2e212582ede878b109755efd0773a4f0f4ec851584cf0aefbeb4d9ecc114822" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] @@ -1703,9 +1702,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -2125,15 +2124,6 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "rfc2047-decoder" version = "0.2.1" @@ -2444,9 +2434,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -2538,9 +2528,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -2566,16 +2556,15 @@ checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 746efe96f..06d09ba17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["konstin ", "messense "] name = "maturin" -version = "0.14.14" +version = "0.14.15" description = "Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages" exclude = ["test-crates/**/*", "sysconfig/*", "test-data/*", "ci/*", "tests/*", "guide/*", ".github/*"] homepage = "https://github.com/pyo3/maturin" diff --git a/Changelog.md b/Changelog.md index 617710c17..9525becaa 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.14.15] - 2023-03-03 + +* Add sdist and sccache support to `generate-ci` command + ## [0.14.14] - 2023-02-24 * Add support for Emscripten in `generate-ci` command in [#1484](https://github.com/PyO3/maturin/pull/1484) @@ -822,7 +826,8 @@ points-0.1.0-py2.py3-none-manylinux1_x86_64.whl | 2,8M | 752K | 85K * Initial Release -[Unreleased]: https://github.com/pyo3/maturin/compare/v0.14.14...HEAD +[Unreleased]: https://github.com/pyo3/maturin/compare/v0.14.15...HEAD +[0.14.15]: https://github.com/pyo3/maturin/compare/v0.14.14...v0.14.15 [0.14.14]: https://github.com/pyo3/maturin/compare/v0.14.13...v0.14.14 [0.14.13]: https://github.com/pyo3/maturin/compare/v0.14.12...v0.14.13 [0.14.12]: https://github.com/pyo3/maturin/compare/v0.14.11...v0.14.12