astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.88k stars 467 forks source link

Rye defaults to pypi regardless of configured custom servers. #1288

Open narigama opened 4 months ago

narigama commented 4 months ago

Steps to Reproduce

[0]

docker run --rm -d --name pypi -p 8080:8080 pypiserver/pypiserver

[1]

[[sources]]
name = "foobar"
url = "http://localhost:8080/simple/"
verify-ssl = false

Expected Result

Rye should push a build to the custom pypi server.

Actual Result

Rye defaults to pypi and asks for an access token.

$ rye publish --repository foobar
No access token found, generate one at: https://pypi.org/manage/account/token/
Access token:

Version Info

rye 0.37.0 commit: 0.37.0 (09b67c469 2024-07-20) platform: linux (x86_64) self-python: cpython@3.12.3 symlink support: true uv enabled: true

Stacktrace

No response

Zander-1024 commented 4 months ago

when are you first run, you need use:

rye publish --repository foobar --repository_url http://localhost:8080/simple/

rye publish doesn't read config.toml, it looks up ~/.rye/credentials based on the parameters you enter.

narigama commented 4 months ago

I don't think that's it either:

$ rye publish --repository foobar --repository_url http://localhost:8080/simple/

error: unexpected argument found
Zander-1024 commented 4 months ago

sorry ··· rye publish --repository foobar --repository-url http://localhost:8080/simple/ ···

jbaiter commented 1 month ago

That doesn't work either, I'm trying to publish to a self-hosted Sonatype Nexus repository, which worked fine with Poetry:

$ ❯ rye publish --repository nexus --repository-url https://nexus.internal/repository/pypi-myrepo/simple
No access token found, generate one at: https://pypi.org/manage/account/token/
Access token:

My ~/.pypirc:

[distutils]
index-servers =
    nexus

[mdz]
repository = https://nexus.internal/repository/pypi-myrepo
username = nexuspypi

The password was stored with keyring as documented in the Twine docs.

Publishing with --repository nexus behaves just the same. How can I published to a custom internal repository with Rye?

-- Update: Specifying --username and --token made it work for me. I think this needs more documentation, publishing to a custom repository is very common and the docs are very bare bones on that use case at the moment.