Skip to content

How can I set repository url config only by environment variables? #1791

@pine

Description

@pine
  • 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).

Issue

Hello. I tried to publish my project to testpypi, but it failed.
I used only environment variables to configure Poetry. I guess it is cause of failure.

How can I set configuration to publish to custom repository only by environment variables?
The following are the details.

$ rm -rf dist/
$ poetry build -f wheel
Building ecode (0.1.1)
 - Building wheel
 - Built ecode-0.1.1-py3-none-any.whl
$ set -x POETRY_REPOSITORIES_TESTPYPI https://test.pypi.org/legacy/
$ set -x POETRY_HTTP_BASIC_TESTPYPI_USERNAME pine
$ set -x POETRY_HTTP_BASIC_TESTPYPI_PASSWORD XXX
$ poetry publish -r testpypi -vvv

Publishing ecode (0.1.1) to testpypi

[TypeError]
string indices must be integers

Traceback (most recent call last):
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/poetry/console/commands/publish.py", line 76, in handle
    publisher.publish(
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/poetry/masonry/publishing/publisher.py", line 59, in publish
    url = repository["url"]


$ set -e POETRY_REPOSITORIES_TESTPYPI # Erase the variable
$ set -x POETRY_REPOSITORIES_TESTPYPI_URL https://test.pypi.org/legacy/
$ poetry publish -r testpypi -vvv

Publishing ecode (0.1.1) to testpypi

[NonExistentKey]
'Key "url" does not exist.'

Traceback (most recent call last):
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/poetry/console/commands/publish.py", line 76, in handle
    publisher.publish(
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/poetry/masonry/publishing/publisher.py", line 59, in publish
    url = repository["url"]
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/tomlkit/items.py", line 1008, in __getitem__
    return self._value[key]
  File "/Users/pine/.anyenv/envs/pyenv/versions/3.8.0/lib/python3.8/site-packages/tomlkit/container.py", line 524, in __getitem__
    raise NonExistentKey(key)

I used Python 3.8.0 with pyenv, and fish shell 3.0.2. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions