hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Cannot publish to private registry

Open wolfch-elsevier opened this issue 1 year ago • 3 comments
trafficstars

The documentation is not clear about the -r option to hatch publish - like is it an alias in ~/.pypirc as ChatGPT suggests? (probably incorrectly, I surmise). Or could it be a URL? Who knows? I tried:

  • hatch -v publish -r myrepo

...where ~/.pypirc contained:

[distutils]
index-servers = myrepo

[myrepo]
repository = https://mycompany.com/pypi/private/artifactory
username = wolf
password = <artifactory-token>

...but I just got the error:

$ hatch -v publish -r myrepo
Enter your username [__token__]:
Enter your credentials:
dist/mypackage.tar.gz ... failed
Error uploading to repository: artifactory - Request URL is missing an 'http://' or 'https://' protocol.

So then I tried:

$ hatch -v publish -u wolf -a <artifactory-token> -r artifactory

...same error - then, assuming it doesn't look at ~/.pypirc as ChatGPT suggests, I added this section to my pyproject.toml:

[publish.index.repos.artifactory]
url = "https://mycompany.com/pypi/private/artifactoryl"
user = "wolf"
auth = "<artifactory-token>"

then did: hatch -v publish -r myrepo - same errors as above.

Finally I tried:

$ hatch -v publish -u wolf -a <artifactory-token> -r https://mycompany.com/pypi/private/artifactory
dist/mypackage.tar-gz ...success
dist/mypackage..py3-none-any.whl ... success

That worked, but how can I supply at least the URL in a file?

wolfch-elsevier avatar Mar 06 '24 22:03 wolfch-elsevier

Dupe of https://github.com/pypa/hatch/issues/948

The "publish" table of settings needs to be in your global configuration, not in the pyproject.toml.

Refer to https://hatch.pypa.io/latest/config/hatch/ for details on the location of the global config file.

SwampFalc avatar Apr 10 '24 07:04 SwampFalc

Perhaps the docs should be updated to reflect that the documentation is referring to the global config. In it's current state and for someone who is just starting out witch hatch it is confusing.

dnutiu avatar Aug 23 '24 11:08 dnutiu

I agree, the documentation is a bit sparse with respect to publishing.

Is there any reason that this config cannot be per project? It would be easier for my team if the publish configuration could be part of pyproject.toml, so when they clone the project repository from our private git server, they can also publish back to our private repository, independent of the team member's global Hatch config.

As it is now, I think I will create a script in the build env that calls twine and have users edit a .pypirc file with our private repository.

13BTurbo avatar Oct 19 '24 02:10 13BTurbo