找不到麻线命令(圆圈)

时间:2018-11-13 00:06:00

标签: python pypi circleci-2.0 twine

当新标签被推送到GitHub时,我正在使用circleci将python软件包自动部署到PyPi。我一直在关注这个tutorial

我的工作流失败,并显示错误home/circleci/project/twitter_sentiment/bin/python: No module named twine

在调用twine命令之前,我尝试确保已安装了twine。我还尝试用python -m twine调用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: /.*/

1 个答案:

答案 0 :(得分:1)

您正在创建一个虚拟环境,将其激活,然后在其外部安装麻线。

--user删除pip install --user --upgrade twine