From 4bb17bf85329912e53063fce2b074a17b8f616c6 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Sat, 6 May 2023 09:54:18 +0200 Subject: [PATCH] Small fixes for link.json parsing, and making entry point template public (#189) --- crates/rattler/src/install/entry_point.rs | 2 +- crates/rattler/src/install/mod.rs | 3 +++ crates/rattler_conda_types/src/package/link.rs | 4 ++++ ..._package__link__test__link-json__tzdata-link.json.snap | 8 ++++++++ test-data/link-json/tzdata-link.json | 6 ++++++ 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 crates/rattler_conda_types/src/package/snapshots/rattler_conda_types__package__link__test__link-json__tzdata-link.json.snap create mode 100644 test-data/link-json/tzdata-link.json diff --git a/crates/rattler/src/install/entry_point.rs b/crates/rattler/src/install/entry_point.rs index a38b6e16d..67517160b 100644 --- a/crates/rattler/src/install/entry_point.rs +++ b/crates/rattler/src/install/entry_point.rs @@ -122,7 +122,7 @@ pub fn create_unix_python_entry_point( /// Returns Python code that, when placed in an executable file, invokes the specified /// [`EntryPoint`]. -fn python_entry_point_template( +pub fn python_entry_point_template( target_prefix: &str, entry_point: &EntryPoint, python_info: &PythonInfo, diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 5c8eb6698..66bb46a1a 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -269,6 +269,9 @@ pub async fn link_package( // Parse the `link.json` file and extract entry points from it. let entry_points = match link_json.noarch { NoArchLinks::Python(entry_points) => entry_points.entry_points, + NoArchLinks::Generic => { + unreachable!("we only use link.json for noarch: python packages") + } }; // Get python info diff --git a/crates/rattler_conda_types/src/package/link.rs b/crates/rattler_conda_types/src/package/link.rs index 5677ffb2b..13de15fa3 100644 --- a/crates/rattler_conda_types/src/package/link.rs +++ b/crates/rattler_conda_types/src/package/link.rs @@ -19,6 +19,9 @@ pub struct PythonEntryPoints { pub enum NoArchLinks { /// Python noarch specific entry points. Python(PythonEntryPoints), + + /// Generic variant (doesn't have any special entry points) + Generic, } /// A representation of the `link.json` file found in noarch package archives. @@ -52,6 +55,7 @@ mod test { #[rstest] #[case::jupyterlab("link-json/jupyterlab-link.json")] #[case::setuptools("link-json/setuptools-link.json")] + #[case::tzdata("link-json/tzdata-link.json")] fn test_link_json(#[case] path: &str) { let test_file = &crate::get_test_data_dir().join(path); let link_json: LinkJson = diff --git a/crates/rattler_conda_types/src/package/snapshots/rattler_conda_types__package__link__test__link-json__tzdata-link.json.snap b/crates/rattler_conda_types/src/package/snapshots/rattler_conda_types__package__link__test__link-json__tzdata-link.json.snap new file mode 100644 index 000000000..a01b64f56 --- /dev/null +++ b/crates/rattler_conda_types/src/package/snapshots/rattler_conda_types__package__link__test__link-json__tzdata-link.json.snap @@ -0,0 +1,8 @@ +--- +source: crates/rattler_conda_types/src/package/link.rs +expression: link_json +--- +noarch: + type: generic +package_metadata_version: 1 + diff --git a/test-data/link-json/tzdata-link.json b/test-data/link-json/tzdata-link.json new file mode 100644 index 000000000..f072e87f8 --- /dev/null +++ b/test-data/link-json/tzdata-link.json @@ -0,0 +1,6 @@ +{ + "noarch": { + "type": "generic" + }, + "package_metadata_version": 1 +} \ No newline at end of file