If you have python library that you want to keep it private and install it with pip install
, you'll need to generate a deploy token and include the username and token in the git url:
On gitlab repository go to Settings
> Repository
and click Expand
on Deploy Tokens.
In the form under Deploy Token section, add a name for your token (describe what is it for), live Expires at empty if you don't want the token to expire automatically then add a username, select the checkbox for read_repository
and then click on Create deploy token.
The generated token will be displayed on the next page, you'll need to copy it because it will be displayed only once.
To install the packge you will need to run the following command:
pip install git+https://{token_username}:{generated_token}@gitlab.com/{your_gitlab_username}/{repository_name}.git
Once is done, if you run pip freeze
you will see the name of the package and the git commit hash, but, you will not see the username and token there.
That means, if you want to install it in a docker container from requirements.txt, you need to add the username and token there.