Django project migrating to CircleCI 2.0 - explicitly add project to Python path

I’m unsure how to set the PYTHONPATH correctly in CircleCI 2.0 to allow the build to run. This is a Django project that was previously building on CircleCI 1.0 successfully so I’ve started by using the auto generated config.yml file.

version: 2
      jobs:
        build:
          working_directory: ~/mygithubname/myproject
          parallelism: 1
          shell: /bin/bash --login

environment:
  CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
  CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
  DATABASE_URL: 'sqlite://:memory:'
  DJANGO_SETTINGS_MODULE: ocdaction.settings.test
  DEBUG: 0
  PYTHONPATH: ${HOME}/myproject/myproject

docker:
- image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
  command: /sbin/init
steps:

- checkout

- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS

- restore_cache:
    keys:
    # This branch if available
    - v1-dep-{{ .Branch }}-
    # Default branch if not
    - v1-dep-master-
    # Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
    - v1-dep-
- run: pip install -r requirements/testing.txt

- save_cache:
    key: v1-dep-{{ .Branch }}-{{ epoch }}
    paths:
    # This is a broad list of cache paths to include many possible development environments
    # You can probably delete some of these entries
    - vendor/bundle
    - ~/virtualenvs
    - ~/.m2
    - ~/.ivy2
    - ~/.bundle
    - ~/.go_workspace
    - ~/.gradle
    - ~/.cache/bower

- run: pytest

- store_test_results:
    path: /tmp/circleci-test-results

- store_artifacts:
    path: /tmp/circleci-artifacts
- store_artifacts:
    path: /tmp/circleci-test-results

the run: pytest command is failing in CircleCI with the error stating pytest-django could not find a Django project (no manage.py file could be found). You must explicitly add your Django project to the Python path to have it picked up. I know what the error means but not sure how to fix in version 2 (it works when building on version 1), and I’m struggling to find anything in the documents.

Can anyone help please?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.