-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poetry cannot properly parse URL with Gitlab [deploy tokens] #2062
Comments
Just checked that it works when poetry is |
Hello @xinbinhuang, thanks a lot for reporting. The git url parsing has changed significant within the last release to be more consistent. As I was not aware of something like deploy tokens, the regex will probably not match anymore. I will take a closer look at this. Could you give me please an example how fin swimmer |
Hi @finswimmer , Thanks for the quick response. The Gitlab's doc is here. I tried to generate a few different tokens until hitting an error. # This is Gitlab's format requirements:
# Here Username == <token-name>
Username can contain only letters, digits, '_', '-', '+', and '.' So something like this For the Let me know if you would need extra information or help from me. Thanks |
I am also running into this issue :( Any update or work-a-round here? |
@jedie , while waiting for the bug to be fixed. You can pin your poetry version in your For example
|
@xinbinhuang would making use of gitcredentials be the better apporach here? This would work both in your development and deployment scenarios. As an additional benifit, would allow you to ensure seperation of privilleges using different credentials. As for respecting the git url spec, I agree we should ensure that a url of the form A reasonable approach might be extend the URL validation to also include a new group "password". The user should stil consider |
@abn Thanks for the suggestion, I have not used gitcredentials before. While I think your suggestion is valid in common scenarios for user passwords, it is a different case for Gitlab Deploy Tokens. These deploy tokens are not user credentials and designed specifically by Gitlab with limited permission scopes (similar to service account). So in the context of Gitalb Deploy Tokens, I believe it's valid. While security suggestion by warnings is good (with optional disabling it), I don't think poetry as a package management tool should by any means enforce this validation and should leave this as a choice for the users. I haven't used Gitlab for a while now, so it doesn't affect me that much. I like poetry and hope it will be successful in the future, so I hope poetry can make good decisions along the way. |
Any update here? |
Any update please. Pain point for gitlab users. |
Same here. This is a major blocker now. |
Still blocked because of python-poetry/poetry-core#115 ?!? |
any solution or workaround? I have a deploy token similar to @xinbinhuang but currently poetry fails with invalid git url 😬 |
Unfortunately, gitlab deploy token url does not work when one wants to use a command [tool.poetry.dependencies]
repo-name = {git = "https://gitlab+deploy-token-123:[email protected]/repo_path/repo_name.git", tag = "1.0.0"}
# or
repo-name = {git = "https://gitlab+deploy-token-123:[email protected]/repo_path/repo_name.git", rev = "aabbccdd"}
# or
repo-name = {git = "https://gitlab+deploy-token-123:[email protected]/repo_path/repo_name.git", branch = "next"} Error in our case is: ➜ poetry add git+https://gitlab+deploy-token-123:[email protected]/repo_path/repo_name.git
ValueError
Invalid git url "git+https://gitlab+deploy-token-123:[email protected]/repo_path/repo_name.git"
at venv/lib/python3.8/site-packages/poetry/core/vcs/git.py:137 in parse
133│ groups.get("name"),
134│ groups.get("rev"),
135│ )
136│
→ 137│ raise ValueError('Invalid git url "{}"'.format(url))
138│
139│ @property
140│ def url(self): # type: () -> str
141│ return "{}{}{}{}{}".format(
➜ poetry -V
Poetry version 1.1.10 Installing using pip: pip install git+https://gitlab+deploy-token-123:[email protected]/repo_path/repo_name.git works just fine |
For me it works (installing from private pypi) if I expose my token in [[tool.poetry.source]]
name = "<a_name>"
url = "https://<token_name>:<token>@gitlab.com/api/v4/projects/<project_id>/packages/pypi/simple" |
I still run into the same error on gitlab CI: Locally it works. Both used the same versions: Python 3.8, poetry v1.1.10 @EnriqueSoria This is for PyPi packages and not git source installation, isn't it? |
True, sorry |
So I've looked into related PRs, and python-poetry/poetry-core#115 resolves this issue. One problem I encountered afterwards was that error message: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none It is because our git is in private intranet, and certificate is self-signed. This was resolved by setting: git config http.sslverify false (source: https://forum.gitlab.com/t/server-certificate-verification-failed/7825) |
Any news here?!? |
Same issue here. |
Experiencing the same issues, and even though it's possible to get around it by adding it to |
My Poetry versions are In my case, I was able to use @EnriqueSoria's workaround of using GitLab's private PyPI repository, which allows me to use deploy tokens with In the "source" project's repository (the project which you want to install into one or more "destination" projects), put the following verbatim into # A pipeline for uploading the project as a package to GitLab's private PyPI repository.
# (This allows the project to be installed from Poetry as a URL dependency with a deploy token
# which has `read_package_registry` scope.)
# References:
# <https://docs.gitlab.com/ee/user/packages/pypi_repository/index.html#authenticate-with-a-ci-job-token>
# <https://github.com/python-poetry/poetry/issues/2062>
build-wheel:
when: manual
image: python:latest
script:
- pip install twine
- pip wheel --no-deps .
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi *.whl Now you can publish a wheel to "Packages & Registries" → "Package Registry", by going to "CI/CD" → "Pipelines" and manually start the To install this wheel to some "destination" project, in your destination project's [[tool.poetry.source]]
name = "identifier-for-gitlab-repository"
url = "https://gitlab+deploy-token-123456:[email protected]/api/v4/projects/PROJECTID/packages/pypi/simple" To adapt this snippet to your project, you will need the following pieces of information...
Then run the command poetry add project-name --source=identifier-for-gitlab-repository where If all went well, this will install the package and create an entry in
Using poetry-core / pip installI'm using Docker, and to keep the container slim, instead of
The downside is that pip is not aware of the COPY --from=ghcr.io/tomwright/dasel:v1.24.1-alpine /usr/local/bin/dasel /usr/local/bin/dasel
RUN PIP_EXTRA_INDEX_URL=$( \
dasel select -f pyproject.toml -m \
"tool.poetry.source.(name=identifier-for-gitlab-repository).url" \
) \
pip install --editable . # (The editable flag is not essential here.) Removing the deploy token from pyproject.tomlIt's generally bad practice to keep secrets like deploy tokens in a file like
and then you can delete the TroubleshootingMake sure your deploy token has |
While not exactly allowing what the @xinbinhuang asked for, I reckon #5567 should serve this use case. Can folks needing this feature please have a go at using that PR and provide any feedback. |
@abn No, certainly not. #5567 requires every user to log in. This may be an option for some teams, but it defeats the whole purpose of poetry if I can't just run commands to get all packages installed, but need to do some manual steps before. What is being requested here is to have an option for private-but-not-secret repositories, where the alternative would be a git submodule or checking it into the main project. To be frank, I'm not sure what the problem is – wouldn't you only have to accept these URLs and pass them on? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
Poetry cannot properly parse URL with gitlab deploy tokens. The project is hosted on a internal hosted Gitlab server.
The same git URL worked before, but I am not sure since when it is failing.
Command I ran:
Output
The text was updated successfully, but these errors were encountered: