Home > Net >  How to install an already distributable Python package (wheel) from a private github repository?
How to install an already distributable Python package (wheel) from a private github repository?

Time:12-14

I am storing distributable wheel packages from several modules in a private GitHub repository. Here is the repository structure:

myrepo\
       | module1\
       |         | pyproject.toml
       |         | src\
       |         |     | *.py
       |         | dist\
       |                | module1.whl
       | module2\
                 | pyproject.toml
                 | src\
                 |     | *.py
                 | dist\
                        | module2.whl

Currently, I'm installing them using the pip tool from the source, which works. But, each time it clones the whole repository and builds the package locally.

pip install ssh git://[email protected]/myorg/myrepo.git#subdirectory=module1

Is there a way to tell pip to only download and install the module1.whl and module2.whl files and not the whole repository?

I've tried the below approaches so far, but none of them works:

pip install ssh git://[email protected]/myorg/myrepo.git#subdirectory=module1/dist/module1-0.1.0-py3-none-any.whl

and

pip install https://github.com/myorg/myrepo/blob/main/module1/dist/module1-0.1.0-py3-none-any.whl

I've already checked existing questions like Is it possible to use pip to install a package from a private github repository? and Distributing my python module inside organization, but none of them describe this use case.


Edited

This is already possible for Public repositories like, so it is not something strange:

pip install https://github.com/numpy/numpy/releases/download/vx.y.z/numpy-x.y.z.tar.gz

CodePudding user response:

After elaborate exploration, I found that it is not possible to install release packages of a private GitHub repository by pip.

The reason is that GitHub only allows downloading such files using GitHub tokens and not by deploy keys.

Suggested ways to download the file and add it to the container, or to use API tokens to download the package and install it in the container and install it from there are not viable as well. Because you either have to update the file manually, or update the API token.

The only possible way is to create a private package repository on google and push the release packages there.

  • Related