Skip to content

Commit

Permalink
fix breakage related to Windows env vars being strings
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed Aug 17, 2016
1 parent 9c79a86 commit 7305e97
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
14 changes: 7 additions & 7 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .conda_interface import get_index
from .conda_interface import PY3
from .conda_interface import fetch_index
from .conda_interface import prefix_placeholder, linked, move_to_trash, symlink_conda
from .conda_interface import prefix_placeholder, linked, symlink_conda
from .conda_interface import Locked
from .conda_interface import url_path
from .conda_interface import Resolve, MatchSpec, NoPackagesFound
Expand All @@ -36,7 +36,7 @@
from conda_build.scripts import create_entry_points, prepend_bin_path
from conda_build.post import (post_process, post_build,
fix_permissions, get_build_metadata)
from conda_build.utils import rm_rf, _check_call, on_win, codec
from conda_build.utils import rm_rf, _check_call, on_win, codec, move_to_trash
from conda_build.index import update_index
from conda_build.create_test import (create_files, create_shell_files,
create_py_files, create_pl_files)
Expand Down Expand Up @@ -394,11 +394,11 @@ def create_env(prefix, specs, clear_cache=True, debug=False):
cc.pkgs_dirs = cc.pkgs_dirs[:1]
actions = plan.install_actions(prefix, index, specs)
plan.display_actions(actions, index)
plan.execute_actions(actions, index, verbose=debug)

if on_win:
os.environ = {k.encode(codec) if hasattr(k, 'encode') else k:
v.encode(codec) if hasattr(v, 'encode') else v
for k, v in os.environ.items()}
for k, v in os.environ.items():
os.environ[k] = str(v)
plan.execute_actions(actions, index, verbose=debug)

os.environ['PATH'] = old_path

Expand Down Expand Up @@ -823,7 +823,7 @@ def test(m, move_broken=True, activate=True, debug=False):
tf.write("{shell_path} -x -e {test_file}\n".format(shell_path=shell_path,
test_file=test_file))
if on_win:
cmd = [env["COMSPEC"], "/d", "/c", test_script]
cmd = ['cmd.exe', "/d", "/c", test_script]
else:
cmd = [shell_path, '-x', '-e', test_script]
try:
Expand Down
2 changes: 1 addition & 1 deletion conda_build/conda_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
text_type) # NOQA
from conda.connection import CondaSession # NOQA
from conda.fetch import TmpDownload, download, fetch_index, handle_proxy_407 # NOQA
from conda.install import (delete_trash, is_linked, linked, linked_data, move_to_trash, # NOQA
from conda.install import (delete_trash, is_linked, linked, linked_data, move_path_to_trash, # NOQA
prefix_placeholder, rm_rf, symlink_conda) # NOQA
from conda.lock import Locked # NOQA
from conda.misc import untracked, walk_prefix # NOQA
Expand Down
5 changes: 2 additions & 3 deletions conda_build/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import yaml

from .conda_interface import PY3
from .conda_interface import move_to_trash, rm_rf
from .conda_interface import Locked

from conda_build import exceptions, utils
Expand Down Expand Up @@ -129,9 +128,9 @@ def render_recipe(recipe_path, no_download_source, verbose, dirty=False):
if not dirty:
if sys.platform == 'win32':
if isdir(source.WORK_DIR):
move_to_trash(source.WORK_DIR, '')
utils.move_to_trash(source.WORK_DIR, '')
else:
rm_rf(source.WORK_DIR)
utils.rm_rf(source.WORK_DIR)

assert not isdir(source.WORK_DIR), ("Failed to clean work directory. Please close open"
" programs/terminals/folders and try again.")
Expand Down
7 changes: 7 additions & 0 deletions conda_build/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fnmatch
from locale import getpreferredencoding
import logging
import os
import sys
import shutil
Expand All @@ -23,6 +24,7 @@

codec = getpreferredencoding() or 'utf-8'
on_win = sys.platform == "win32"
log = logging.getLogger(__file__)


def find_recipe(path):
Expand Down Expand Up @@ -257,3 +259,8 @@ def get_site_packages(prefix):
else:
sp = os.path.join(prefix, 'lib', 'python%s' % sys.version[:3], 'site-packages')
return sp


def move_to_trash(path, placeholder=""):
from .conda_interface import move_path_to_trash as trash
return trash(path)
4 changes: 2 additions & 2 deletions conda_build/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def build_vcvarsall_vs_path(version):

flatversion = str(version).replace('.', '')
vstools = "VS{0}COMNTOOLS".format(flatversion)

if vstools in os.environ:
return os.path.join(os.environ[vstools], '..\\..\\VC\\vcvarsall.bat')
else:
Expand Down Expand Up @@ -223,6 +223,6 @@ def build(m, bld_bat, dirty=False, activate=True):
fo.write("REM ===== end generated header =====\n")
fo.write(data)

cmd = [os.environ['COMSPEC'], '/c', 'bld.bat']
cmd = ['cmd.exe', '/c', 'bld.bat']
_check_call(cmd, cwd=src_dir)
fix_staged_scripts()

0 comments on commit 7305e97

Please sign in to comment.