Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add private GitHub repo to pyproject.toml as new dependency

How can I define a private GitHub repo as a dependency in the project section of my pyproject.toml file?

[project]
dependencies = [
    "my_repo_name>=<SSH-address_to_my_private_github_repo>"
]
like image 377
Andi Avatar asked Sep 12 '25 06:09

Andi


1 Answers

How about something like:

[tool.hatch.metadata] 
allow-direct-references = true

[project]

dependencies = [
    "my_pkg_name @ git+ssh://[email protected]/my-github-name/my_repo",
]

Explanation:

@EDG956 and @sinoroc pointed at docs on how to do this if you're using poetry, but I don't think you are: your example has a [project] section rather than a [tool.poetry.dependencies] section, so I'm guessing you're using pyproject.toml with setuptools directly — as described here.

That page refers to PEP 621, whose section on dependencies says:

For dependencies, it is a key whose value is an array of strings. Each string represents a dependency of the project and MUST be formatted as a valid PEP 508 string.

Then, the "Examples" section of PEP 508 shows an example which I've used as the basis of my suggestion above.

(As usual, you can use @<tag> or @<sha>, or #<branch_name> suffixes, etc.)

like image 156
gimboland Avatar answered Sep 14 '25 21:09

gimboland