flit icon indicating copy to clipboard operation
flit copied to clipboard

Bad Request for url (400 Client Error) on Gitlab CI

Open jorgebrunal opened this issue 1 year ago • 2 comments

Hi!

Describe the bug:

I am publishing my package in Gitlab CI using flit publish and I am getting these errors when uploading the package to the registry

To Reproduce:

on my local machine works fine when building the package and submitting it to Gitlab registry

Details
(.venv) [brunaldo@fedora oaspy] $ flit publish --repository gitlab
Version number normalised: '2023.08.25' -> '2023.8.25' (see PEP 440)                                    W-flit_core.versionno
Found 19 files tracked in git                                                                                    I-flit.sdist
Built sdist: dist/oaspy-2023.8.25.tar.gz                                                                    I-flit_core.sdist
Version number normalised: '2023.08.25' -> '2023.8.25' (see PEP 440)                                    W-flit_core.versionno
Copying package file(s) from /tmp/tmp1warla15/oaspy-2023.8.25/src/oaspy                                     I-flit_core.wheel
Writing metadata files                                                                                      I-flit_core.wheel
Writing the record of files                                                                                 I-flit_core.wheel
Built wheel: dist/oaspy-2023.8.25-py3-none-any.whl                                                          I-flit_core.wheel
Using repository at https://gitlab.com/api/v4/projects/47862338/packages/pypi                                   I-flit.upload
Uploading dist/oaspy-2023.8.25-py3-none-any.whl...                                                              I-flit.upload
Package is at https://gitlab.com/api/v4/projects/47862338/packages/pypi/oaspy                                   I-flit.upload
Using repository at https://gitlab.com/api/v4/projects/47862338/packages/pypi                                   I-flit.upload
Uploading dist/oaspy-2023.8.25.tar.gz...                                                                        I-flit.upload
Package is at https://gitlab.com/api/v4/projects/47862338/packages/pypi/oaspy                                   I-flit.upload

...but when I run the pipeline in Gitlab it generates the following error:

Details
$ flit build --no-use-vcs
Fetching list of valid trove classifiers               I-flit.validate
Version number normalised: '2023.08.25' -> '2023.8.25' (see PEP 440)  W-flit_core.versionno
Built sdist: dist/oaspy-2023.8.25.tar.gz             I-flit_core.sdist
Version number normalised: '2023.08.25' -> '2023.8.25' (see PEP 440)  W-flit_core.versionno
Copying package file(s) from /tmp/tmptdjz0g0s/oaspy-2023.8.25/src/oaspy  I-flit_core.wheel
Writing metadata files                               I-flit_core.wheel
Writing the record of files                          I-flit_core.wheel
Built wheel: dist/oaspy-2023.8.25-py3-none-any.whl   I-flit_core.wheel
$ flit publish --no-use-vcs
Version number normalised: '2023.08.25' -> '2023.8.25' (see PEP 440)  W-flit_core.versionno
Built sdist: dist/oaspy-2023.8.25.tar.gz             I-flit_core.sdist
Version number normalised: '2023.08.25' -> '2023.8.25' (see PEP 440)  W-flit_core.versionno
Copying package file(s) from /tmp/tmpl4fwszuw/oaspy-2023.8.25/src/oaspy  I-flit_core.wheel
Writing metadata files                               I-flit_core.wheel
Writing the record of files                          I-flit_core.wheel
Built wheel: dist/oaspy-2023.8.25-py3-none-any.whl   I-flit_core.wheel
Using repository at https://gitlab.com/api/v4/projects/47862338/packages/pypi  I-flit.upload
Uploading dist/oaspy-2023.8.25-py3-none-any.whl...       I-flit.upload
Traceback (most recent call last):
  File "/usr/local/bin/flit", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/flit/__init__.py", line 200, in main
    main(args.ini_file, repository, args.pypirc, formats=set(args.format or []),
  File "/usr/local/lib/python3.10/site-packages/flit/upload.py", line 277, in main
    do_upload(built.wheel.file, built.wheel.builder.metadata, pypirc_path, repo_name)
  File "/usr/local/lib/python3.10/site-packages/flit/upload.py", line 252, in do_upload
    upload_file(file, metadata, repo)
  File "/usr/local/lib/python3.10/site-packages/flit/upload.py", line 245, in upload_file
    resp.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://gitlab.com/api/v4/projects/47862338/packages/pypi
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

the complete pipeline is here...

Expected behavior:

be able to generate the package and send it to Gitlab Registry (initially) and then to PyPI. 😄

Desktop (please complete the following information):

  • OS: Fedora Workstation (38)
  • Python version: 3.10.12
  • Flit version: 3.9.0

Additional context:

my .gitlab-ci.yml file

image: python:3.10-buster

stages:
  - deploy

before_script:
   - pip install flit
   - flit build --no-use-vcs

deploy_staging:
  stage: deploy
  variables:
    FLIT_USERNAME: $STAGING_PAT_NAME
    FLIT_PASSWORD: $STAGING_PAT_TOKEN
    FLIT_INDEX_URL: https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi
  script:
    - flit publish --no-use-vcs
  only:
    - master
  cache:
    paths:
      - dist/

in the before_script step I am using it that way because it generated another error:

Details
$ flit build
Fetching list of valid trove classifiers               I-flit.validate
Version number normalised: '2023.08.25' -> '2023.8.25' (see PEP 440)  W-flit_core.versionno
Traceback (most recent call last):
  File "/usr/local/bin/flit", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/flit/__init__.py", line 191, in main
    main(args.ini_file, formats=set(args.format or []),
  File "/usr/local/lib/python3.10/site-packages/flit/build.py", line 46, in main
    sdist_file = sb.build(dist_dir, gen_setup_py=gen_setup_py)
  File "/usr/local/lib/python3.10/site-packages/flit_core/sdist.py", line 175, in build
    files_to_add = self.apply_includes_excludes(self.select_files())
  File "/usr/local/lib/python3.10/site-packages/flit/sdist.py", line 173, in select_files
    untracked_deleted = vcs_mod.list_untracked_deleted_files(self.cfgdir)
  File "/usr/local/lib/python3.10/site-packages/flit/vcs/git.py", line 12, in list_untracked_deleted_files
    outb = check_output(['git', 'ls-files', '--deleted', '--others',
  File "/usr/local/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

more info about this error, here

some links of interest that I have reviewed:

thank you very much! sorry for the bad translation, I don't speak English.

jorgebrunal avatar Aug 26 '23 06:08 jorgebrunal