How to specify github access token in pyproject.toml with an environment variable, or something similar?

Viewed 2125

I want to install a package from my private GitHub repository. Using GitHub access token, I can specify it like this:

[tool.poetry.dependencies]
python = "^3.8"
<package> = {git = "https://<token>@github.com/<user>/<repo>", rev = "0.1.3"}

And it works. But, I don't want to specify my access token in pyproject.toml directly. Is there some other way I can specify it?

1 Answers

You can use the private repositories configuration (never tried it with github though)

see: https://python-poetry.org/docs/repositories/

If you can configure github to accept basic http authorization then you can run

poetry config http-basic.<private-repo-ref> username password

Note though, that if you cannot configure github for basic auth dont create the repository with the url containing the token, this url is also written to the lock file which you are commiting to git...

Related