mirror of
https://github.com/open-mmlab/mim.git
synced 2025-06-03 14:59:11 +08:00
[Fix] Fix the path separator problem of run command on Windows (#177)
This commit is contained in:
parent
6d947416dd
commit
fae573e4ab
@ -110,8 +110,8 @@ def run(
|
||||
|
||||
pkg_root = get_installed_path(package)
|
||||
possible_prefixes = [
|
||||
osp.join(pkg_root, '.mim', 'tools/'),
|
||||
osp.join(pkg_root, 'tools/')
|
||||
osp.join(pkg_root, '.mim', f'tools{os.sep}'),
|
||||
osp.join(pkg_root, f'tools{os.sep}')
|
||||
]
|
||||
for possible_prefix in possible_prefixes:
|
||||
if osp.exists(possible_prefix):
|
||||
@ -121,15 +121,15 @@ def run(
|
||||
command_domain = ''
|
||||
if ':' in command:
|
||||
split_command = command.split(':')
|
||||
command_domain = '/'.join(split_command[:-1])
|
||||
command_domain = os.sep.join(split_command[:-1])
|
||||
command = split_command[-1]
|
||||
|
||||
files = recursively_find(prefix, command + '.py')
|
||||
|
||||
if command_domain == '':
|
||||
suffix = f'/{command}.py'
|
||||
suffix = f'{os.sep}{command}.py'
|
||||
else:
|
||||
suffix = f'/{command_domain}/{command}.py'
|
||||
suffix = f'{os.sep}{command_domain}{os.sep}{command}.py'
|
||||
files = [f for f in files if f.endswith(suffix)]
|
||||
|
||||
if len(files) == 0:
|
||||
@ -142,11 +142,11 @@ def run(
|
||||
echo_warning(f)
|
||||
|
||||
# Use the shortest path
|
||||
files.sort(key=lambda x: len(x.split('/')))
|
||||
files.sort(key=lambda x: len(x.split(os.sep)))
|
||||
echo_warning(f'We are using the script {files[0]}. ')
|
||||
echo_warning('To use other scripts, you need to use these commands: ')
|
||||
for f in files[1:]:
|
||||
cmd = f.split(prefix)[1].split('.')[0].replace('/', ':')
|
||||
cmd = f.split(prefix)[1].split('.')[0].replace(os.sep, ':')
|
||||
echo_warning(f'Command for {f}: {cmd}')
|
||||
|
||||
script = files[0]
|
||||
|
Loading…
x
Reference in New Issue
Block a user