We can't install package include relative path dependency as VCS dependency #4130
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.
Pull Request Check List
summary
pip install
probllem
This package (
poetry_package_with_subdir_package
) is valid package and it have relative path dependency for sub directory (poetry_subdir_package
).https://github.com/ota42y/poetry_package_with_subdir_package
We can create a directory dependency for a locally cloned folder.
But we can't create a VCS dependency for this repository
Example is this.
I create other package which have relative path dependency using
setup.py
but I got same error.This mean we can't use VCS package which include relative path even if the package use pip or poetry.
Cause
temporary directory problem
Provider#get_package_from_vcs clone git repository to temporary directory.
poetry immediately creates
Package
object and remove temporary directory.poetry/poetry/puzzle/provider.py
Line 227 in fcc2c83
The relative dependency of the package is then interpreted as a directory dependency on the folder in the temporary directory.
For example, in the previous example, the object would be like this:
poetry install original pakcage (VCS dependency package) from git repository so we can install this package correctory.
But the directory dependency package depende on temporary directory and which alerady removed so we can't install it.
long life temporary diectory
We can solve this issue by this PR's changes.
This changes
This change can be installed by extending the lifetime of the temporary directory.
But poetry write directory dependency which depend on temporary directory to lock file so we can't install package from lock file.
how to solve
I think these package is valid package because we can install from local folder and we can install by pip so we should fix this problem.
I've come up with two solutions.
convert relative dependency in VCS dependency to git subfolder dependency
This problem cause by VCS dependency, and relative dependency in git repository is equal to git subfolder's dependency.
So we can convert git subfolder's dependency.
For example, if we have a
Package
that has a dependency on the./poetry_subdir_package
.We can convert directory dependency (
./poetry_subdir_package
) to git subfolder dependency with same revision like thisWe can convert in creating package from VCS
pros/cons
craete new dependency type like VCS relative dependency
If we can create
Dependency
for relative dependency in VCS dependency, we can solve this problem by simple way.For example, if we have a
Package
that has a dependency on the./poetry_subdir_package
.We can create
Dependency
for relative dependency in VCS dependency and set pkg.requires.When we install VCSDirectoryDependency, we should clone this repository to tmp dir and install like DirectoryDependency.
poetry write
Package
with VCSDirectoryDependency to lock file, we should add new propeties to source section and we can create VCSDirectoryDependency from lock file.pros/cons
I want to solve this problem because we can't use valid package.
I think the latter is a simpler solution, but it may require a lot of change, and there may be a lot of things to solve because I don't know the full poetry spec.
If there are any other good solutions, I'd love to discuss them.