Poetry: how to specify a (range of) version of a package by command line

Created on 17 Jun 2018  路  3Comments  路  Source: python-poetry/poetry

I want to get the latest minor version update of Django so my target is 2.0.6 but I don't want to prevent myself from getting 2.0.7 in the future.

I tried to install Django 2.0.* with poetry:

poetry add django==2.0 OR poetry add django==2.0.* will give me Django 2.0 exact.

Eventually, I got it by adding django== ">2.0,<2.1" in pyproject.toml.

Is there a command line way to do it? Thanks.

Most helpful comment

poetry add django=^2.0.5

This will add a line to pyproject.toml as follows:

django = "^2.0.5"

However the install will fetch the latest version:

Package operations: 3 installs, 0 updates, 0 removals

Writing lock file

  - Installing pytz (2018.4)
  - Installing setuptools (39.2.0)
  - Installing django (2.0.6)

All 3 comments

poetry add django=^2.0.5

This will add a line to pyproject.toml as follows:

django = "^2.0.5"

However the install will fetch the latest version:

Package operations: 3 installs, 0 updates, 0 removals

Writing lock file

  - Installing pytz (2018.4)
  - Installing setuptools (39.2.0)
  - Installing django (2.0.6)

That's how the caret is intended to work: https://github.com/sdispater/poetry#caret-requirement

You want poetry add django==2.0.5 to insert django = "=2.0.5".

@jacebrowning I know... I was simply showing an example of how defining an "older" version will automatically download a newer version, as the op had requested.

Was this page helpful?
0 / 5 - 0 ratings