-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Poetry removes importlib_metadata and other requirements when run as --no-dev
#2102
Comments
Indeed this is very annoying when I run CI/CD (im my case in gitlab) when separating development and production environment. Is there any applicable workaround ? |
To answer my own question: the solution in my case is to use |
I am seeing this same issue here, with a manually created virtualenv, where I installed poetry (1.0.6) into, and then ran In a way, poetry does exactly what I ask of it - make the installed packages equal to what's listed. There's one exception, though: poetry does not uninstall itself (I assume this is some hardcoded exception in the code?). Maybe this exception should be extended to also include its own dependencies? Note that this is different from requiring |
One extra observation: It seems that poetry only removes packages that are mentioned in its I tried installing an extra package ( A workaround that seems to work, is to add
This adds a ton of extra packages to |
This allows running poetry from inside the virtualenv it manages. Without this, `poetry install --no-dev` would try to uninstall some of its own dependencies (the ones that were also listed as dev dependencies of other packages). This is a bit of a workaround, for a bug in poetry: python-poetry/poetry#2102
I can confirm that this issue is still seen with Poetry 1.0.9. Another apparent workaround: if I delete the |
I am seeing a further side-effect of this. I have a package which depends on some source-based python packages. When I install with The first thing the install does is remove a bunch of transitive dependencies of my dev packages, which were actually installed by the system (e.g. virutalenv, filelock, etc). I have a suspicion that with the loss of these packages, something in the installation process goes bad. Either way, my fix is to either include these packages explicitly in my non-dev dependencies, which seems incorrect, since they are part of the system, and I have no idea what new ones will be introduced when poetry upgrades, new dependencies are added, etc. Or, I can It would be nice if poetry could either recognize that it is uninstalling packages it never touched, or at least provide an option to not remove packages for CI-based workflows like this where you're starting from a clean slate every time. |
@klarose are you using poetry to manage a system environment? When poetry creates an environment, only pip, wheel and setuptools will typically be present. Even in CI environments I'd recommend the use a virtual environment. As for this issue, one option coule be to make it so that for Additionally, performing removals from system environments is a bad idea. If you add a dependency to your project that was already in the environment, there is no good way poetry could tell it was previously present. The current behavior is, believe it or not, a good feature. But yes, we should probably add a warning when a system environment is used (if we can detect it reliably). |
FWIW, it turns out that my workaround doesn't work consistently, so I wouldn't go with it. @abn I'm trying out a venv now to see if it helps. The reason we decided not to do that before is that it just seems like an extra bit of overhead when we're running in a container whose purpose is already quite similar to a venv. |
Okay. venvs didn't work as well. Clearly something else is going on. |
I also encountered this issue (Python 3.6). My workaround (like others): add some dependencies as optional and add those to
pyproject.toml [tool.poetry.extras]
myextra = [..., "importlib-metadata", "virtualenv"] then
|
Hello, the problem here is, that When using fin swimmer |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
I'm using poetry inside a docker with
poetry config virtualenvs.create false
. Poetry requirements are listed in mypoetry.lock
as dev (they probably are dependencies of some other package). When I runpoetry install --no-dev
the first time, the command runs fine but poetry removes its own requirements!The second time
poetry
is run, I get:The text was updated successfully, but these errors were encountered: