Python Poetry - update -dev dependencies only to latest - python-poetry

How do I get Poetry to update dev dependencies only to latest?
I originally had:
[tool.poetry.dev-dependencies]
pytest = "^4.6"
But I wanted:
[tool.poetry.dev-dependencies]
pytest = "^6.0"
I achieved it by manual editing the pyproject.toml file.
When I ran poetry update it ( brilliantly ) bumped all my normal ( non-dev ) dependencies.

This is the command I wanted:
poetry add pytest#latest --dev

With latest poetry version you should use
poetry add pytest#latest --group dev

Related

composer install --dev is gone, how do I use dev dependencies?

Most people in my team doesn't need dev dependencies. So it is desirable that composer install doesn't install dev dependencies.
However, QA does need to install them with some command.
I have no idea how to achieve this now. Formerly it was composer install --dev but that's gone.
You can set the environment variable COMPOSER_NO_DEV to 0 or 1 to change the default behaviour of composer install and composer update.
see: documentation - COMPOSER_NO_DEV
If you want composer install to not install the dev dependencies by default
export COMPOSER_NO_DEV=1
If you want composer install to install dev dependencies (the default)
export COMPOSER_NO_DEV=0
or unset COMPOSER_NO_DEV
Depending on how you develop (i.e. in a container) there are various options to set a default value for the environment variable.
On the other hand you can instruct your engineer colleagues that do not require any dev dependencies to run the command:
composer install --no-dev
# .. or ..
COMPOSER_NO_DEV=1 composer install
... instead of ...
composer install
# .. or ..
COMPOSER_NO_DEV=0 composer install

why poetry is failing at installing a freshly released pypi package?

I want to install the freshly released version 2.4.0 of datasets (https://pypi.org/project/datasets/2.4.0/).
With pip, it works:
$ pip install datasets==2.4.0
With poetry, it fails:
$ poetry add datasets==2.4.0
ValueError
Could not find a matching version of package datasets
Poetry uses PyPi's JSON Api to retrieve necessary metadata. They had some problem yesterday, which is fixed in the meantime. See https://github.com/pypi/warehouse/issues/11949

Poetry gives: `TooManyIndirects` error suddenly

I have a pyproject.toml:
...
[[tool.poetry.source]]
name = "REPO_NAME"
url = "https://gitlab.com/SOME_ADDRESS"
secondary = true
When trying to install the project using poetry
(poetry install/poetry update) i get:
Updating dependencies Resolving dependencies... (14.3s)
TooManyRedirects
Exceeded 30 redirects.
Currently pypi.python.org is having an issue and there is nothing one can do about it:
But hey, it's Friday.
Clearing the cache seemed to do the trick:
poetry cache clear --all REPO_NAME
Also, it could happen on global PYPI, in that case run:
poetry cache clear --all pypi
To list all poetry's repos:
poetry cache list
There has been an issue with PyPI Json endpoints that poetry uses. pip was unaffected because it uses different endpoints.
A workaround is to export poetry dependencies to the requirements.txt format and use pip:
poetry export --dev > requirements.txt && pip install -r requirements.txt

Poetry takes ages to update dependencies

Yesterday I've commanded poetry to add new dependency. I'm still waiting...
$ poetry add readability
Using version ^0.3.1 for readability
Updating dependencies
Resolving dependencies... (66408.9s)
Is there any way to fix that or manually update lock?
First run:
poetry cache clear pypi --all
Then run:
poetry lock

How to find and treat the cause of an outdated composer package that is not in my composer.json?

I ran composer outdated command:
$ composer outdated
phpdocumentor/type-resolver 0.4.0 0.7.1
but looking inside composer.json, I see no such package. In my case there is no type-resolver.
How do I find an outdated package that is missing in composer.json belongs to and how do I update it?
Composer install not only packages that are listed directly in composer.json but also packages that are dependencies of packages that are listed in composer.json. Assuming you have in composer package vendor/A and this package requires vendor/B you will have installed both A and B packages.
So in your case you can run:
composer update phpdocumentor/type-resolver
to try to update this package.
Of course it does not mean it will be possible to update this way. It's possible that you might need to run:
composer update
but this will update all packages (and depends on scenario this is what you can accept or maybe you don't want to update all packages).
It's also possible that it won't be possible to update this package because other package that is used has phpdocumentor/type-resolver dependency set to for example 0.4.* so 0.7 version is not compatible with this package and version 0.7 won't be installed

Resources