当一个新标签被推送到 GitHub 时,我正在使用 circleci 自动将我的 python 包部署到 PyPi。我一直在关注这个教程
我的工作流程因错误而失败home/circleci/project/twitter_sentiment/bin/python: No module named twine
我试图确保在调用 twine 命令之前安装 twine。我也尝试过调用 twine 命令python -m twine
根据我的理解,似乎 twine 没有添加到容器的路径中 - 这会导致command not found
错误。
我将如何解决这个错误?
config.yml 文件
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6
working_directory: ~/twitter-sentiment
steps:
- checkout
- run:
name: install dependencies
command: |
python3 -m venv twitter_sentiment
. twitter_sentiment/bin/activate
pip install -r requirements.txt
- save_cache:
paths:
- ./twitter_sentiment
key: v1-dependencies-{{ checksum "setup.py" }}
runLibraryTest:
docker:
- image: circleci/python:3.6
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "setup.py" }}
- run:
name: run twitter_sentiment tests
command: |
python3 -m venv twitter_sentiment
. twitter_sentiment/bin/activate
pip install -r requirements.txt
cd test/
python3 -m unittest test_twitterSentiment
- save_cache:
paths:
- ./twitter_sentiment
key: v1-dependencies-{{ checksum "setup.py" }}
- store_artifacts:
path: test-reports
destination: test-reports
deploy:
docker:
- image: circleci/python:3.6
steps:
- checkout
- restore_cache:
key: v1-dependencies-{{ checksum "setup.py" }}
- run:
name: verify git tag vs version
command: |
python3 -m venv twitter_sentiment
. twitter_sentiment/bin/activate
pip install -r requirements.txt
python3 setup.py verify
- run:
name: create package files
command: |
python3 setup.py sdist bdist_wheel
- run:
name: create .pypirc file
command: |
echo -e "[pypi]" >> .pypirc
echo -e "repository = https://pypi.org/legacy/"
echo -e "username = TeddyCr" >> .pypirc
echo -e " = $PYPI_PASSWORD" >> .pypirc
- run:
name: upload package to pypi server
command: |
python3 -m venv twitter_sentiment
. twitter_sentiment/bin/activate
pip install --user --upgrade twine
python -m twine upload dist/*
- save_cache:
paths:
- ./twitter_sentiment
key: v1-dependencies-{{ checksum "setup.py" }}
workflows:
version: 2
build_and_deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- runLibraryTest:
requires:
- build
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
- deploy:
requires:
- runLibraryTest
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/