Skip to content

Commit

Permalink
win_path_ok
Browse files Browse the repository at this point in the history
  • Loading branch information
kalefranz committed Nov 11, 2016
1 parent c172833 commit fa489e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions conda/common/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ def get_python_path(prefix):

def get_bin_directory_short_path():
return 'Scripts' if on_win else 'bin'


def win_path_ok(path):
return path.replace('/', '\\') if on_win else path
19 changes: 10 additions & 9 deletions conda/core/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from .package_cache import is_extracted, read_url
from ..base.constants import LinkType
from ..base.context import context
from ..common.path import explode_directories, get_leaf_directories, get_bin_directory_short_path
from ..common.path import explode_directories, get_leaf_directories, get_bin_directory_short_path, \
win_path_ok
from ..core.linked_data import (delete_linked_data, get_python_version_for_prefix, load_meta,
set_linked_data)
from ..exceptions import CondaOSError, LinkError, PaddingError
Expand Down Expand Up @@ -117,13 +118,13 @@ def _execute_link_operations(self, leaf_directories, link_operations):

# Step 1. Make all directories
for leaf_directory in leaf_directories:
mkdir_p(join(self.prefix, leaf_directory))
mkdir_p(join(self.prefix, win_path_ok(leaf_directory)))

# Step 2. Do the actual file linking
for op in link_operations:
try:
create_link(join(self.extracted_package_dir, op.source_short_path),
join(self.prefix, op.dest_short_path),
create_link(join(self.extracted_package_dir, win_path_ok(op.source_short_path)),
join(self.prefix, win_path_ok(op.dest_short_path)),
op.link_type)
dest_short_paths.append(op.dest_short_path)
except OSError as e:
Expand All @@ -135,13 +136,13 @@ def _execute_link_operations(self, leaf_directories, link_operations):
for op in link_operations:
if op.prefix_placeholder:
try:
update_prefix(join(self.prefix, op.dest_short_path), self.prefix,
update_prefix(join(self.prefix, win_path_ok(op.dest_short_path)), self.prefix,
op.prefix_placeholder, op.file_mode)
except _PaddingError:
raise PaddingError(op.dest_path, op.prefix_placeholder,
len(op.prefix_placeholder))
if on_win and op.is_menu_file and context.shortcuts:
make_menu(self.prefix, op.dest_short_path, remove=False)
make_menu(self.prefix, win_path_ok(op.dest_short_path), remove=False)

if on_win:
# make sure that the child environment behaves like the parent,
Expand Down Expand Up @@ -257,17 +258,17 @@ def unlink(self):

for f in meta['files']:
dirs_with_removals.add(dirname(f))
rm_rf(join(self.prefix, f))
rm_rf(join(self.prefix, win_path_ok(f)))

if on_win and bool(MENU_RE.match(f)):
# Always try to run this - it should not throw errors where menus do not exist
make_menu(self.prefix, f, remove=False)
make_menu(self.prefix, win_path_ok(f), remove=False)

# remove the meta-file last
delete_linked_data(self.prefix, self.dist, delete=True)

dirs_with_removals.add('conda-meta') # in case there is nothing left
directory_removal_candidates = (join(self.prefix, d) for d in
directory_removal_candidates = (join(self.prefix, win_path_ok(d)) for d in
sorted(explode_directories(dirs_with_removals),
reverse=True))

Expand Down
7 changes: 4 additions & 3 deletions conda/gateways/disk/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ...base.constants import LinkType, UTF8
from ...base.context import context
from ...common.path import (get_python_path, missing_pyc_files, parse_entry_point_def,
get_bin_directory_short_path)
get_bin_directory_short_path, win_path_ok)
from ...exceptions import ClobberError, CondaOSError
from ...gateways.disk.delete import backoff_unlink, rm_rf
from ...models.dist import Dist
Expand Down Expand Up @@ -50,7 +50,8 @@ def create_entry_point(entry_point_def, prefix):
fo.write(pyscript)

# link cli-XX.exe
link(join(PACKAGE_ROOT, 'resources', 'cli-%d.exe' % context.bits), ep_path + '.exe')
link(join(PACKAGE_ROOT, 'resources', 'cli-%d.exe' % context.bits),
join(prefix, win_path_ok(ep_path + '.exe')))
return [ep_path + '-script.py', ep_path + '.exe']
else:
# create py file
Expand Down Expand Up @@ -143,7 +144,7 @@ def make_menu(prefix, file_path, remove=False):

import menuinst
try:
menuinst.install(join(prefix, file_path), remove, prefix)
menuinst.install(join(prefix, win_path_ok(file_path)), remove, prefix)
except:
stdoutlog.error("menuinst Exception:")
stdoutlog.error(traceback.format_exc())
Expand Down

0 comments on commit fa489e6

Please sign in to comment.