【问题标题】:Deploying Python package on Anaconda with TravisCI使用 TravisCI 在 Anaconda 上部署 Python 包
【发布时间】:2020-12-05 01:20:14
【问题描述】:

我正在尝试使用 TravisCI 在 Anaconda 上部署我的 Python 包。我已经设置了 PyPi 部署,运行良好。这是travis.yml文件的相关部分:

deploy:
  provider: pypi
  username: "__token__"
  password:
    secure: ......
  on:
    tags: true
  distributions: "sdist bdist_wheel"
  skip_existing: true

after_deploy:
  - conda install conda-build
  - conda install anaconda-client
  - bash .ci/conda_upload.sh

错误发生在.ci/conda_upload.sh。这里是conda_upload.sh

USER=myusername

mkdir ~/conda-bld
conda config --set anaconda_upload no
export CONDA_BLD_PATH=~/conda-bld
ls -l
conda build .

find $CONDA_BLD_PATH/ -name *.tar.bz2 | while read file
do
    echo $file
    anaconda -t $CONDA_UPLOAD_TOKEN upload -u $USER $file --force
done

我收到的错误消息发生在conda build .,它找不到setup.py 文件。但是之前的ls -l 调用清楚地表明那里有一个setup.py 文件:

...
-rw-rw-r-- 1 travis travis     1190 Aug 15 09:42 setup.py
...

我也加入了

build:
  script_env:
   - CONDA_BLD_PATH

meta.yaml 文件中。

这是我在 Travis 上获得的完整输出:

WARNING:conda_build.metadata:No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11

Adding in variants from internal_defaults

INFO:conda_build.variants:Adding in variants from internal_defaults

Attempting to finalize metadata for pysprint

INFO:conda_build.metadata:Attempting to finalize metadata for pysprint

Collecting package metadata (repodata.json): ...working... done

Solving environment: ...working... done

Collecting package metadata (repodata.json): ...working... done

Solving environment: ...working... done

BUILD START: ['pysprint-0.12.1-py38_0.tar.bz2']

Collecting package metadata (repodata.json): ...working... done

Solving environment: ...working... done

## Package Plan ##
  environment location: /home/travis/conda-bld/pysprint_1597484753718/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl

The following NEW packages will be INSTALLED:

    # deleted this section to save space

Preparing transaction: ...working... done

Verifying transaction: ...working... done

Executing transaction: ...working... done

Collecting package metadata (repodata.json): ...working... done

Solving environment: ...working... done

/home/travis/conda-bld/pysprint_1597484753718/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/bin/python: can't open file 'setup.py': [Errno 2] No such file or directory

source tree in: /home/travis/conda-bld/pysprint_1597484753718/work

export PREFIX=/home/travis/conda-bld/pysprint_1597484753718/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl

export BUILD_PREFIX=/home/travis/conda-bld/pysprint_1597484753718/_build_env

export SRC_DIR=/home/travis/conda-bld/pysprint_1597484753718/work

Traceback (most recent call last):

  File "/home/travis/miniconda/bin/conda-build", line 11, in <module>

    sys.exit(main())

  File "/home/travis/miniconda/lib/python3.8/site-packages/conda_build/cli/main_build.py", line 474, in main

    execute(sys.argv[1:])

  File "/home/travis/miniconda/lib/python3.8/site-packages/conda_build/cli/main_build.py", line 463, in execute

    outputs = api.build(args.recipe, post=args.post, test_run_post=args.test_run_post,

  File "/home/travis/miniconda/lib/python3.8/site-packages/conda_build/api.py", line 208, in build

    return build_tree(absolute_recipes, config, stats, build_only=build_only, post=post,

  File "/home/travis/miniconda/lib/python3.8/site-packages/conda_build/build.py", line 2859, in build_tree

    packages_from_this = build(metadata, stats,

  File "/home/travis/miniconda/lib/python3.8/site-packages/conda_build/build.py", line 1994, in build

    utils.check_call_env(cmd, env=env, rewrite_stdout_env=rewrite_env,

  File "/home/travis/miniconda/lib/python3.8/site-packages/conda_build/utils.py", line 405, in check_call_env

    return _func_defaulting_env_to_os_environ('call', *popenargs, **kwargs)

  File "/home/travis/miniconda/lib/python3.8/site-packages/conda_build/utils.py", line 385, in _func_defaulting_env_to_os_environ

    raise subprocess.CalledProcessError(proc.returncode, _args)

subprocess.CalledProcessError: Command '['/bin/bash', '-o', 'errexit', '/home/travis/conda-bld/pysprint_1597484753718/work/conda_build.sh']' returned non-zero exit status 2.

问题似乎是环境位置设置为

environment location: /home/travis/conda-bld/pysprint_1597484753718/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl

但我不知道如何解决这个问题。我对 linux 环境和 shell 脚本很陌生,如果有人可以帮助我,我将不胜感激。

编辑: meta.yaml的内容:

{% set name = "pysprint" %}
{% set version = "0.12.1" %}

package:
  name: "{{ name|lower }}"
  version: "{{ version }}"

source:
  url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz"
  sha256: 5fee159c59c81fd31957e23bbd292bcfc1c947583f27eda7f4215594ec898ddd

build:
  script_env:
   - CONDA_BLD_PATH

requirements:
  host:
    - matplotlib
    - numpy >=1.16.6
    - pandas
    - pip
    - python
    - scipy

test:
  imports:
    - pysprint

【问题讨论】:

  • 你的meta.yamlbuild.sh的完整内容是什么?
  • @darthbith build.sh: $PYTHON setup.py install 。在 meta.yaml 中:包版本、名称、要求、脚本环境变量和测试导入。如果您需要完整文件,我可以更新问题。本地 conda 构建使用指定的 meta.yamlsetup.py 成功。

标签: python anaconda conda travis-ci continuous-deployment


【解决方案1】:

事实证明,deploy 部分以某种方式弄乱了 conda 部署。我将 after_deploy 部分更改为 before_deploy 并且它可以工作。

before_deploy:
  - conda install conda-build
  - conda install anaconda-client
  - bash .ci/conda_upload.sh

deploy:
  provider: pypi
  username: "__token__"
  password:
    secure: ......
  on:
    tags: true
  distributions: "sdist bdist_wheel"
  skip_existing: true

但是我根本不清楚是什么导致了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-06
    • 2014-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2018-03-10
    • 1970-01-01
    相关资源
    最近更新 更多