Can Poetry add package from AWS CodeArtifact
Asked Answered
F

1

5

I find multiple answers for how to publish package using Python Poetry to CodeArtifact and this is quite simple. But now I try to add the published package poetry add sample-package and it does not work. Poetry error:

Could not find a matching version of package sample-package

With pip install it works. But not with Poetry.

My pyproject.toml specifies to you my CodeArtifact repo as default. No problem with this:

[[tool.poetry.source]]
name = "artifact"
url = "https://test-domain-1234.d.codeartifact.region.amazonaws.com/pypi/test-repo"
default = true

Did anyone figure out how to do it?

Fleam answered 8/9, 2022 at 11:49 Comment(0)
F
6

I found my mistake. In the package that I publish I need to specify repository without /simple at the end. But for project where I use the package from CodeArtifact the repository needs to end with /simple.

Example: Publish package config looks like:

[[tool.poetry.source]]
name = "artifact"
url = "https://test-domain-1234.d.codeartifact.region.amazonaws.com/pypi/test-repository/"
secondary=true

And the publish command is: poetry publish --build -r artifact

For project where I use my package sample-lib the config should be:

[[tool.poetry.source]]
name = "artifact-repo"
url = "https://test-domain-1234.d.codeartifact.region.amazonaws.com/pypi/test-repository/simple"
secondary=true

And then Poetry command is: poetry add sample-lib --source artifact-repo

Fleam answered 8/9, 2022 at 13:27 Comment(1)
Thanks! I get an authorization error.Thalia

© 2022 - 2024 — McMap. All rights reserved.