Python 3 support

Python 3 support

I am a complete newbie to Gitlab and in the past I only did Dockerfiles. I use shared runners and somehow I always get a docker+machine executor. I have a generator.py-script which builds a static html-page in the public-folder.

I have a requirements.txt in my repo and I want to install the packages. Most examples I could find over Google specified e.g. image: python:3.7 - however for me this resulted in an error:

Errno 2] No such file or directory: 'requirements.txt'

Apparently the runner doesn’t have access to my requirements.txt. If I don’t specify any image gitlab uses a ruby:2.5 image as executor and after installiing python-pip I get the same error message,

How can I have the complete gitlab-repo in my build environment? As previously written google or reading the docs didn’t help for me.

minimal .gitlab-ci.yml:

---
image: python:3.9-slim-buster
before_script:
- python3 -V
- pip install -r requirements.txt
- pip install -r backend/requirements.txt
stages:
- ".pre"
- build
- ".post"
prepare:
  stage: build
  script:
  - python3 generator.py

Hi @moritz2389
I wouldn’t use image and before_script as top-level keywords, because thats deprecated. You also don’t need to specify .pre and .post stages in stages

something like this works for me just fine

stages:
    - build

.template_job:
    image: python:3.9-slim-buster
    before_script:
        - python3 -V
        - pip install -r requirements.txt

prepare:
    extends: ['.template_job']
    stage: build
    script:
        - python3 generator.py