diff --git a/python/pyproject.toml b/python/pyproject.toml index 8ed59a6a4..a8ce8e8f9 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -54,7 +54,67 @@ before-all = [ """, ] +before-build = [ + """cmake \ + -S . \ + -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DBUILD_TESTING=OFF \ + -DBUILD_PYTHON=OFF \ + """, + """cmake \ + --build build \ + --parallel \ + --target install \ + --config Release \ + """, +] + +test-requires = "pytest" + +# Cibuildwheel doesn't run tests from the project directory. This is to ensure +# the wheel is imported by the tests, and not the source copy. Normally, one +# would run pytest using the cibw project variable like so: 'pytest +# {project}/tests'. This doesn't work for us however, because our tests use +# relative paths to our test data folder python/data. The workaround is to copy +# out the tests/ and data/ directories to the current folder. This has to be +# done in 'test-command' and not in 'before-test' because there is no guarantee +# they are run from the same directory. +test-command = [ + """python {project}/.github/utils.py copy --src {package}/tests --dst testdir/tests""", + """python {project}/.github/utils.py copy --src {package}/data --dst testdir/data""", + """cd testdir""", + """pytest tests""", + """python {project}/.github/utils.py remove --paths tests data""", +] + +[tool.cibuildwheel.linux] +manylinux-x86_64-image = "manylinux2014" + +[[tool.cibuildwheel.overrides]] +select = "cp3{9,10,11,12}*i686" +before-build= [ + "python -m pip install numpy --config-settings=setup-args=\"-Dallow-noblas=true\" ", + """cmake \ + -S . \ + -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DBUILD_TESTING=OFF \ + -DBUILD_PYTHON=OFF \ + """, + """cmake \ + --build build \ + --parallel \ + --target install \ + --config Release \ + """, +] + [tool.cibuildwheel.macos] +environment = { CXXFLAGS="-L/usr/local/lib" } + before-all = [ """curl \ -L https://github.com/fmtlib/fmt/archive/refs/tags/7.1.3.tar.gz \ @@ -86,7 +146,7 @@ before-all = [ --config Release \ """, """curl \ - -L https://github.com/mpark/variant/archive/refs/tags/v1.4.0.tar.gz \ + -L https://github.com/mpark/variant/archive/refs/tags/v1.4.0.tar.gz \ -o variant-1.4.0.tar.gz \ """, "tar xf variant-1.4.0.tar.gz", @@ -101,24 +161,6 @@ before-all = [ """, ] -before-build = [ - """cmake \ - -S . \ - -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DBUILD_TESTING=OFF \ - -DBUILD_PYTHON=OFF \ - """, - """cmake \ - --build build \ - --parallel \ - --target install \ - --config Release \ - """, -] - -[tool.cibuildwheel.macos] before-build = [ """cmake \ -S . \ @@ -135,47 +177,3 @@ before-build = [ --config Release \ """, ] - -test-requires = "pytest" - -# Cibuildwheel doesn't run tests from the project directory. This is to ensure -# the wheel is imported by the tests, and not the source copy. Normally, one -# would run pytest using the cibw project variable like so: 'pytest -# {project}/tests'. This doesn't work for us however, because our tests use -# relative paths to our test data folder python/data. The workaround is to copy -# out the tests/ and data/ directories to the current folder. This has to be -# done in 'test-command' and not in 'before-test' because there is no guarantee -# they are run from the same directory. -test-command = [ - """python {project}/.github/utils.py copy --src {package}/tests --dst testdir/tests""", - """python {project}/.github/utils.py copy --src {package}/data --dst testdir/data""", - """cd testdir""", - """pytest tests""", - """python {project}/.github/utils.py remove --paths tests data""", -] - -[tool.cibuildwheel.linux] -manylinux-x86_64-image = "manylinux2014" - -[[tool.cibuildwheel.overrides]] -select = "cp3{9,10,11,12}*i686" -before-build= [ - "python -m pip install numpy --config-settings=setup-args=\"-Dallow-noblas=true\" ", - """cmake \ - -S . \ - -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DBUILD_TESTING=OFF \ - -DBUILD_PYTHON=OFF \ - """, - """cmake \ - --build build \ - --parallel \ - --target install \ - --config Release \ - """, -] - -[tool.cibuildwheel.macos] -environment = { CXXFLAGS="-L/usr/local/lib" }