From cb78fae02522a1cdcaaa23cd3bda488bfba61152 Mon Sep 17 00:00:00 2001 From: Guilhem Bonnefille <guilhem.bonnefille@c-s.fr> Date: Tue, 3 Jan 2023 14:21:45 +0000 Subject: [PATCH] doc: introduce PIP_EXTRA_INDEX_URL Useful in corporate environment with more than one repository to access. --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 8306148..e2d74ce 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ The Python template uses some global configuration used throughout all jobs. | `PYTHON_PROJECT_DIR` | Python project root directory | `.` | | `PYTHON_BUILD_SYSTEM`| Python build-system to use to install dependencies, build and package the project (see below) | _none_ (auto-detect) | | `PIP_INDEX_URL` | Python repository url | _none_ | +| `PIP_EXTRA_INDEX_URL` | Exra Python repository url | _none_ | | `PIP_OPTS` | pip [extra options](https://pip.pypa.io/en/stable/cli/pip/#general-options) | _none_ | | `PYTHON_EXTRA_DEPS` | Python extra sets of dependencies to install<br/>For [Setuptools](https://setuptools.pypa.io/en/latest/userguide/dependency_management.html?highlight=extras#optional-dependencies) or [Poetry](https://python-poetry.org/docs/pyproject/#extras) only | _none_ | | `PYTHON_REQS_FILE` | Main requirements file _(relative to `$PYTHON_PROJECT_DIR`)_<br/>For [Requirements Files](https://pip.pypa.io/en/stable/user_guide/#requirements-files) build-system only | `requirements.txt` | @@ -364,3 +365,25 @@ The template handles both classic variable and file variable. Simply specify :lock: `$GIT_USERNAME` and :lock: `$GIT_PASSWORD` as secret project variables. Note that the password should be an access token (preferably a [project](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html) or [group](https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html) access token) with `write_repository` scope and `Maintainer` role. + +#### Pip repositories + +When depending on Python packages published in [GitLab's packages registry](https://docs.gitlab.com/ee/user/packages/pypi_repository/), it could be useful to configure a group level Package. +But such repository will require an authenticated access. + +To do so, simply set the `PIP_INDEX_URL` and use the CI job token. + +```YAML +variables: + PIP_INDEX_URL: "${CI_SERVER_PROTOCOL}://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4/groups/<group-id>/-/packages/pypi/simple" +``` + +In a corporate environment, you can be faced to two repositories: the corporate proxy-cache and the project repository. + +Simply use both `PIP_INDEX_URL` and `PIP_EXTRA_INDEX_URL`. + +```YAML +variables: + PIP_INDEX_URL: "https://cache.corp/repository/pypi/simple" + PIP_EXTRA_INDEX_URL: "${CI_SERVER_PROTOCOL}://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4/groups/<group-id>/-/packages/pypi/simple" +``` -- GitLab