Pip Install from a Private Repo

Python
How to pip install from a private repo
Author

Ziyue Li

Published

November 6, 2022

You can pip install in the following way:

pip install <package_name>@git+ssh://git@github.com/<user>/<repo_name>@<branch>

In setup.py, we can add these packages in the following way:

setup(
  name='<package>',
  install_requires=[
    '<package_name>@git+ssh://git@github.com/<user>/<repo_name>@<branch>',
    '<package_name>@git+https://<access_token>@github.com/<user>/<repo_name>@<branch>'
  ]
)

If we are doing editable installation, it looks like the following:

pip install -e https://<access_token>@github.com/<user>/<repo_name>#egg=<package_name>

For GitLab CI/CD, one needs to do it in the following way:

pip install -e https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.example.com/<namespace>/<project>#egg=<package_name>