Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: can now incrementally regenerage lockfile #129

Merged
merged 4 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 8 additions & 33 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn locked_dependency_satisfies(
/// Updates the lock file for a project.
pub async fn update_lock_file(
project: &Project,
_existing_lock_file: CondaLock,
existing_lock_file: CondaLock,
repodata: Option<Vec<SparseRepoData>>,
) -> anyhow::Result<CondaLock> {
let platforms = project.platforms();
Expand Down Expand Up @@ -329,47 +329,22 @@ pub async fn update_lock_file(
.map(|records| LibsolvRepoData::from_records(records)),

// TODO: All these things.
locked_packages: vec![],
locked_packages: existing_lock_file
.packages_for_platform(platform)
.map(RepoDataRecord::try_from)
.collect::<Result<Vec<_>, _>>()?,
pinned_packages: vec![],
virtual_packages,
};

// Solve the task
let records = rattler_solve::LibsolvBackend.solve(task)?;

// Update lock file
let mut locked_packages = LockedPackages::new(platform);
for record in records {
locked_packages = locked_packages.add_locked_package(LockedPackage {
name: record.package_record.name,
version: record.package_record.version.to_string(),
build_string: record.package_record.build.to_string(),
url: record.url,
package_hashes: match (record.package_record.sha256, record.package_record.md5) {
(Some(sha256), Some(md5)) => PackageHashes::Md5Sha256(md5, sha256),
(Some(sha256), None) => PackageHashes::Sha256(sha256),
(None, Some(md5)) => PackageHashes::Md5(md5),
_ => unreachable!("package without any hash??"),
},
dependency_list: record
.package_record
.depends
.iter()
.map(|dep| {
MatchSpec::from_str(dep)
.map_err(anyhow::Error::from)
.and_then(|spec| match &spec.name {
Some(name) => {
Ok((name.to_owned(), NamelessMatchSpec::from(spec).into()))
}
None => Err(anyhow::anyhow!(
"dependency MatchSpec missing a name '{}'",
dep
)),
})
})
.collect::<Result<_, _>>()?,
optional: None,
});
let locked_package = LockedPackage::try_from(record)?;
locked_packages = locked_packages.add_locked_package(locked_package);
}

builder = builder.add_locked_packages(locked_packages);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
source: src/project/manifest.rs
assertion_line: 230
expression: "examples.into_iter().map(|example|\n toml_edit::de::from_str::<ProjectManifest>(&format!(\"{PROJECT_BOILERPLATE}\\n{example}\")).unwrap_err().to_string()).collect::<Vec<_>>().join(\"\\n\")"
---
TOML parse error at line 8, column 9
|
8 | [target.foobar.dependencies]
| ^^^^^^
'foobar' is not a known platform
'foobar' is not a known platform. Valid platforms are 'noarch', 'linux-32', 'linux-64', 'linux-aarch64', 'linux-armv6l', 'linux-armv7l', 'linux-ppc64le', 'linux-ppc64', 'linux-s390x', 'linux-riscv32', 'linux-riscv64', 'osx-64', 'osx-arm64', 'win-32', 'win-64', 'win-arm64', 'emscripten-32'