How to Specify GitHub Sources in Your requirements.txt?

Susan Sarandon
Release: 2024-11-19 08:28:02
Original
278 people have browsed it

How to Specify GitHub Sources in Your requirements.txt?

Handling Direct GitHub Sources in Requirements.txt

In order to install dependencies directly from a GitHub repository, you may have encountered difficulties with the syntax in requirements.txt files.

Unlike regular package specifications (package-name==version), specifying a GitHub source requires a different approach:

Correct Syntax:

To reference a GitHub repo in requirements.txt, omit the package-name==version format. Instead, use the following structure:

package @ git+https://github.com/owner/repo@[specifier]
Copy after login

where [specifier] can be:

  • Commit hash (@commit)
  • Branch name (@branch)
  • Tag (@tag)
  • Release (@release/v[version])

Examples:

  • Specify commit hash: package @ git https://github.com/owner/repo@41b95ec
  • Specify branch: package @ git https://github.com/owner/repo@main
  • Specify tag: package @ git https://github.com/owner/repo@0.1
  • Specify release: package @ git https://github.com/owner/repo@releases/tag/v3.7.1

Note:

In earlier versions of pip, you may need to update the package version in its setup.py to prevent pip from assuming the requirement is already satisfied.

The above is the detailed content of How to Specify GitHub Sources in Your requirements.txt?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template