pub fn write_bindings_module(
    writer: &mut impl ModuleWriter,
    project_layout: &ProjectLayout,
    module_name: &str,
    artifact: &Path,
    python_interpreter: Option<&PythonInterpreter>,
    target: &Target,
    develop: bool,
) -> Result<()> {
    let so_filename = match python_interpreter {
        Some(python_interpreter) => python_interpreter.get_library_name(&module_name),
        // abi3
        None => {
            if target.is_freebsd() || target.is_unix() {
                format!("{base}.abi3.so", base = module_name)
            } else {
                // Apparently there is no tag for abi3 on windows
                format!("{base}.pyd", base = module_name)
            }
        }
    };

    match project_layout {
        ProjectLayout::Mixed(ref python_module) => {
            write_python_part(writer, python_module, &module_name)
                .context("Failed to add the python module to the package")?;

            if develop {
                let target = python_module.join(&so_filename);
                fs::copy(&artifact, &target).context(format!(
                    "Failed to copy {} to {}",
                    artifact.display(),
                    target.display()
                ))?;
            }

            writer.add_file_with_permissions(
                Path::new(&module_name).join(&so_filename),
                &artifact,
                0o755,
            )?;
        }
        ProjectLayout::PureRust => {
            writer.add_file_with_permissions(so_filename, &artifact, 0o755)?;
        }
    }

    Ok(())
}
/// Copies the shared library into the module, which is the only extra file needed with bindings
Copies the shared library into the module, which is the only extra file needed with bindings
Copies the shared library into the module which is the only extra file needed with bindings
pub fn write_bindings_module(
    writer: &mut impl ModuleWriter,
    project_layout: &ProjectLayout,
    module_name: &str,
    artifact: &Path,
    python_interpreter: Option<&PythonInterpreter>,
    target: &Target,
    develop: bool,
) -> Result<()> {
    let so_filename = match python_interpreter {
        Some(python_interpreter) => python_interpreter.get_library_name(&module_name),
        // abi3
        None => {
            if target.is_freebsd() || target.is_unix() {
                format!("{base}.abi3.so", base = module_name)
            } else {
                // Apparently there is no tag for abi3 on windows
                format!("{base}.pyd", base = module_name)
            }
        }
    };
    match project_layout {
        ProjectLayout::Mixed(ref python_module) => {
            write_python_part(writer, python_module, &module_name)
                .context("Failed to add the python module to the package")?;
            if develop {
                let target = python_module.join(&so_filename);
                fs::copy(&artifact, &target).context(format!(
                    "Failed to copy {} to {}",
                    artifact.display(),
                    target.display()
                ))?;
            }
            writer.add_file_with_permissions(
                Path::new(&module_name).join(&so_filename),
                &artifact,
                0o755,
            )?;
        }
        ProjectLayout::PureRust => {
            writer.add_file_with_permissions(so_filename, &artifact, 0o755)?;
        }
    }
    Ok(())
}
pub fn write_bindings_module ( writer : & mut impl ModuleWriter , project_layout : & ProjectLayout , module_name : & str , artifact : & Path , python_interpreter : Option < & PythonInterpreter > , target : & Target , develop : bool , ) -> Result < ( ) > { let so_filename = match python_interpreter { Some ( python_interpreter ) => python_interpreter . get_library_name ( & module_name ) , // abi3 None => { if target . is_freebsd ( ) || target . is_unix ( ) { format ! ( " " base module_name ) } else { // Apparently there is no tag for abi3 on windows format ! ( " " base module_name ) } } } ; match project_layout { ProjectLayout :: Mixed ( ref python_module ) => { write_python_part ( writer , python_module , & module_name ) . context ( " " ) ? ; if develop { let target = python_module . join ( & so_filename ) ; fs :: copy ( & artifact , & target ) . context ( format ! ( " " artifact display ( ) target display ( ) ) ) ? ; } writer . add_file_with_permissions ( Path :: new ( & module_name ) . join ( & so_filename ) , & artifact , 0o755 , ) ? ; } ProjectLayout :: PureRust => { writer . add_file_with_permissions ( so_filename , & artifact , 0o755 ) ? ; } } Ok ( ( ) ) }
Copies the shared library into the module, which is the only extra file needed with bindings
Copies the shared library into the module which is the only extra file needed with bindings
writer
&mut impl ModuleWriter
project_layout
&ProjectLayout
module_name
&str
artifact
&Path
python_interpreter
Option<&PythonInterpreter>
target
&Target
develop
bool
writer
&mut impl ModuleWriter
project_layout
&ProjectLayout
module_name
&str
artifact
&Path
python_interpreter
Option<&PythonInterpreter>
target
&Target
develop
bool