找不到绳线命令(circleci)

2024-06-14 20:25:25 发布

您现在位置:Python中文网/ 问答频道 /正文

当一个新标记被推送到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错误。在

我该如何解决这个错误?在

配置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: /.*/

Tags: installrunnamepycachebinsetupdependencies