|
@@ -1,8 +1,11 @@
|
|
import shutil
|
|
import shutil
|
|
import os
|
|
import os
|
|
import subprocess
|
|
import subprocess
|
|
|
|
+import sys
|
|
from modulefinder import ModuleFinder
|
|
from modulefinder import ModuleFinder
|
|
|
|
|
|
|
|
+import borg
|
|
|
|
+
|
|
# Creates standalone Windows executable
|
|
# Creates standalone Windows executable
|
|
# First build by following instructions from installation.rst
|
|
# First build by following instructions from installation.rst
|
|
|
|
|
|
@@ -42,20 +45,15 @@ int wmain(int argc , wchar_t *argv[] )
|
|
|
|
|
|
PySys_SetArgv(argc, argv);
|
|
PySys_SetArgv(argc, argv);
|
|
|
|
|
|
- wchar_t path[MAX_PATH];
|
|
|
|
- GetModuleFileNameW(NULL, path, MAX_PATH);
|
|
|
|
- PathRemoveFileSpecW(path);
|
|
|
|
-
|
|
|
|
- FILE* file_1 = _wfopen(wcsncat(path, L"/borg/__main__.py", 17), L"r");
|
|
|
|
- PyRun_AnyFile(file_1, "borg/__main__.py");
|
|
|
|
|
|
+ PyRun_SimpleString("from runpy import run_module\\n"
|
|
|
|
+ "run_module('borg')");
|
|
|
|
|
|
Py_Finalize();
|
|
Py_Finalize();
|
|
- PyMem_RawFree(program);
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
""")
|
|
""")
|
|
source.close()
|
|
source.close()
|
|
-subprocess.run('gcc wrapper.c -lpython3.5m -lshlwapi -municode -o ' + builddir + '/bin/borg.exe')
|
|
|
|
|
|
+subprocess.check_call('gcc wrapper.c -lpython3.5m -lshlwapi -municode -o ' + builddir + '/bin/borg.exe')
|
|
os.remove('wrapper.c')
|
|
os.remove('wrapper.c')
|
|
|
|
|
|
print('Searching modules')
|
|
print('Searching modules')
|
|
@@ -65,7 +63,7 @@ modulepath = os.path.abspath(os.path.join(gccpath, '../lib/python3.5/'))
|
|
shutil.copytree(os.path.join(modulepath, 'encodings'), os.path.join(builddir, 'lib/python3.5/encodings'))
|
|
shutil.copytree(os.path.join(modulepath, 'encodings'), os.path.join(builddir, 'lib/python3.5/encodings'))
|
|
|
|
|
|
finder = ModuleFinder()
|
|
finder = ModuleFinder()
|
|
-finder.run_script('borg/__main__.py')
|
|
|
|
|
|
+finder.run_script(os.path.join(borg.__path__[0], '__main__.py'))
|
|
extramodules = [os.path.join(modulepath, 'site.py')]
|
|
extramodules = [os.path.join(modulepath, 'site.py')]
|
|
|
|
|
|
for module in extramodules:
|
|
for module in extramodules:
|
|
@@ -98,9 +96,10 @@ for name, mod in items:
|
|
continue
|
|
continue
|
|
lib = file.find('lib')
|
|
lib = file.find('lib')
|
|
if lib == -1:
|
|
if lib == -1:
|
|
- relpath = os.path.relpath(file)
|
|
|
|
- os.makedirs(os.path.join(builddir, 'bin', os.path.split(relpath)[0]), exist_ok=True)
|
|
|
|
- shutil.copyfile(file, os.path.join(builddir, 'bin', relpath))
|
|
|
|
|
|
+ # Part of the borg package
|
|
|
|
+ relpath = os.path.relpath(file)[4:]
|
|
|
|
+ os.makedirs(os.path.join(builddir, 'lib', 'python3.5', os.path.split(relpath)[0]), exist_ok=True)
|
|
|
|
+ shutil.copyfile(file, os.path.join(builddir, 'lib', 'python3.5', relpath))
|
|
continue
|
|
continue
|
|
relativepath = file[file.find('lib')+4:]
|
|
relativepath = file[file.find('lib')+4:]
|
|
os.makedirs(os.path.join(builddir, 'lib', os.path.split(relativepath)[0]), exist_ok=True)
|
|
os.makedirs(os.path.join(builddir, 'lib', os.path.split(relativepath)[0]), exist_ok=True)
|
|
@@ -112,9 +111,10 @@ for name, mod in items:
|
|
for dll in finddlls(os.path.join(builddir, "bin/borg.exe")):
|
|
for dll in finddlls(os.path.join(builddir, "bin/borg.exe")):
|
|
if builddir not in dll:
|
|
if builddir not in dll:
|
|
shutil.copyfile(dll, os.path.join(builddir, 'bin', os.path.split(dll)[1]))
|
|
shutil.copyfile(dll, os.path.join(builddir, 'bin', os.path.split(dll)[1]))
|
|
-shutil.copyfile('borg/__main__.py', os.path.join(builddir, 'bin/borg/__main__.py'))
|
|
|
|
|
|
|
|
-for extmodule in ['borg/chunker-cpython-35m.dll', 'borg/compress-cpython-35m.dll', 'borg/crypto-cpython-35m.dll', 'borg/hashindex-cpython-35m.dll']:
|
|
|
|
|
|
+shutil.copyfile('src/borg/__main__.py', os.path.join(builddir, 'lib/python3.5/borg/__main__.py'))
|
|
|
|
+
|
|
|
|
+for extmodule in ['src/borg/chunker-cpython-35m.dll', 'src/borg/compress-cpython-35m.dll', 'src/borg/crypto-cpython-35m.dll', 'src/borg/hashindex-cpython-35m.dll']:
|
|
for dll in finddlls(extmodule):
|
|
for dll in finddlls(extmodule):
|
|
if builddir not in dll:
|
|
if builddir not in dll:
|
|
shutil.copyfile(dll, os.path.join(builddir, 'bin', os.path.split(dll)[1]))
|
|
shutil.copyfile(dll, os.path.join(builddir, 'bin', os.path.split(dll)[1]))
|