diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 9aef8682c..f37a05eee 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -762,7 +762,7 @@ mod test { }; test_install_python( - packages.filter_map(|p| Some(p.as_conda()?.location().as_url()?)), + packages.filter_map(|p| p.as_conda()?.location().as_url().cloned()), "conda-lock", current_platform, ) diff --git a/py-rattler/Cargo.lock b/py-rattler/Cargo.lock index 058ac1194..8b758131b 100644 --- a/py-rattler/Cargo.lock +++ b/py-rattler/Cargo.lock @@ -2161,6 +2161,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -2784,6 +2793,7 @@ dependencies = [ "rattler_conda_types", "rattler_digest", "serde", + "serde-value", "serde_repr", "serde_with", "serde_yaml", @@ -3417,6 +3427,16 @@ dependencies = [ "typeid", ] +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.203" diff --git a/py-rattler/rattler/lock/package.py b/py-rattler/rattler/lock/package.py index 5a4cea6de..4236010e9 100644 --- a/py-rattler/rattler/lock/package.py +++ b/py-rattler/rattler/lock/package.py @@ -68,7 +68,7 @@ def is_conda(self) -> bool: >>> lock_file = LockFile.from_path("../test-data/test.lock") >>> env = lock_file.default_environment() >>> lock_packages = env.packages(Platform("osx-arm64")) - >>> conda_pkgs = [pkg for pkg in lock_packages if pkg.url_or_path.startswith("https://conda.anaconda.org/")] + >>> conda_pkgs = [pkg for pkg in lock_packages if pkg.location.startswith("https://conda.anaconda.org/")] >>> conda_pkgs[0].is_conda True >>> @@ -88,7 +88,7 @@ def is_pypi(self) -> bool: >>> lock_file = LockFile.from_path("../test-data/test.lock") >>> env = lock_file.default_environment() >>> lock_packages = env.packages(Platform("osx-arm64")) - >>> pypi_pkgs = [pkg for pkg in lock_packages if pkg.url_or_path.startswith("https://files.pythonhosted.org/")] + >>> pypi_pkgs = [pkg for pkg in lock_packages if pkg.location.startswith("https://files.pythonhosted.org/")] >>> pypi_pkgs[0].is_pypi True >>> @@ -116,7 +116,7 @@ def name(self) -> str: return self._package.name @property - def url_or_path(self) -> str: + def location(self) -> str: """ Returns the URL of the package @@ -127,12 +127,12 @@ def url_or_path(self) -> str: >>> lock_file = LockFile.from_path("../test-data/test.lock") >>> env = lock_file.default_environment() >>> lock_package = env.packages(Platform("osx-arm64"))[0] - >>> lock_package.url_or_path + >>> lock_package.location 'https://conda.anaconda.org/...' >>> ``` """ - return self._package.url_or_path + return self._package.location @property def version(self) -> str: diff --git a/py-rattler/rattler/lock/pypi.py b/py-rattler/rattler/lock/pypi.py index dd7974d1a..c330f69f7 100644 --- a/py-rattler/rattler/lock/pypi.py +++ b/py-rattler/rattler/lock/pypi.py @@ -72,7 +72,7 @@ def version(self) -> str: return self._data.version @property - def url_or_path(self) -> str: + def location(self) -> str: """ The URL that points to where the artifact can be downloaded from. @@ -84,12 +84,12 @@ def url_or_path(self) -> str: >>> env = lock_file.default_environment() >>> pypi_packages = env.pypi_packages() >>> data = pypi_packages[Platform("osx-arm64")][0][0] - >>> data.url_or_path + >>> data.location 'https://files.pythonhosted.org/...' >>> ``` """ - return self._data.url_or_path + return self._data.location @property def hash(self) -> Optional[PackageHashes]: diff --git a/py-rattler/src/lock/mod.rs b/py-rattler/src/lock/mod.rs index 37f1d3bf4..2561e6859 100644 --- a/py-rattler/src/lock/mod.rs +++ b/py-rattler/src/lock/mod.rs @@ -337,8 +337,8 @@ impl PyLockedPackage { } #[getter] - pub fn url_or_path(&self) -> String { - self.inner.url_or_path().to_string() + pub fn location(&self) -> String { + self.inner.location().to_string() } pub fn as_conda(&self) -> Option { @@ -347,7 +347,7 @@ impl PyLockedPackage { package_record: pkg.package_record().clone(), file_name: pkg.file_name().unwrap_or("").into(), channel: pkg.channel().map_or("".to_string(), |c| c.to_string()), - url: pkg.url().clone(), + url: pkg.location().as_url()?.clone(), })); } None @@ -418,8 +418,8 @@ impl PyPypiPackageData { /// The URL that points to where the artifact can be downloaded from. #[getter] - pub fn url_or_path(&self) -> String { - self.inner.url_or_path.to_string() + pub fn location(&self) -> String { + self.inner.location.to_string() } /// Whether the package is installed in editable mode or not.