Minor Windows fixes.

This commit is contained in:
Antti Aalto 2017-10-31 17:20:25 +02:00
parent 401155e909
commit f3543c28fd
3 changed files with 15 additions and 8 deletions

View File

@ -32,7 +32,7 @@ if gccpath == '':
source = open('wrapper.c', 'w')
source.write(
"""
#include <python""" + pythonversion +"""m/python.h>
#include <python""" + pythonversion + """m/python.h>
#include <windows.h>
#include <wchar.h>
#include <string>
@ -104,6 +104,7 @@ def finddlls(exe):
re.append(dll)
return re
items = finder.modules.items()
for name, mod in items:
file = mod.__file__
@ -137,9 +138,9 @@ library.write(os.path.join(modulepath, 'lib-dynload/_sysconfigdata_m_win32_.py')
library.write(os.path.join(modulepath, 'ctypes/wintypes.py'), 'ctypes/wintypes.py')
for extmodule in ['src/borg/chunker-cpython-' + str(sys.version_info[0]) + str(sys.version_info[1]) + 'm.dll',
'src/borg/compress-cpython-' + str(sys.version_info[0]) + str(sys.version_info[1]) + 'm.dll',
'src/borg/item-cpython-' + str(sys.version_info[0]) + str(sys.version_info[1]) + 'm.dll',
'src/borg/hashindex-cpython-' + str(sys.version_info[0]) + str(sys.version_info[1]) + 'm.dll']:
'src/borg/compress-cpython-' + str(sys.version_info[0]) + str(sys.version_info[1]) + 'm.dll',
'src/borg/item-cpython-' + str(sys.version_info[0]) + str(sys.version_info[1]) + 'm.dll',
'src/borg/hashindex-cpython-' + str(sys.version_info[0]) + str(sys.version_info[1]) + 'm.dll']:
for dll in finddlls(extmodule):
if builddir not in dll:
shutil.copyfile(dll, os.path.join(builddir, os.path.split(dll)[1]))

View File

@ -759,6 +759,7 @@ class Clean(clean):
for compiled in sorted(glob(compiled_glob)):
rm(compiled)
cmdclass = {
'build_ext': build_ext,
'build_usage': build_usage,
@ -797,6 +798,7 @@ def parse(root, describe_command=None):
file.write('version = "' + output + '"\n')
return output
parse_function = parse if sys.platform == 'win32' else None
setup(

View File

@ -28,6 +28,7 @@ from ..constants import * # NOQA
if sys.platform == 'win32':
import posixpath
def bin_to_hex(binary):
return hexlify(binary).decode('ascii')
@ -365,7 +366,7 @@ class Location:
""" + optional_archive_re, re.VERBOSE) # archive name (optional, may be empty)
win_file_re = re.compile(r'(?:file://)?(?P<path>(?:[a-zA-Z]:[\\/])?(?:[^:]*))' + optional_archive_re, re.VERBOSE)
def __init__(self, text=''):
self.orig = text
if not self.parse(self.orig):
@ -392,7 +393,10 @@ class Location:
def normpath_special(p):
# avoid that normpath strips away our relative path hack and even makes p absolute
relative = p.startswith('/./')
p = os.path.normpath(p)
if sys.platform != 'win32':
p = os.path.normpath(p)
else:
p = posixpath.normpath(p)
return ('/.' + p) if relative else p
if sys.platform != 'win32':
m = self.ssh_re.match(text)
@ -422,7 +426,7 @@ class Location:
m = self.win_file_re.match(text)
if m:
self.proto = 'file'
self.path = posixpath.normpath(m.group('path'))
self.path = os.path.normpath(m.group('path').replace('/', '\\'))
self.archive = m.group('archive')
return True
m = self.ssh_re.match(text)
@ -434,7 +438,7 @@ class Location:
self.path = normpath_special(m.group('path'))
self.archive = m.group('archive')
return True
return False
def __str__(self):