I am using circleci to automatically deploy my python package to PyPi when a new tag is being pushed to GitHub. I've been following this tutorial
My workflow is failing with the error home/circleci/project/twitter_sentiment/bin/python: No module named twine
I've tried to make sure twine was installed prior to calling the twine command. I've also tried to call the twine command with python -m twine
From my understanding, it seems that twine is not added to the path of the container - which causes the command not found
error.
How would I go about solving this error?
config.yml file
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: /.*/
You're creating a virtual environment, activating it, and then installing twine outside of it.
Remove --user
from pip install --user --upgrade twine