miroir de
https://github.com/arsenetar/dupeguru.git
synchronisé 2025-09-11 17:58:17 +00:00
Prettified the build system by getting rid of those "gen.py" files and hardcoded "python3" calls. Also, ported Qt's block.c to Python3, which hadn't been done yet.
Cette révision appartient à :
Parent
8d56f4c33b
révision
e2f240ebc9
46
build.py
46
build.py
@ -13,6 +13,7 @@ import os.path as op
|
||||
import shutil
|
||||
|
||||
from setuptools import setup
|
||||
from distutils.extension import Extension
|
||||
import yaml
|
||||
|
||||
from hscommon import helpgen
|
||||
@ -65,14 +66,47 @@ def build_cocoa(edition, dev, help_destpath):
|
||||
os.chdir('..')
|
||||
|
||||
def build_qt(edition, dev):
|
||||
print("Building Qt stuff")
|
||||
build_all_qt_ui(op.join('qtlib', 'ui'))
|
||||
build_all_qt_ui(op.join('qt', 'base'))
|
||||
build_all_qt_ui(op.join('qt', edition))
|
||||
print_and_do("pyrcc4 -py3 {0} > {1}".format(op.join('qt', 'base', 'dg.qrc'), op.join('qt', 'base', 'dg_rc.py')))
|
||||
if edition == 'pe':
|
||||
os.chdir(op.join('qt', edition))
|
||||
os.system('python3 gen.py')
|
||||
os.chdir(op.join('..', '..'))
|
||||
|
||||
def build_pe_modules(ui):
|
||||
def move(src, dst):
|
||||
if not op.exists(src):
|
||||
return
|
||||
if op.exists(dst):
|
||||
os.remove(dst)
|
||||
print('Moving %s --> %s' % (src, dst))
|
||||
os.rename(src, dst)
|
||||
|
||||
print("Building PE Modules")
|
||||
exts = [
|
||||
Extension("_block", [op.join('core_pe', 'modules', 'block.c'), op.join('core_pe', 'modules', 'common.c')]),
|
||||
Extension("_cache", [op.join('core_pe', 'modules', 'cache.c'), op.join('core_pe', 'modules', 'common.c')]),
|
||||
]
|
||||
if ui == 'qt':
|
||||
exts.append(Extension("_block_qt", [op.join('qt', 'pe', 'modules', 'block.c')]))
|
||||
elif ui == 'cocoa':
|
||||
exts.append(Extension(
|
||||
"_block_osx", [op.join('core_pe', 'modules', 'block_osx.m'), op.join('core_pe', 'modules', 'common.c')],
|
||||
extra_link_args=[
|
||||
"-framework", "CoreFoundation",
|
||||
"-framework", "Foundation",
|
||||
"-framework", "ApplicationServices",]
|
||||
))
|
||||
setup(
|
||||
script_args = ['build_ext', '--inplace'],
|
||||
ext_modules = exts,
|
||||
)
|
||||
move('_block.so', op.join('core_pe', '_block.so'))
|
||||
move('_block.pyd', op.join('core_pe', '_block.pyd'))
|
||||
move('_block_osx.so', op.join('core_pe', '_block_osx.so'))
|
||||
move('_cache.so', op.join('core_pe', '_cache.so'))
|
||||
move('_cache.pyd', op.join('core_pe', '_cache.pyd'))
|
||||
move('_block_qt.so', op.join('qt', 'pe', '_block.so'))
|
||||
move('_block_qt.pyd', op.join('qt', 'pe', '_block.pyd'))
|
||||
|
||||
def main():
|
||||
conf = yaml.load(open('conf.yaml'))
|
||||
@ -93,9 +127,7 @@ def main():
|
||||
helpgen.gen(help_basepath, help_destpath, profile=profile)
|
||||
print("Building dupeGuru")
|
||||
if edition == 'pe':
|
||||
os.chdir('core_pe')
|
||||
os.system('python3 gen.py')
|
||||
os.chdir('..')
|
||||
build_pe_modules(ui)
|
||||
if ui == 'cocoa':
|
||||
build_cocoa(edition, dev, help_destpath)
|
||||
elif ui == 'qt':
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-05-26
|
||||
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "HS" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
import os
|
||||
import os.path as op
|
||||
|
||||
def move(src, dst):
|
||||
if not op.exists(src):
|
||||
return
|
||||
if op.exists(dst):
|
||||
os.remove(dst)
|
||||
print('Moving %s --> %s' % (src, dst))
|
||||
os.rename(src, dst)
|
||||
|
||||
os.chdir('modules')
|
||||
os.system('python3 setup.py build_ext --inplace')
|
||||
os.chdir('..')
|
||||
move(op.join('modules', '_block.so'), '_block.so')
|
||||
move(op.join('modules', '_block.pyd'), '_block.pyd')
|
||||
move(op.join('modules', '_block_osx.so'), '_block_osx.so')
|
||||
move(op.join('modules', '_cache.so'), '_cache.so')
|
||||
move(op.join('modules', '_cache.pyd'), '_cache.pyd')
|
||||
@ -1,30 +0,0 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-04-23
|
||||
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "HS" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
import sys
|
||||
|
||||
from distutils.core import setup
|
||||
from distutils.extension import Extension
|
||||
|
||||
exts = []
|
||||
|
||||
exts.append(Extension("_block", ["block.c", "common.c"]))
|
||||
exts.append(Extension("_cache", ["cache.c", "common.c"]))
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
exts.append(Extension(
|
||||
"_block_osx", ["block_osx.m", "common.c"],
|
||||
extra_link_args=[
|
||||
"-framework", "CoreFoundation",
|
||||
"-framework", "Foundation",
|
||||
"-framework", "ApplicationServices",
|
||||
]))
|
||||
|
||||
setup(
|
||||
ext_modules = exts,
|
||||
)
|
||||
25
qt/pe/gen.py
25
qt/pe/gen.py
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-05-22
|
||||
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "HS" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
import os
|
||||
import os.path as op
|
||||
|
||||
def move(src, dst):
|
||||
if not op.exists(src):
|
||||
return
|
||||
if op.exists(dst):
|
||||
os.remove(dst)
|
||||
print('Moving %s --> %s' % (src, dst))
|
||||
os.rename(src, dst)
|
||||
|
||||
os.chdir('modules')
|
||||
os.system('python setup.py build_ext --inplace')
|
||||
os.chdir('..')
|
||||
move(op.join('modules', '_block.so'), op.join('.', '_block.so'))
|
||||
move(op.join('modules', '_block.pyd'), op.join('.', '_block.pyd'))
|
||||
@ -40,14 +40,14 @@ getblock(PyObject *image, int width, int height)
|
||||
int i;
|
||||
|
||||
pi = PyObject_CallMethod(image, "bytesPerLine", NULL);
|
||||
bytes_per_line = PyInt_AsSsize_t(pi);
|
||||
bytes_per_line = PyLong_AsLong(pi);
|
||||
Py_DECREF(pi);
|
||||
|
||||
sipptr = PyObject_CallMethod(image, "bits", NULL);
|
||||
/* int(sipptr) returns the address of the pointer */
|
||||
pi = PyObject_CallMethod(sipptr, "__int__", NULL);
|
||||
Py_DECREF(sipptr);
|
||||
s = (char *)PyInt_AsSsize_t(pi);
|
||||
s = (char *)PyLong_AsLong(pi);
|
||||
Py_DECREF(pi);
|
||||
/* Qt aligns all its lines on 32bit, which means that if the number of bytes per
|
||||
* line for image is not divisible by 4, there's going to be crap inserted in "s"
|
||||
@ -74,9 +74,9 @@ getblock(PyObject *image, int width, int height)
|
||||
blue /= pixel_count;
|
||||
}
|
||||
|
||||
pred = PyInt_FromSsize_t(red);
|
||||
pgreen = PyInt_FromSsize_t(green);
|
||||
pblue = PyInt_FromSsize_t(blue);
|
||||
pred = PyLong_FromLong(red);
|
||||
pgreen = PyLong_FromLong(green);
|
||||
pblue = PyLong_FromLong(blue);
|
||||
result = PyTuple_Pack(3, pred, pgreen, pblue);
|
||||
Py_DECREF(pred);
|
||||
Py_DECREF(pgreen);
|
||||
@ -107,10 +107,10 @@ block_getblocks(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
pi = PyObject_CallMethod(image, "width", NULL);
|
||||
width = PyInt_AsSsize_t(pi);
|
||||
width = PyLong_AsLong(pi);
|
||||
Py_DECREF(pi);
|
||||
pi = PyObject_CallMethod(image, "height", NULL);
|
||||
height = PyInt_AsSsize_t(pi);
|
||||
height = PyLong_AsLong(pi);
|
||||
Py_DECREF(pi);
|
||||
|
||||
if (!(width && height)) {
|
||||
@ -157,11 +157,24 @@ static PyMethodDef BlockMethods[] = {
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
init_block(void)
|
||||
static struct PyModuleDef BlockDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_block",
|
||||
NULL,
|
||||
-1,
|
||||
BlockMethods,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
PyObject *
|
||||
PyInit__block(void)
|
||||
{
|
||||
PyObject *m = Py_InitModule("_block", BlockMethods);
|
||||
PyObject *m = PyModule_Create(&BlockDef);
|
||||
if (m == NULL) {
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "HS" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/hs_license
|
||||
|
||||
from distutils.core import setup
|
||||
from distutils.extension import Extension
|
||||
|
||||
setup(
|
||||
ext_modules = [Extension("_block", ["block.c"])]
|
||||
)
|
||||
2
run.py
2
run.py
@ -34,7 +34,7 @@ def main():
|
||||
add_to_pythonpath('qt')
|
||||
add_to_pythonpath(op.join('qt', 'base'))
|
||||
os.chdir(op.join('qt', edition))
|
||||
os.system('python3 start.py')
|
||||
os.system('{0} start.py'.format(sys.executable))
|
||||
os.chdir('..')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Chargement…
x
Référencer dans un nouveau ticket
Bloquer un utilisateur