diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 76fdf13..de3142a 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -56,6 +56,7 @@ jobs: run: bmake -C build test build_and_test_python: + needs: build_and_test strategy: matrix: python-version: ['3.10', '3.11', '3.12'] @@ -83,10 +84,10 @@ jobs: pip install -r python/requirements.txt - name: build - run: CC=${COMPILER} ${PYTHON_CMD} python/setup.py build + run: CC=${COMPILER} ${PYTHON_CMD} setup.py build sdist - name: install - run: pip install python/ + run: pip install dist/[Gg]722*.gz - name: test run: ./scripts/do-test.sh "${PYTHON_CMD} test.py" diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..da83cfb --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include g722.h g722_codec.h g722_common.h g722_decoder.h g722_encoder.h g722_private.h +include python/requirements.txt python/symbols.map diff --git a/python/G722_mod.c b/python/G722_mod.c index c95e4ee..10f969e 100644 --- a/python/G722_mod.c +++ b/python/G722_mod.c @@ -147,7 +147,9 @@ PyG722_encode(PyG722* self, PyObject* args) { free(array); } e1: - Py_DECREF(seq); + if (!PyArray_Check(item)) { + Py_DECREF(seq); + } e0: return rval; } @@ -177,7 +179,7 @@ PyG722_decode(PyG722* self, PyObject* args) { PyObject* item; uint8_t* buffer; int16_t* array; - Py_ssize_t length, olength, i; + Py_ssize_t length, olength; // Parse the input tuple to get a bytes object if (!PyArg_ParseTuple(args, "O", &item)) { @@ -222,8 +224,6 @@ PyG722_decode(PyG722* self, PyObject* args) { return numpy_array; e1: Py_DECREF(owner); -e0: - free(array); return NULL; } diff --git a/python/setup.py b/setup.py similarity index 63% rename from python/setup.py rename to setup.py index 468ea9c..407145a 100644 --- a/python/setup.py +++ b/setup.py @@ -30,26 +30,28 @@ module1 = Extension(mod_name, **mod_common_args) module2 = Extension(mod_name_dbg, **mod_debug_args) -class PyTest(TestCommand): - user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = [] - - def run_tests(self): - import pytest - errno = pytest.main(self.pytest_args) - exit(errno) - requirements = [x.strip() for x in open(mod_dir + "requirements.txt", "r").readlines()] +with open(src_dir + "README.md", "r") as fh: + long_description = fh.read() + +kwargs = { + 'name':mod_name, + 'version':'1.1', + 'description':'This is a package for G.722 module', + 'long_description': long_description, + 'long_description_content_type': "text/markdown", + 'author':'Maksym Sobolyev', + 'author_email':'sobomax@sippysoft.com', + 'url':'https://github.com/sippy/libg722', + 'ext_modules': [module1, module2], + 'python_requires': '>=3.10', + 'install_requires': requirements, + 'classifiers': [ + 'License :: OSI Approved :: BSD License', + 'Operating System :: POSIX', + 'Programming Language :: C', + 'Programming Language :: Python' + ] +} -setup (name = mod_name, - version = '1.0', - description = 'This is a package for G.722 module', - ext_modules = [module1, module2], - tests_require=['pytest'], - cmdclass={'test': PyTest}, - install_requires = requirements, -) - +setup (**kwargs)