diff --git a/Cargo.lock b/Cargo.lock index 78c7db45..6b4073cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -575,6 +575,9 @@ name = "configparser" version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec6d3da8e550377a85339063af6e3735f4b1d9392108da4e083a1b3b9820288" +dependencies = [ + "indexmap 2.2.6", +] [[package]] name = "console" diff --git a/crates/rattler_installs_packages/Cargo.toml b/crates/rattler_installs_packages/Cargo.toml index d0c4403e..777fd1a7 100644 --- a/crates/rattler_installs_packages/Cargo.toml +++ b/crates/rattler_installs_packages/Cargo.toml @@ -16,6 +16,7 @@ include = ["src/", "vendor/", "benches/"] default = ["native-tls"] native-tls = ['reqwest/native-tls'] rustls-tls = ['reqwest/rustls-tls'] +configparser-indexmap = ["configparser/indexmap"] [dependencies] async-trait = "0.1.80" diff --git a/crates/rattler_installs_packages/src/install/mod.rs b/crates/rattler_installs_packages/src/install/mod.rs index 34f67d23..fca09a50 100644 --- a/crates/rattler_installs_packages/src/install/mod.rs +++ b/crates/rattler_installs_packages/src/install/mod.rs @@ -10,11 +10,15 @@ use crate::{ }; use configparser::ini::Ini; use data_encoding::BASE64URL_NOPAD; +#[cfg(feature = "configparser-indexmap")] +use indexmap::IndexMap; use rattler_digest::Sha256; use std::str::FromStr; +#[cfg(not(feature = "configparser-indexmap"))] +use std::collections::HashMap; use std::{ borrow::Cow, - collections::{HashMap, HashSet}, + collections::HashSet, ffi::OsStr, fs, io::{BufRead, BufReader, Read, Write}, @@ -623,14 +627,20 @@ impl Scripts { }; // Parse the script entry points - let console_scripts = entry_points_mapping - .remove("console_scripts") + #[cfg(feature = "configparser-indexmap")] + let console_scripts = entry_points_mapping.shift_remove("console_scripts"); + #[cfg(not(feature = "configparser-indexmap"))] + let console_scripts = entry_points_mapping.remove("console_scripts"); + let console_scripts = console_scripts .map(|e| parse_entry_points_from_ini_section(e, extras)) .transpose()? .unwrap_or_default(); - let gui_scripts = entry_points_mapping - .remove("gui_scripts") + #[cfg(feature = "configparser-indexmap")] + let gui_scripts = entry_points_mapping.shift_remove("gui_scripts"); + #[cfg(not(feature = "configparser-indexmap"))] + let gui_scripts = entry_points_mapping.remove("gui_scripts"); + let gui_scripts = gui_scripts .map(|e| parse_entry_points_from_ini_section(e, extras)) .transpose()? .unwrap_or_default(); @@ -669,7 +679,10 @@ impl Scripts { /// Parse entry points from a section in the `entry_points.txt` file. fn parse_entry_points_from_ini_section( + #[cfg(not(feature = "configparser-indexmap"))] entry_points: HashMap>, + #[cfg(feature = "configparser-indexmap")] + entry_points: IndexMap>, extras: Option<&HashSet>, ) -> Result, InstallError> { let mut result = Vec::new();