How to state in requirements.txt a direct github not merged Pull

ghz 14hours ago ⋅ 6 views

How to state in requirements.txt a direct github not merged Pull request

y English is bad.

I'm going to state some Python 3 library in requirements.txt, but there is a bug in original version of code. In Pull requests one user commited the new version with bug fix that wasn't merged by Author if it affects something.

The link looks like this: https://github.com/ramusus/kinopoiskpy/pull/47/commits/4c888bf4f6b330b115d11fac3e0b8bb177b597bb

How should i write to requirements.txt so that it installs without any problem?

I tried that: -e git+git://github.com/ramusus/kinopoiskpy.git@4c888bf4f6b330b115d11fac3e0b8bb177b597bb#egg=kinopoiskpy.

But there was an ERROR: "git checkout -q 4c888bf4f6b330b115d11fac3e0b8bb177b597bb" failed with error code 128

Answer

To specify a dependency in requirements.txt that uses a specific commit from a GitHub repository, the syntax you've used is almost correct. However, there might be some issues to check:

  1. Repository Access
    Ensure that the repository is publicly accessible or that you have access permissions if it’s private.

  2. Correct URL Scheme
    If git:// doesn't work, try using https://.

  3. Exact Commit Reference
    Make sure the commit hash is correct and exists in the repository.

Here’s the correct way to specify the dependency in your requirements.txt:

-e git+https://github.com/ramusus/kinopoiskpy.git@4c888bf4f6b330b115d11fac3e0b8bb177b597bb#egg=kinopoiskpy

Steps to Debug the Issue

  1. Test Cloning the Repository Manually
    Run the following command to ensure you can clone the repository and checkout the commit:

    git clone https://github.com/ramusus/kinopoiskpy.git
    cd kinopoiskpy
    git checkout 4c888bf4f6b330b115d11fac3e0b8bb177b597bb
    
  2. Install the Dependency Locally
    If the above works, try installing it directly using pip:

    pip install -e git+https://github.com/ramusus/kinopoiskpy.git@4c888bf4f6b330b115d11fac3e0b8bb177b597bb#egg=kinopoiskpy
    
  3. Check for SSH Configuration Issues
    If you used git:// or ssh:// and encounter errors, ensure your SSH keys are correctly configured. Alternatively, switch to using https://.

  4. Verify Commit Existence
    Ensure that the commit 4c888bf4f6b330b115d11fac3e0b8bb177b597bb exists in the repository by checking it on the GitHub website.


If the Issue Persists

If you still face issues with git checkout, it could be due to:

  • A missing or incorrect commit hash.
  • A shallow repository clone preventing access to older commits.
  • An error in the way pip is parsing the requirements.txt.

To work around this, you can fork the repository, apply the commit to a branch, and use your fork as the dependency source:

  1. Fork the repository on GitHub.
  2. Apply the commit to a new branch (e.g., bugfix).
  3. Reference your fork and branch in requirements.txt:
    -e git+https://github.com/your-username/kinopoiskpy.git@bugfix#egg=kinopoiskpy
    

This ensures that your changes are preserved and accessible.