Skip to content

Commit 3b5d07c

Browse files
committed
Fixed long paths on python 2. Version bump.
1 parent e57e46a commit 3b5d07c

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

files/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.3.4b
1+
v0.4.1b

utils.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ def path_join(base, *rest):
3333

3434
rpath = u'/'.join(new_rest)
3535

36-
if os.path.isabs(rpath):
37-
return rpath
38-
else:
39-
return base + u'/' + rpath
36+
if not os.path.isabs(rpath):
37+
rpath = base + u'/' + rpath
38+
39+
if is_windows():
40+
rpath = rpath.replace(u'/', u'\\')
41+
return rpath
4042

4143
def get_data_path(dir_path):
4244
parts = dir_path.split('/')
@@ -59,34 +61,33 @@ def get_data_file_path(file_path):
5961
def rmtree(path, **kwargs):
6062
if is_windows():
6163
if os.path.isabs(path):
62-
path = u'//?/'+path
64+
path = u'\\\\?\\'+path.replace(u'/', u'\\')
6365
shutil.rmtree(path, **kwargs)
6466

6567
def copy(src, dest, **kwargs):
6668
if is_windows():
6769
if os.path.isabs(src):
68-
src = u'//?/'+src
70+
src = u'\\\\?\\'+src.replace(u'/', u'\\')
6971
if os.path.isabs(dest):
70-
dest = u'//?/'+dest
72+
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
7173
shutil.copy(src, dest, **kwargs)
7274

7375
def move(src, dest, **kwargs):
7476
if is_windows():
7577
if os.path.isabs(src):
76-
src = u'//?/'+src
78+
src = u'\\\\?\\'+src.replace(u'/', u'\\')
7779
if os.path.isabs(dest):
78-
dest = u'//?/'+dest
80+
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
7981
shutil.move(src, dest, **kwargs)
8082

8183
def copytree(src, dest, **kwargs):
8284
if is_windows():
8385
if os.path.isabs(src):
84-
src = u'//?/'+src
86+
src = u'\\\\?\\'+src.replace(u'/', u'\\')
8587
if os.path.isabs(dest):
86-
dest = u'//?/'+dest
88+
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
8789
shutil.copytree(src, dest, **kwargs)
8890

89-
9091
def log(*args):
9192
if DEBUG:
9293
print(*args)
@@ -109,6 +110,8 @@ def zip_files(zip_file_name, *args, **kwargs):
109110
old_path = os.getcwd()
110111

111112
for arg in args:
113+
if is_windows():
114+
arg = u'\\\\?\\'+os.path.abspath(arg).replace(u'/', u'\\')
112115
if os.path.exists(arg):
113116
if os.path.isdir(arg):
114117
directory = os.path.abspath(arg)

0 commit comments

Comments
 (0)