Skip to content

Commit

Permalink
Move setup.py to the top-level and provide MANIFEST.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Apr 22, 2024
1 parent 166aff7 commit 9c54c3c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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"
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions python/G722_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -222,8 +224,6 @@ PyG722_decode(PyG722* self, PyObject* args) {
return numpy_array;
e1:
Py_DECREF(owner);
e0:
free(array);
return NULL;
}

Expand Down
44 changes: 23 additions & 21 deletions python/setup.py → setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':'[email protected]',
'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)

0 comments on commit 9c54c3c

Please sign in to comment.