diff --git a/.github/workflows/clang_format_check.yaml b/.github/workflows/clang_format_check.yaml index f7634119..3763e7d7 100644 --- a/.github/workflows/clang_format_check.yaml +++ b/.github/workflows/clang_format_check.yaml @@ -10,6 +10,6 @@ jobs: - name: Fetch repository uses: actions/checkout@v1 - name: Install packages - run: sudo apt-get install python3-venv + run: sudo apt-get update && sudo apt-get install python3-venv - name: check_clang_format run: ci/check_clang_format.sh diff --git a/.github/workflows/coverage_test.yaml b/.github/workflows/coverage_test.yaml index 75bbd363..bbe34454 100644 --- a/.github/workflows/coverage_test.yaml +++ b/.github/workflows/coverage_test.yaml @@ -14,7 +14,7 @@ jobs: - name: Get submodules run: git submodule update --init --force --recursive - name: Install packages - run: sudo apt-get install build-essential libhdf5-dev lcov + run: sudo apt-get update && sudo apt-get install build-essential libhdf5-dev lcov - name: Build and run unittests run: ci/coverage_test.sh - name: Upload Coverage to Coveralls diff --git a/ci/python_test.sh b/ci/python_test.sh index f7f2a8f7..f1daf925 100755 --- a/ci/python_test.sh +++ b/ci/python_test.sh @@ -2,21 +2,20 @@ set -euxo pipefail -VENV=build/venv-python-test +VENV=$(pwd)/build/venv-python-test/ if [[ ! -d "$VENV" ]]; then - # We use virtualenv instead of venv for python2 tests + # We use virtualenv instead of `python3 -mvenv` because of python2 tests pip install virtualenv virtualenv "$VENV" fi -set +u # ignore errors in virtualenv's activate -source "$VENV/bin/activate" -set -u +BIN=$VENV/bin/ -pip install --upgrade pip +$BIN/pip -v install --upgrade pip setuptools wheel # install -pip install . -pip install nose -nosetests python +$BIN/pip -v install --force . +$BIN/pip install nose + +$BIN/nosetests -s -v python/tests diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 450ff063..70bde60c 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -9,7 +9,7 @@ endif() pybind11_add_module(sonata_python SYSTEM bindings.cpp) set_target_properties(sonata_python PROPERTIES - OUTPUT_NAME "libsonata" + OUTPUT_NAME "_libsonata" ) target_link_libraries(sonata_python diff --git a/python/bindings.cpp b/python/bindings.cpp index f2c986a6..18dace4d 100644 --- a/python/bindings.cpp +++ b/python/bindings.cpp @@ -360,7 +360,7 @@ void bindReportReader(py::module& m, const std::string& prefix) { } -PYBIND11_MODULE(libsonata, m) { +PYBIND11_MODULE(_libsonata, m) { py::class_(m, "Selection", "ID sequence in the form convenient for querying attributes") diff --git a/python/libsonata/__init__.py b/python/libsonata/__init__.py new file mode 100644 index 00000000..48550cd3 --- /dev/null +++ b/python/libsonata/__init__.py @@ -0,0 +1,19 @@ +# Needed so that mac wheels properly delocate: +# https://github.com/matthew-brett/delocate/issues/22 + +from libsonata._libsonata import (EdgePopulation, + EdgeStorage, + ElementsDataFrame, + ElementsReportPopulation, + ElementsReportReader, + NodePopulation, + NodeStorage, + Selection, + SomasDataFrame, + SomasReportPopulation, + SomasReportReader, + SonataError, + SpikePopulation, + SpikeReader, + version, + ) diff --git a/python/test.py b/python/tests/test.py similarity index 99% rename from python/test.py rename to python/tests/test.py index 86d7c0dc..66c8ba4e 100644 --- a/python/test.py +++ b/python/tests/test.py @@ -8,7 +8,7 @@ PATH = os.path.dirname(os.path.realpath(__file__)) -PATH = os.path.join(PATH, '../tests/data') +PATH = os.path.join(PATH, '../../tests/data') class TestSelection(unittest.TestCase): diff --git a/setup.py b/setup.py index 96076a20..dfc85736 100644 --- a/setup.py +++ b/setup.py @@ -156,7 +156,7 @@ def run(self): author="BlueBrain Project, EPFL", author_email="bbp-ou-nse@groupes.epfl.ch", classifiers=[], - ext_modules=[CMakeExtension("libsonata")], + ext_modules=[CMakeExtension("libsonata._libsonata")], cmdclass=lazy_dict( build_ext=CMakeBuild, test_ext=CMakeBuild, @@ -166,5 +166,9 @@ def run(self): zip_safe=False, setup_requires=setup_requires, install_requires=install_requires, - use_scm_version=True, + use_scm_version={"local_scheme": "no-local-version", + }, + package_dir={"": "python"}, + packages=['libsonata', + ], )