используя pipenv с gitlab ci - PullRequest
0 голосов
/ 24 июня 2018

Я использую pipenv в своей локальной разработке и интегрирую Gitlab CI / CD для развертывания и тестирования.

Я не хочу генерировать файл requirements.py каждый раз, когда я устанавливаю новый пакет.Поэтому я хочу использовать pipenv с Gitlab бегуном.

Мой gitlab-ci.yml файл содержит

stages:
  - test
  - deploy

test:
  stage: test
  script:
  - apt-get update -qy
  - apt-get install -y ruby-dev
  - apt-get install -y python-dev python-pip
  - pip install pipenv
  - pipenv install
  - pipenv run py.test src/


...

Но конвейер не работает с ошибкой

$ pipenv install
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Warning: Python 3.6 was not found on your system…
You can specify specific versions of Python with:
  $ pipenv --python path/to/python
/usr/local/lib/python2.7/dist-packages/pipenv/_compat.py:86: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/pipenv-fmGiYD-requirements'>
  warnings.warn(warn_message, ResourceWarning)

Я даже пытался с флагом --python 3.6, но с той же ошибкой.

Мое Pipfile содержимое

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

[packages]
django = "*"
...
pytest = "*"
pytest-django = "*"
pytest-cov = "*"
pdbpp = "*"
mixer = "*"

[dev-packages]

[requires]
python_version = "3.6"

Обновление 2

замена python-dev python-pip с python3-dev python3-pip устанавливает версию Python 3.5 и при запуске команды pipenv install выдает следующую ошибку

RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult http://click.pocoo.org/python3/for mitigation steps.

This system supports the C.UTF-8 locale which is recommended.
You might be able to resolve your issue by exporting the
following environment variables:

export LC_ALL=C.UTF-8
export LANG=C.UTF-8
ERROR: Job failed: exit code 1

1 Ответ

0 голосов
/ 25 июня 2018

Чтобы добавить переменные среды в ваш файл gitlab-ci.yml: https://docs.gitlab.com/ce/ci/variables/#gitlab-ci-yml-defined-variables

Также используйте образ докера python вместо установки python: https://docs.gitlab.com/ce/ci/docker/using_docker_images.html#define-image-and-services-from-gitlab-ci-yml

image: python:3.6
test:
    stage: test
    variables:
        LC_ALL=C.UTF-8
        LANG=C.UTF-8
...