How to Specify GitHub Direct Sources in Requirements.txt?

Susan Sarandon
Release: 2024-11-13 03:50:02
Original
896 people have browsed it

How to Specify GitHub Direct Sources in Requirements.txt?

Specifying GitHub Direct Sources in Requirements.txt

Directly installing libraries from GitHub repositories via commands like pip install git git://github.com/mozilla/elasticutils.git can be convenient, but how can you specify these dependencies in your requirements.txt file?

The Standard Requirements.txt Syntax

Requirements.txt files typically follow a straightforward format:

package-one==1.9.4
package-two==3.7.1
package-three==1.0.1
Copy after login

However, these entries do not have the package name-version format that is required for direct GitHub repo installations.

Specifying GitHub Repositories in Requirements.txt

To specify a GitHub repository, you do not need the package-name== convention. Instead, follow these guidelines:

  • Commit hash: package-two @ git https://github.com/owner/repo@41b95ec
  • Branch name: package-two @ git https://github.com/owner/repo@main
  • Tag: package-two @ git https://github.com/owner/repo@0.1
  • Release: package-two @ git https://github.com/owner/repo@releases/tag/v3.7.1

Additional Considerations

  • If using pip versions prior to 20.1, you may need to update the package version in the package's setup.py to force pip to install the new version.
  • Consult the pip documentation on VCS support for further guidance.

Example

Update package-two from a GitHub repository in your requirements.txt as follows:

package-two @ git+https://github.com/owner/repo@main
Copy after login

The above is the detailed content of How to Specify GitHub Direct Sources in 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