anchor.diff:  REM
   REM We work around this by wrapping the original contents of `setup.py` in an
   REM `if` block to only execute during package installation.
  -"%PYTHON%" -c "from __future__ import print_function; input_ = open('setup.py', 'r'); data = input_.read(); input_.close(); output_ = open('setup.py', 'w'); output_.write('\n'.join(['import sys', 'import path_helpers as ph', '''if ph.path(sys.argv[0]).name == 'conda-build-script.py':''', '    sys.argv.pop()', 'else:', '\n'.join([('    ' + d) for d in data.splitlines()])])); output_.close(); print(open('setup.py', 'r').read())"
  +python -c "from __future__ import print_function; input_ = open('setup.py', 'r'); data = input_.read(); input_.close(); output_ = open('setup.py', 'w'); output_.write('\n'.join(['import sys', 'import path_helpers as ph', '''if ph.path(sys.argv[0]).name == 'conda-build-script.py':''', '    sys.argv.pop()', 'else:', '\n'.join([('    ' + d) for d in data.splitlines()])])); output_.close(); print(open('setup.py', 'r').read())"
   if errorlevel 1 exit 1
   
   REM Build Python C-extension
  
positive.code: if errorlevel 1 exit 1
  
  REM Generate Arduino/Python code
  "%PYTHON%" -m paver create_config
  
  REM REM Build firmware
  pio run
  
negative.code: REM XXX **Workaround** Run `scons` in subprocess, since otherwise it causes the
  REM build script to exit early, preventing installation of the Python package
  REM (not sure why this happens...).
  python -c "import subprocess as sp; sp.check_call('scons', shell=True)"
  if errorlevel 1 exit 1
  
  REM Install source directory as Python package.
  echo "Install source directory as Python package."
  python setup.py install --single-version-externally-managed --record record.txt
  if errorlevel 1 exit 1
  