1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 06:37: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.

This commit is contained in:
Virgil Dupras
2010-08-17 09:30:25 +02:00
parent 8d56f4c33b
commit e2f240ebc9
7 changed files with 64 additions and 114 deletions

View File

@@ -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'))

View File

@@ -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;
}

View File

@@ -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"])]
)