Skip to content

Commit 9ece0ed

Browse files
committed
wip
1 parent 110bae0 commit 9ece0ed

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/pack.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use base64::engine::{Engine, general_purpose::STANDARD};
2222
use futures::{StreamExt, TryFutureExt, TryStreamExt, stream};
2323
use rattler_conda_types::{
2424
ChannelInfo, PackageRecord, Platform, RepoData,
25-
package::{CondaArchiveType, DistArchiveIdentifier},
25+
package::{ArchiveIdentifier, ArchiveType},
2626
};
2727
use rattler_digest::{HashingWriter, Md5, Sha256};
2828
use rattler_lock::{
@@ -192,18 +192,18 @@ pub async fn pack(options: PackOptions) -> Result<()> {
192192
.map_err(|e: anyhow::Error| anyhow!("could not download package: {}", e))?;
193193
bar.pb.finish_and_clear();
194194

195-
let mut conda_packages: Vec<(DistArchiveIdentifier, PackageRecord)> = Vec::new();
195+
let mut conda_packages: Vec<(String, PackageRecord)> = Vec::new();
196196

197197
for package in conda_packages_from_lockfile {
198198
let filename = package.file_name;
199199
conda_packages.push((filename, package.package_record));
200200
}
201201

202-
let injected_packages: Vec<(PathBuf, CondaArchiveType)> = options
202+
let injected_packages: Vec<(PathBuf, ArchiveType)> = options
203203
.injected_packages
204204
.iter()
205205
.filter_map(|e| {
206-
CondaArchiveType::split_str(e.as_path().to_string_lossy().as_ref())
206+
ArchiveType::split_str(e.as_path().to_string_lossy().as_ref())
207207
.map(|(p, t)| (PathBuf::from(format!("{}{}", p, t.extension())), t))
208208
})
209209
.collect();
@@ -212,8 +212,8 @@ pub async fn pack(options: PackOptions) -> Result<()> {
212212
for (path, archive_type) in injected_packages.iter() {
213213
// step 1: Derive PackageRecord from index.json inside the package
214214
let package_record = match archive_type {
215-
CondaArchiveType::TarBz2 => package_record_from_tar_bz2(path),
216-
CondaArchiveType::Conda => package_record_from_conda(path),
215+
ArchiveType::TarBz2 => package_record_from_tar_bz2(path),
216+
ArchiveType::Conda => package_record_from_conda(path),
217217
}?;
218218

219219
// step 2: Copy file into channel dir
@@ -224,14 +224,14 @@ pub async fn pack(options: PackOptions) -> Result<()> {
224224
.to_str()
225225
.ok_or(anyhow!("could not convert filename to string"))?
226226
.to_string();
227-
let package_identifier = DistArchiveIdentifier::try_from_filename(&filename)
227+
ArchiveIdentifier::try_from_filename(&filename)
228228
.ok_or(anyhow!("could not parse package filename: {}", filename))?;
229229

230230
fs::copy(&path, channel_dir.join(subdir).join(&filename))
231231
.await
232232
.map_err(|e| anyhow!("could not copy file to channel directory: {}", e))?;
233233

234-
conda_packages.push((package_identifier, package_record));
234+
conda_packages.push((filename, package_record));
235235
}
236236

237237
// In case we injected packages, we need to validate that these packages are solvable with the
@@ -912,7 +912,7 @@ async fn create_environment_file(
912912

913913
/// Create `repodata.json` files for the given packages.
914914
async fn create_repodata_files(
915-
packages: impl Iterator<Item = &(DistArchiveIdentifier, PackageRecord)>,
915+
packages: impl Iterator<Item = &(String, PackageRecord)>,
916916
channel_dir: &Path,
917917
) -> Result<()> {
918918
let mut packages_per_subdir = HashMap::new();
@@ -941,7 +941,6 @@ async fn create_repodata_files(
941941
}),
942942
packages: Default::default(),
943943
conda_packages,
944-
experimental_whl_packages: Default::default(),
945944
removed: Default::default(),
946945
version: Some(2),
947946
};

src/unpack.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rattler::{
1616
package_cache::{CacheKey, PackageCache},
1717
};
1818
use rattler_conda_types::{
19-
PackageRecord, Platform, RepoData, RepoDataRecord, package::DistArchiveIdentifier,
19+
PackageRecord, Platform, RepoData, RepoDataRecord,
2020
};
2121
use rattler_package_streaming::fs::extract;
2222
use rattler_shell::{
@@ -134,7 +134,7 @@ pub async fn unpack(options: UnpackOptions) -> Result<()> {
134134

135135
async fn collect_packages_in_subdir(
136136
subdir: PathBuf,
137-
) -> Result<IndexMap<DistArchiveIdentifier, PackageRecord, ahash::RandomState>> {
137+
) -> Result<IndexMap<String, PackageRecord, ahash::RandomState>> {
138138
let repodata = subdir.join("repodata.json");
139139

140140
let raw_repodata_json = fs::read_to_string(repodata)
@@ -183,7 +183,7 @@ async fn validate_metadata_file(metadata_file: PathBuf) -> Result<()> {
183183
/// Collect all packages in a directory.
184184
async fn collect_packages(
185185
channel_dir: &Path,
186-
) -> Result<IndexMap<DistArchiveIdentifier, PackageRecord, ahash::RandomState>> {
186+
) -> Result<IndexMap<String, PackageRecord, ahash::RandomState>> {
187187
let subdirs = fs::read_dir(channel_dir)
188188
.await
189189
.map_err(|e| anyhow!("could not read channel directory: {}", e))?;
@@ -235,7 +235,7 @@ async fn create_prefix(
235235
channel_dir: &Path,
236236
target_prefix: &Path,
237237
cache_dir: &Path,
238-
) -> Result<IndexMap<DistArchiveIdentifier, PackageRecord, ahash::RandomState>> {
238+
) -> Result<IndexMap<String, PackageRecord, ahash::RandomState>> {
239239
let packages = collect_packages(channel_dir)
240240
.await
241241
.map_err(|e| anyhow!("could not collect packages: {}", e))?;
@@ -277,7 +277,7 @@ async fn create_prefix(
277277

278278
let repodata_record = RepoDataRecord {
279279
package_record,
280-
identifier: file_name,
280+
file_name,
281281
url,
282282
channel: None,
283283
};
@@ -360,7 +360,7 @@ async fn create_activation_script(
360360
async fn install_pypi_packages(
361361
unpack_dir: &Path,
362362
target_prefix: &Path,
363-
installed_conda_packages: IndexMap<DistArchiveIdentifier, PackageRecord, ahash::RandomState>,
363+
installed_conda_packages: IndexMap<String, PackageRecord, ahash::RandomState>,
364364
) -> Result<()> {
365365
let pypi_directory = unpack_dir.join(PYPI_DIRECTORY_NAME);
366366
if !pypi_directory.exists() {

0 commit comments

Comments
 (0)