Trying to run a Python program using GitLab's CI pipeline.
I had this running in Teamcity, but I wanted to try in GitLab.
First attempt
I supplied an explicit list of pip install
commands including wmi
.
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:3.8.0
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
before_script:
- python -V # Print out python version for debugging
- pip install virtualenv
- virtualenv venv
- . venv/bin/activate
test:
script:
- python -m pip install --upgrade pip
- python -m pip install locust
- locust -V
- python -m pip install multipledispatch
- python -m pip install pycryptodome
- python -m pip install pandas
- python -m pip install wmi
- python -m pip install pywin32==300
- python -m pip install influxdb_client
- set LOAD_TEST_CONF=load_test.conf
- locust -f ./src/main.py --host http://x.x.x.x:yyyy -u 1000 -t 1m -r 250 -s 1800 --headless --csv=./LoadTestsData --csv-full-history --html=./LoadTestsReport_VPOS.html --stream-file ./data/stream_jsons/streams_vpos.json --database=csv
pages:
stage: deploy
script:
- mv ./LoadTests* ../public/
artifacts:
paths:
- public
ModuleNotFoundError: No module named 'win32com'
Second attempt
So I figured I had to explicitly add a line to pip install pywin32
.
That failed with
ERROR: Could not find a version that satisfies the requirement pywin32
# I tried python:latest, but I used 3.8 successfully in my IDE
image: python:3.8
variables: ....
cache: ...
test:
script:
- python -V
- pip install virtualenv
- virtualenv venv
- . venv/bin/activate
- python -m pip install --upgrade pip
- python -m pip install locust
- locust -V
- python -m pip install pywin32==300 # <----- doesn't like this
- python -m pip install pypiwin32 # or this
- set LOAD_TEST_CONF=load_test.conf
- locust -f ./src/main.py <a bunch of arguments...>
...
Results Obtained
$ python -m pip install pywin32==300
ERROR: Could not find a version that satisfies the requirement pywin32==300 (from versions: 302)
ERROR: No matching distribution found for pywin32==300
It shouldn't be an OS mismatch, since the OS of the build environment is Windows, as I see
OS/Arch: windows/amd64
I also tried python -m pip install -r requirements.txt
, but the results were the same.
How do I resolve this?
Result Using Windows Tag
Zach's answer is getting me on the right track.
I used the exact YAML as in the answer, except with a tag of win2019
. I'm not the admin; this is what I found.