poetry: setting up gemfury is not obvious

  • 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: macOS 10.14.3 (18D109)
  • Poetry version: 0.12.11

Issue

I tried following the instructions at https://poetry.eustace.io/docs/repositories/ but it doesn’t seem to be working.

❯ poetry config repositories.REDACTED https://pypi.fury.io/REDACTED/

❯ poetry config http-basic.dialogue jasonkuhrt

Password:


❯ poetry config --list
settings.virtualenvs.create = true
settings.virtualenvs.in-project = false
settings.virtualenvs.path = "/Users/jasonkuhrt/Library/Caches/pypoetry/virtualenvs"
repositories.dialogue.url = "https://pypi.fury.io/REDACTED/"

❯ head pyproject.toml
REDACTED


[[tool.poetry.source]]
name = "REDACTED"
url = "https://pypi.fury.io/REDACTED/"

❯ poetry add REDACTED

[PackageNotFound]
Package [REDACTED] not found.

add [-D|--dev] [--git GIT] [--path PATH] [-E|--extras EXTRAS] [--optional] [--python PYTHON] [--platform PLATFORM] [--allow-prereleases] [--dry-run] [--] <name> (<name>)...

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 16 (2 by maintainers)

Most upvoted comments

These are the instructions we currently have at Dialogue internally. Hope its useful to anyone else. I would be happy to make a PR to the official docs but not sure if these instructions are flawed in some way.


Publishing Packages

Steps

  • Register the dialogue package repository

      poetry config repositories.dialogue https://pypi.fury.io/dialogue
    
  • Setup auth to dialogue repo

      poetry config http-basic.dialogue $GEMFURY_TOKEN $GEMFURY_TOKEN
    
  • Specify dialogue repo when publishing. Do not specify -p or -u (auth done in previous step)

      poetry publish --build --repository dialogue
    

Example

❯ poetry publish -r dialogue --build

Building foobar (0.1.2)
 - Building sdist
 - Built foobar-0.1.2.tar.gz

 - Building wheel
 - Built foobar-0.1.2-py3-none-any.whl

Publishing foobar (0.1.2) to dialogue
 - Uploading foobar-0.1.2-py3-none-any.whl 100%
 - Uploading foobar-0.1.2.tar.gz 100%

Using Dialogue gemfury private repository

Steps:

  • Add in pyproject.toml:

      [[tool.poetry.source]]
      name = "dialogue"
      url = "https://pypi.fury.io/dialogue"
    
  • To poetry add or poetry remove , setup poetry with gemfury token for user and pass like so:

      $ poetry config http-basic.dialogue $GEMFURY_TOKEN $GEMFURY_TOKEN
    

    In CI, since changes are not done, http-basic config is not needed, just the env var which is present in contect via org-global-v2. However, as you can see in publishing setup, this step is always needed for that.

  • In order to do poetry install with private packages listed in lock file, must have PIP_EXTRA_INDEX_URL set globally like so:

      $ echo $PIP_EXTRA_INDEX_URL
      https://pypi.fury.io/$GEMFURY_TOKEN/dialogue/
    

Hey @cenzhe,

We discovered that we had not configured things properly.

In order to make changes like poetry add or poetry remove with private packages, we must have setup gemfury token for user and pass like so:

$ poetry config http-basic.dialogue $GEMFURY_TOKEN $GEMFURY_TOKEN

In order to do poetry install with private packages listed in lock file, must have PIP_EXTRA_INDEX_URL set globally like so:

$ echo $PIP_EXTRA_INDEX_URL
https://pypi.fury.io/$GEMFURY_TOKEN/dialogue/

Observations:

  1. This wasn’t obvious from either the poetry or gemfury docs
  2. there were no particularly helpful error messges from poetry

I realize this may be/is an integration issue, but I think it could only help poetry to take it upon itself to have a doc section for various private PyPI registries.

We were very close to delaying adoption of poetry until one team member cracked the issue.

I’ve renamed the issue title to reflect this new information

I’m not sure if specifying $GEMFURY_TOKEN as the password is strictly necessary. I use this command just fine across several Dockerfiles:

poetry config http-basic.repo $GEMFURY_TOKEN ""

We use this command on our local development machines too, to set up our private Gemfury repository across all of our projects. The repository for each package installed is recorded in poetry.lock so we don’t need the PIP_EXTRA_INDEX_URL environment variable.

Agree - the docs have placeholder values in their examples, but don’t explain what they mean! An actual worked example would be really helpful.

When using poetry 1.5.1 the problem I have is that I get a 403 when poetry tries to download the file. This only happens in my github action. Locally everything works. I found that gemfury expects the authorization and poetry is not providing it.

Ohhh that makes a lot of sens but this is very odd as I have the problem only inside docker build and not on my local machine 🤔

We still have the problem from time to time as soon as the cache gets bumped and also when we push to gemfury. yes the above solution works but since poetry 1.0.0 it is getting clunky.

[TypeError]
quote_from_bytes() expected bytes

Traceback (most recent call last):
  File "/home/circleci/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/home/circleci/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/home/circleci/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/home/circleci/.poetry/lib/poetry/_vendor/py3.8/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/home/circleci/.poetry/lib/poetry/console/commands/install.py", line 63, in handle
    return_code = installer.run()
  File "/home/circleci/.poetry/lib/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/home/circleci/.poetry/lib/poetry/installation/installer.py", line 286, in _do_install
    self._execute(op)
  File "/home/circleci/.poetry/lib/poetry/installation/installer.py", line 302, in _execute
    getattr(self, "_execute_{}".format(method))(operation)
  File "/home/circleci/.poetry/lib/poetry/installation/installer.py", line 327, in _execute_install
    self._installer.install(operation.package)
  File "/home/circleci/.poetry/lib/poetry/installation/pip_installer.py", line 63, in install
    index_url = repository.authenticated_url
  File "/home/circleci/.poetry/lib/poetry/repositories/legacy_repository.py", line 224, in authenticated_url
    password=quote(self._auth.auth.password),
  File "/usr/local/lib/python3.8/urllib/parse.py", line 839, in quote
    return quote_from_bytes(string, safe)
  File "/usr/local/lib/python3.8/urllib/parse.py", line 864, in quote_from_bytes
    raise TypeError("quote_from_bytes() expected bytes")