How do I install packages from test.pypi.org using poetry?

Question:

I want to use a pre-release version of a package (https://test.pypi.org/project/delta-spark/2.1.0rc1/) in my project.

I’m using poetry to manage my pyproject.toml. How do I do this?

In other words what is the poetry equivalent of:

pip install -i https://test.pypi.org/simple/ delta-spark==2.1.0rc1

I tried:

  • poetry add delta-spark==2.1.0rc1
  • poetry add --allow-prereleases delta-spark==2.1.0rc1

Both give: Could not find a matching version of package delta-spark


$ poetry config --local repositories.test-pypi https://test.pypi.org/
$ poetry config --list | fgrep repositories
repositories.test.url = "https://test.pypi.org/"
repositories.test-pypi.url = "https://test.pypi.org/"
$ fgrep -A 3 tool.poetry.source pyproject.toml 
[[tool.poetry.source]]
name = "test-pypi"
url = "https://test.pypi.org/"
secondary = true
$ poetry add --group dev delta-spark==2.1.0rc1

Could not find a matching version of package delta-spark
$ 
Asked By: Kashyap

||

Answers:

This is described here. Basically, you can add the repository via:

poetry config repositories.test https://test.pypi.org/simple/

and then make it available in pyproject.toml via:

[[tool.poetry.source]]
name = "test"
url = "https://test.pypi.org/simple/"
secondary = true

Then adding the dependency should work.

Answered By: a_guest