machine:
  python:
    version: 2.7.10
dependencies:
  override:
    - "pip install -U pip wheel setuptools"
    - "pip install -e git://github.com/edx/xblock-sdk.git@bddf9f4a2c6e4df28a411c8f632cc2250170ae9d#egg=xblock-sdk"
    - "pip install -r requirements.txt"
    - "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/base.txt"
    - "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/test.txt"
    - "pip uninstall -y xblock-problem-builder && python setup.py sdist && pip install dist/xblock-problem-builder-2.5.0.tar.gz"
    - "pip install -r test_requirements.txt"
    - "mkdir var"
test:
  override:
    - "if [ $CIRCLE_NODE_INDEX = '0' ]; then pep8 problem_builder --max-line-length=120; fi":
        parallel: true
    - "if [ $CIRCLE_NODE_INDEX = '1' ]; then pylint problem_builder --disable=all --enable=function-redefined,undefined-variable,unused-import,unused-variable; fi":
        parallel: true
    - "python run_tests.py":
        parallel: true
        files:
          - "problem_builder/v1/tests/**/*.py"
          - "problem_builder/tests/**/*.py"

machine:
  python:
    version: 2.7.10
dependencies:
  override:
    - "pip install -U pip wheel"
    - "pip install setuptools==24.3.1"
    - "pip install -e git://github.com/edx/xblock-sdk.git@bddf9f4a2c6e4df28a411c8f632cc2250170ae9d#egg=xblock-sdk"
    - "pip install -r requirements.txt"
    - "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/base.txt"
    - "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/test.txt"
    - "pip uninstall -y xblock-problem-builder && python setup.py sdist && pip install dist/xblock-problem-builder-2.5.0.tar.gz"
    - "pip install -r test_requirements.txt"
    - "mkdir var"
test:
  override:
    - "if [ $CIRCLE_NODE_INDEX = '0' ]; then pep8 problem_builder --max-line-length=120; fi":
        parallel: true
    - "if [ $CIRCLE_NODE_INDEX = '1' ]; then pylint problem_builder --disable=all --enable=function-redefined,undefined-variable,unused-import,unused-variable; fi":
        parallel: true
    - "python run_tests.py":
        parallel: true
        files:
          - "problem_builder/v1/tests/**/*.py"
          - "problem_builder/tests/**/*.py"

Fix dependency installation for CircleCI builds.
Fix dependency installation for CircleCI builds.

XBlock is listed as a dependency in requirements files for xblock-sdk,
xblock-utils, and problem-builder itself. These files list different (but compatible)
versions of the XBlock repo. Because of that, XBlock gets installed multiple times
when installing dependencies for CircleCI builds.

Starting with setuptools 25.0.0, the behavior for installing packages on top of
existing installs changed; see https://github.com/pypa/setuptools/issues/729
for an example issue that this change in behavior caused.

For problem-builder CI builds, the issue was that after installing all dependencies,
the egg link for XBlock ended up pointing to the installation of problem-builder itself,
creating a situation where the code that ships with XBlock was not accessible from modules
that depend on it. This caused imports for any classes defined in the XBlock repo to fail,
and CircleCI builds errored out.

To fix this, we temporarily pin setuptools to the most recent version
that does not exhibit this behavior (24.3.1).

An upstream fix seems to be underway (via https://github.com/pypa/pip/pull/3904),
but it hasn't been merged/released yet.
