Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer dependency to --dev in poetry

If you accidentally install a dependency in poetry as a main dependency (i.e. poetry add ...), is there a way to quickly transfer it to dev dependencies (i.e. poetry add --dev ...), or do you have to uninstall it and reinstall with poetry add --dev?

like image 215
A. Hendry Avatar asked Aug 25 '20 08:08

A. Hendry


People also ask

How do you remove dependency from a poem?

lock file, Poetry will create one after dependency resolution. You can specify to the command that you do not want the development dependencies installed by passing the --no-dev option. If you want to remove old dependencies no longer present in the lock file, use the --remove-untracked option.

How do you update a poem lock file?

As mentioned above, the poetry. lock file prevents you from automatically getting the latest versions of your dependencies. To update to the latest versions, use the update command. This will fetch the latest matching versions (according to your pyproject.


2 Answers

You can move the corresponding line in the pyproject.toml from the [tool.poetry.dependencies] section to [tool.poetry.dev-dependencies] by hand and run poetry lock --no-update afterwards.

like image 107
finswimmer Avatar answered Oct 24 '22 09:10

finswimmer


You can also poetry add -D <dep> and poetry remove <dep> in either order. Just be sure to use the same version constraint. Poetry stops/warns you if you use different constraints as they'd conflict.

like image 41
ccchoy Avatar answered Oct 24 '22 10:10

ccchoy