Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipenv gets blocked while running with Docker in Gitlab

I created this simple project in Gitlab:

https://gitlab.com/PequeX/deleteme

With a Pipfile that installs only a couple of packages:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "*"

[packages]
requests = "*"

[requires]
python_version = "3.7"

And a very simple .gitlab-ci.yml file:

image: peque/python-devel

before_script:
  - pipenv sync --dev

python36:
  script:
    - pipenv run pytest

There is also the autogenerated Pipfile.lock file. Which I will not paste here as it is not very interesting.

Now, the problem is Gitlab seems to get blocked when calling pipenv sync:

https://gitlab.com/PequeX/deleteme/-/jobs/171273142

There is no output printed on the log and no error. It just gets blocked forever. And then, eventually, it timeouts (because Gitlab would not let you run a pipeline forever).

What is wrong or how could I successfully run pipenv sync? Note that I would like to keep using the same peque/python-devel image from Docker Hub, as I need to have multiple Python versions installed for my pipelines.

Update

Tried unsetting the CI variable as @Hernan Garcia suggests in his answer, with no luck:

  • Branch
  • Error (does not find package)

I also tried with pipenv shell as @Hernan Garcia suggests in his comments, with no luck:

  • Branch
  • Error (pipenv shell crashes)
like image 452
Peque Avatar asked Mar 04 '19 15:03

Peque


2 Answers

As mentioned in another answer defining an empty CI variable will solve the build stuck issue.

Then the second issue that you will face due to not finding pytest and this is because the docker image is missing which package and this makes pipenv not able to find pytest.

The final gitlab-ci.yml file should be similar to the following:

image: peque/python-devel

variables:
  CI: ""

before_script:
  - pipenv sync --dev
  - yum install -y which

python36:
  script:
    - pipenv run pytest

And the final output will be:

$ pipenv run pytest
============================= test session starts ==============================
platform linux -- Python 3.7.2, pytest-4.3.0, py-1.8.0, pluggy-0.9.0
rootdir: /builds/mostafahussein/deleteme, inifile:
collected 0 items

========================= no tests ran in 0.01 seconds =========================


Regarding this issue:
termios.error: (25, 'Inappropriate ioctl for device')

This is because pipenv shell needs a tty to run without raising the above error however GitLab CI does not provide a tty since there are no user inputs as far as i know. So it will be better to use the first method which is pipenv run.

like image 58
Mostafa Hussein Avatar answered Nov 07 '22 11:11

Mostafa Hussein


I could fix it by using this workaround:
https://github.com/pypa/pipenv/issues/3534#issuecomment-464510351

Add the following to your .gitlab-ci.yml file to unset CI variable:

variables:
    CI: ""

Check this succeeded job:
https://gitlab.com/hernandanielg/deleteme/-/jobs/171342796

;)

like image 1
Hernan Garcia Avatar answered Nov 07 '22 11:11

Hernan Garcia