fix: expand editable path dependencies under Poetry >= 2.3.0 - #163
Open
BrandonLWhite wants to merge 1 commit into
Open
fix: expand editable path dependencies under Poetry >= 2.3.0#163BrandonLWhite wants to merge 1 commit into
BrandonLWhite wants to merge 1 commit into
Conversation
Poetry 2.3.0 changed the default of installer.re-resolve from true to false (python-poetry/poetry#10622). On that path, Installer._do_install sources its install targets from Locker.locked_packages() rather than Locker.locked_repository(). VenvBundler's CustomLocker only overrode locked_repository() to clear develop mode, so develop = true path dependencies were bundled as editable installs, leaving a .pth file pointing at the original source tree and making the bundle non-portable. Override locked_packages() as well, sharing the develop-clearing loop between both overrides. The existing test did not catch this because the simple_project_with_editable_dep fixture's lock file was lock-version 1.0, and Poetry forces re-resolution for lock files older than 2.1, so only the working path was ever exercised. Regenerate that fixture to lock-version 2.1 (content-hash unchanged) and parametrize the test over both installer.re-resolve values.
BrandonLWhite
marked this pull request as ready for review
August 13, 2026 22:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #159
Problem
With Poetry >= 2.3.0,
poetry bundle venvinstallsdevelop = truepath dependencies as editable installs. The bundled venv gets a.pthfile pointing back at the original source tree instead of a real copy of the package, so the bundle is no longer portable — it breaks as soon as it is shipped to another machine, a container, or a Lambda.The failure is silent at bundle time: the command reports success and only the destination breaks.
Root cause
Poetry 2.3.0 changed the default of
installer.re-resolvefromtruetofalse(python-poetry/poetry#10622).VenvBundler.bundle()neutralizes develop mode with aCustomLockersubclass that overridesLocker.locked_repository()and forcespackage.develop = False. ButInstaller._do_installpicks its package source based on that config flag:installer.re-resolve = true(the pre-2.3.0 default) →self._locker.locked_repository()— the overridden method, so develop mode was cleared.installer.re-resolve = false(the 2.3.0+ default) →self._locker.locked_packages()— not overridden, sodevelop = truesurvives from the lock file and the executor performs an editable install.The plugin was overriding only one of the two seams the installer reads from.
Fix
Override
locked_packages()as well, sharing the develop-clearing loop between both overrides.This leaves the user's
installer.re-resolvesetting in effect rather than overriding it. The alternative — forcinginstaller.re-resolve = trueon the installer's config, which is the current user-facing workaround (POETRY_INSTALLER_RE_RESOLVE=true poetry bundle venv …) — was rejected because it would permanently opt the plugin out of the faster lockfile-direct install path, and it would stake correctness on a config default that has already changed once.Why the existing test did not catch it
tests/fixtures/simple_project_with_editable_dep/poetry.lockwas lock-version1.0. Poetry forces re-resolution for lock files older than 2.1 (theis_locked_groups_and_markers()gate in_do_install), sotest_bundler_editable_depsonly ever exercised the old, working path and passed regardless of this bug.This PR regenerates that fixture to lock-version 2.1 and parametrizes the test over both
installer.re-resolvevalues, so the regression is pinned on both paths. The fixture'scontent-hashis unchanged, since itspyproject.tomlis untouched. (Thebarversion in the lock moves0.1.0→1.2.3; the old lock file was simply stale relative tobar/pyproject.toml.)Verification
mypy --strictclean; all pre-commit hooks pass. Test-first:test_bundler_editable_deps[False]fails withassert 1 == 0before the fix and passes after, while[True]passes throughout.Executor._execute_operationand therefore assert onInstalloperations rather than files on disk — a realpoetry bundle venvrun against Poetry 2.4.1 with default config, on a project with adevelop = truepath dependency:.pthfile in the bundle'ssite-packagesdirect_url.jsonreads"dir_info": {}rather than"dir_info": {"editable": true}site-packagespoetry>=2.1.0,<3.0.0range:Locker.locked_packages()exists with an identical signature in Poetry 2.1.0, 2.2.1, 2.3.x and 2.4.x, andinstaller.re-resolveis in the config schema of all of them. On 2.1/2.2 defaults the new override is dormant but harmless, and it is correct if a user turns re-resolve off there. Lock-version 2.1 is natively readable by Poetry 2.1.0, so the regenerated fixture does not affect older supported versions.