I am using Poetry for dependency and packaging of my project.
One of my python package maintained in GitLab package registry. And the pip installation command goes straight forward
pip install <my_package> --index-url https://__token__:<your_personal_token>@gitlab.com/api/v4/projects/<project_id>/packages/pypi/simple
But I am unable to add this to my pyproject.toml dependency from GitLab package registry.
This command works for me
[tool.poetry.dependencies]
<my_package> = {git = "https://<token_name>:<>@gitlab.com/lululemon/global-tech-services/retail-engineering-department/dsp/dsp-logging.git"}
But it's not getting installed from package registry rather directly from the codebase.
I am able to fix it by adding poetry source. Below are the commands to add a package dependency from gitlab package registry
poetry source add --secondary foo https://gitlab.com/api/v4/projects/<project_id>/packages/pypi/simple
poetry config http-basic.foo <token_key> <token_value>
poetry add <package> --source=foo
Assume that you have a Gitlab repository MY_REPO (arbitary name, internal to poetry) whose project ID is MY_PROJECT_ID (indicated on the main page of your project) that provides the python module MY_MODULE that you access through a CI/personal token:
poetry source add --priority supplemental MY_REPO https://MY_GITLAB/api/v4/projects/MY_PROJECT_ID/packages/pypi/simple
poetry config http-basic.MY_REPO __token__ MY_TOKEN
poetry add MY_MODULE --source MY_REPO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With