question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Environment variable `POETRY_PYPI_TOKEN_<NAME>` not used by `poetry publish -r <name>`

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: 10.15.3 Mac OS X

  • Poetry version: 1.0.5

  • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/esciara/dfc058348e597f8586d4f678cc163182

Issue

After setting the following environment variables and verifying the system is correctly set:

$ export POETRY_REPOSITORIES_TESTPYPI_URL=https://test.pypi.org/legacy/
$ export POETRY_PYPI_TOKEN_TESTPYPI=<token>
$ env | grep POETRY
POETRY_REPOSITORIES_TESTPYPI_URL=https://test.pypi.org/legacy/
POETRY_PYPI_TOKEN_TESTPYPI=<token>

and building my package:

$ poetry build
Building mypackage (0.0.1)
 - Building sdist
 - Built mypackage-0.0.1.tar.gz

 - Building wheel
 - Built mypackage-0.0.1-py3-none-any.whl

I am asked for a username a password when attempting to publish, event thought the token is passed through the environment variable:

$ poetry publish -r testpypi

Publishing mypackage (0.0.1) to testpypi
Username:

I checked the doc (section on environment variables) and it should work.

Workaround

The following workaround using username and password works:

$ export POETRY_REPOSITORIES_TESTPYPI_URL=https://test.pypi.org/legacy/
$ export POETRY_HTTP_BASIC_TESTPYPI_USERNAME=__token__
$ export POETRY_HTTP_BASIC_TESTPYPI_PASSWORD=<token>

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hukkincommented, Jan 7, 2021

Here’s a one-liner workaround that works for me:

poetry config http-basic.pypi "__token__" "${POETRY_PYPI_TOKEN_PYPI}"
0reactions
whg517commented, Aug 23, 2022

hi, guys.

I think the best practice is this:

first pass env:

export POETRY_HTTP_BASIC_TEST_USERNAME=__token__
export POETRY_HTTP_BASIC_TEST_PASSWORD=pypi-AgENdGVzdC5weX
# poetry not use `POETRY_REPOSITORIES_TEST`
export POETRY_REPOSITORIES_TEST=https://test.pypi.org/legacy/

config poetry repo. eg: ci action

poetry config repositories.test ${POETRY_REPOSITORIES_TEST}

publish

poetry publish -r test
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration | Documentation | Poetry - Python dependency ...
Sometimes, in particular when using Poetry with CI tools, it's easier to use environment variables and not have to execute configuration commands.
Read more >
Making Python Packages Part 2: How to Publish & Test Your ...
Poetry new. Our first command is to create the directory. · Virtual environments · Poetry add · Side note on others using your...
Read more >
Best Practice for using Poetry - Medium
I am obsessed with it recently and I really hope it can become the default python packaging and dependency management system. For basic...
Read more >
Start Managing Your Python Dependencies Using Poetry
Poetry is a tool for creating, packaging, and publishing projects in ... Uninstall using the environment variable ... name = "demopoetry"
Read more >
Using CodeArtifact with Poetry - Chariot Solutions
Net, npm (JavaScript/NodeJS), and Python. If you're not familiar with artifact servers, the basic idea is that you publish your company's ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found