Rebase: Uninstall existing non-editable versions when installing editable requirements bug (#682)
Separate branch for rebasing #677 onto main because i don't trust the rebase enough to force push. Closes #677. --- If you install `black` from PyPI, then `-e ../black`, we need to uninstall the existing `black`. This sounds simple, but that in turn requires that we _know_ `-e ../black` maps to the package `black`, so that we can mark it for uninstallation in the install plan. This, in turn, means that we need to build editable dependencies prior to the install plan. This is just a bunch of reorganization to fix that specific bug (installing multiple versions of `black` if you run through the above workflow): we now run through the list of editables upfront, mark those that are already installed, build those that aren't, and then ensure that `InstallPlan` correctly removes those that need to be removed, etc. Closes #676. Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
@@ -16,7 +16,7 @@ use platform_tags::Tags;
|
||||
use puffin_build::{SourceBuild, SourceBuildContext};
|
||||
use puffin_cache::Cache;
|
||||
use puffin_client::RegistryClient;
|
||||
use puffin_installer::{Downloader, EditableMode, InstallPlan, Installer, Reinstall};
|
||||
use puffin_installer::{Downloader, InstallPlan, Installer, Reinstall, SitePackages};
|
||||
use puffin_interpreter::{Interpreter, Virtualenv};
|
||||
use puffin_resolver::{Manifest, ResolutionOptions, Resolver};
|
||||
use puffin_traits::{BuildContext, BuildKind, OnceMap};
|
||||
@@ -131,23 +131,27 @@ impl BuildContext for BuildDispatch {
|
||||
venv.root().display(),
|
||||
);
|
||||
|
||||
// Determine the current environment markers.
|
||||
let tags = Tags::from_interpreter(&self.interpreter)?;
|
||||
|
||||
// Determine the set of installed packages.
|
||||
let site_packages =
|
||||
SitePackages::from_executable(venv).context("Failed to list installed packages")?;
|
||||
|
||||
let InstallPlan {
|
||||
local,
|
||||
remote,
|
||||
reinstalls,
|
||||
extraneous,
|
||||
editables: _,
|
||||
} = InstallPlan::from_requirements(
|
||||
&resolution.requirements(),
|
||||
&[],
|
||||
Vec::new(),
|
||||
site_packages,
|
||||
&Reinstall::None,
|
||||
&self.index_urls,
|
||||
self.cache(),
|
||||
venv,
|
||||
&tags,
|
||||
EditableMode::default(),
|
||||
)?;
|
||||
|
||||
// Resolve any registry-based requirements.
|
||||
|
||||
Reference in New Issue
Block a user