简体   繁体   English

在gitlab ci中使用pipenv

[英]using pipenv with gitlab ci

I'm using pipenv in my local development and integrating Gitlab CI/CD to deploy and testing. 我在本地开发中使用pipenv ,并集成了Gitlab CI / CD进行部署和测试。

I do not want to generated requirements.py file every time I install a new package. 我不想每次安装新程序包时都生成requirements.py文件。 Therefore I want to use pipenv with Gitlab runner too. 因此,我也想在pipenv使用Gitlab

My gitlab-ci.yml file contains 我的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/


...

But pipeline is failing with error 但是管道由于错误而失败

$ 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)

I even tried with --python 3.6 flag but same error. 我什至尝试使用--python 3.6标志,但存在相同的错误。

My Pipfile contents are 我的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"

Update 2 更新2

replacing python-dev python-pip with python3-dev python3-pip is installing python version 3.5 and while running the command pipenv install giving following error python3-dev python3-pip替换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

To add environment variables to your gitlab-ci.yml file: https://docs.gitlab.com/ce/ci/variables/#gitlab-ci-yml-defined-variables 要将环境变量添加到gitlab-ci.yml文件: https ://docs.gitlab.com/ce/ci/variables/#gitlab-ci-yml-defined-variables

Also use a python docker image instead of installing python: https://docs.gitlab.com/ce/ci/docker/using_docker_images.html#define-image-and-services-from-gitlab-ci-yml 还可以使用python docker映像而不是安装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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM