diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index ec19cdb4..37cb8436 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -21,19 +21,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - submodules: recursive - name: Set up Python uses: actions/setup-python@v4 with: python-version: ">=3.11.0" - - name: Verify QuadBLAS submodule - run: | - ls -la quaddtype/numpy_quaddtype/QBLAS/ - ls -la quaddtype/numpy_quaddtype/QBLAS/include/quadblas/ - - name: Install cibuildwheel run: pip install cibuildwheel==3.1.4 @@ -46,21 +39,8 @@ jobs: CIBW_BEFORE_ALL: | yum update -y yum install -y cmake gcc gcc-c++ make git pkgconfig - # Install SLEEF in container - git clone --branch 3.8 https://github.com/shibatch/sleef.git - cd sleef - cmake -S . -B build \ - -DSLEEF_BUILD_QUAD:BOOL=ON \ - -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - cmake --build build/ --clean-first -j - cmake --install build --prefix /usr/local CIBW_ENVIRONMENT: > - CFLAGS="-I/usr/local/include -I{project}/numpy_quaddtype/QBLAS/include $CFLAGS" - CXXFLAGS="-I/usr/local/include -I{project}/numpy_quaddtype/QBLAS/include -fext-numeric-literals $CXXFLAGS" - LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp $LDFLAGS" - LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH" - PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" + LDFLAGS="-fopenmp" CIBW_REPAIR_WHEEL_COMMAND: | auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} CIBW_TEST_COMMAND: | @@ -89,8 +69,6 @@ jobs: steps: - uses: actions/checkout@v3 - with: - submodules: recursive - name: Set up Python uses: actions/setup-python@v4 @@ -107,27 +85,6 @@ jobs: brew cleanup brew install $packages - - name: Install SLEEF - env: - MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-13' && '13.0' || '14.0' }} - run: | - git clone --branch 3.8 https://github.com/shibatch/sleef.git - cd sleef - cmake -S . -B build \ - -DSLEEF_BUILD_QUAD:BOOL=ON \ - -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=${{ matrix.os == 'macos-13' && '13.0' || '14.0' }} \ - -DCMAKE_INSTALL_RPATH="@loader_path/../lib" \ - -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON - cmake --build build/ --clean-first -j - sudo cmake --install build --prefix /usr/local - - - name: Verify QuadBLAS submodule - run: | - ls -la quaddtype/numpy_quaddtype/QBLAS/ - ls -la quaddtype/numpy_quaddtype/QBLAS/include/quadblas/ - - name: Installing Python dependencies run: | pip install -U pip @@ -142,11 +99,6 @@ jobs: CIBW_BUILD_VERBOSITY: "3" CIBW_ENVIRONMENT: > MACOSX_DEPLOYMENT_TARGET="${{ matrix.os == 'macos-13' && '13.0' || '14.0' }}" - DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH" - CFLAGS="-I/usr/local/include -I{project}/numpy_quaddtype/QBLAS/include $CFLAGS" - CXXFLAGS="-I/usr/local/include -I{project}/numpy_quaddtype/QBLAS/include $CXXFLAGS" - LDFLAGS="-L/usr/local/lib $LDFLAGS" - PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" CIBW_REPAIR_WHEEL_COMMAND: > delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} CIBW_TEST_COMMAND: | @@ -176,8 +128,6 @@ jobs: steps: - uses: actions/checkout@v3 - with: - submodules: recursive - name: Setup MSVC uses: ilammy/msvc-dev-cmd@v1 @@ -193,21 +143,6 @@ jobs: - name: Install CMake uses: lukka/get-cmake@latest - - name: Verify QuadBLAS submodule - shell: pwsh - run: | - Get-ChildItem quaddtype/numpy_quaddtype/QBLAS/ - Get-ChildItem quaddtype/numpy_quaddtype/QBLAS/include/quadblas/ - - - name: Clone and Build SLEEF - shell: pwsh - run: | - git clone --branch 3.8 https://github.com/shibatch/sleef.git - cd sleef - cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture == 'x86' && 'Win32' || 'x64' }} -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON - cmake --build build --config Release - cmake --install build --prefix "C:/sleef" --config Release - - name: Install build dependencies shell: bash -l {0} run: | @@ -226,12 +161,8 @@ jobs: CIBW_BEFORE_BUILD: | pip install meson meson-python ninja numpy CIBW_ENVIRONMENT: > - INCLUDE="C:/sleef/include;{project}/numpy_quaddtype/QBLAS/include;$INCLUDE" - LIB="C:/sleef/lib;$LIB" - PATH="C:/sleef/bin;$PATH" - CFLAGS="/IC:/sleef/include /I{project}/numpy_quaddtype/QBLAS/include /DDISABLE_QUADBLAS $CFLAGS" - CXXFLAGS="/IC:/sleef/include /I{project}/numpy_quaddtype/QBLAS/include /DDISABLE_QUADBLAS $CXXFLAGS" - LDFLAGS="C:/sleef/lib/sleef.lib C:/sleef/lib/sleefquad.lib $LDFLAGS" + CFLAGS="/DDISABLE_QUADBLAS $CFLAGS" + CXXFLAGS="/DDISABLE_QUADBLAS $CXXFLAGS" CIBW_REPAIR_WHEEL_COMMAND: 'delvewheel repair -w {dest_dir} {wheel} --add-path C:\sleef\bin' CIBW_TEST_COMMAND: | pip install {package}[test] @@ -258,49 +189,29 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - submodules: recursive - name: Set up Python uses: actions/setup-python@v4 with: python-version: ">=3.11.0" - - name: Verify QuadBLAS submodule - run: | - ls -la quaddtype/numpy_quaddtype/QBLAS/ - ls -la quaddtype/numpy_quaddtype/QBLAS/include/quadblas/ - - name: Install system dependencies run: | sudo apt-get update -y sudo apt-get install -y cmake gcc g++ make git pkg-config - - name: Install SLEEF - run: | - git clone --branch 3.8 https://github.com/shibatch/sleef.git - cd sleef - cmake -S . -B build \ - -DSLEEF_BUILD_QUAD:BOOL=ON \ - -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - cmake --build build/ --clean-first -j - sudo cmake --install build --prefix /usr/local - - name: Install build dependencies run: | python -m pip install --upgrade pip - python -m pip install build + python -m pip install build pytest - - name: Build SDist + - name: Build SDist & test sdist env: - CFLAGS: "-I/usr/local/include -I$(pwd)/numpy_quaddtype/QBLAS/include" - CXXFLAGS: "-I/usr/local/include -I$(pwd)/numpy_quaddtype/QBLAS/include -fext-numeric-literals" - LDFLAGS: "-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp" - LD_LIBRARY_PATH: "/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH" - PKG_CONFIG_PATH: "/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" + LDFLAGS: "-fopenmp" run: | python -m build --sdist --outdir dist/ + pip install dist/*.tar.gz -v + pytest -s tests working-directory: ./quaddtype - name: Upload SDist artifact diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 542093c5..55c3f2dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,35 +60,11 @@ jobs: sudo apt-get update sudo apt-get install -y libmpfr-dev libssl-dev libfftw3-dev - - name: Install SLEEF - run: | - sudo apt-get update -y - sudo apt-get install -y cmake gcc g++ make git pkg-config - git clone --branch 3.8 https://github.com/shibatch/sleef.git - cd sleef - cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON - cmake --build build/ --clean-first -j - sudo cmake --install build --prefix /usr/local - - name: Install quaddtype working-directory: quaddtype run: | - # Initialize submodules first - git submodule update --init --recursive - ls -la numpy_quaddtype/QBLAS/ - - # Set environment variables with proper export and correct paths - export CFLAGS="-I/usr/local/include -I$(pwd)/numpy_quaddtype/QBLAS/include" - export CXXFLAGS="-I/usr/local/include -I$(pwd)/numpy_quaddtype/QBLAS/include -fext-numeric-literals" - export LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp" - export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH" - - # Install with meson args to ensure the C++ flags are passed through - python -m pip install . -v --no-build-isolation \ - -Cbuilddir=build \ - -C'compile-args=-v' \ - -Csetup-args="-Dbuildtype=debug" \ - -Csetup-args="-Dcpp_args=-fext-numeric-literals" + export LDFLAGS="-fopenmp" + python -m pip install . -v - name: Run quaddtype tests working-directory: quaddtype diff --git a/.gitignore b/.gitignore index dc6d7cc2..e004ae30 100644 --- a/.gitignore +++ b/.gitignore @@ -137,3 +137,8 @@ compile_commands.json *.whl .DS_Store .idea/ + +# quaddtype +/quaddtype/subprojects/qblas/ +/quaddtype/subprojects/sleef/ +.wraplock diff --git a/.gitmodules b/.gitmodules index 523c79c8..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "quaddtype/numpy_quaddtype/QBLAS"] - path = quaddtype/numpy_quaddtype/QBLAS - url = https://github.com/SwayamInSync/QBLAS diff --git a/quaddtype/LICENSE b/quaddtype/LICENSE new file mode 100644 index 00000000..6d6c9a5c --- /dev/null +++ b/quaddtype/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2022, NumPy Developers. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the NumPy Developers nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/quaddtype/README.md b/quaddtype/README.md index 35740398..86eae750 100644 --- a/quaddtype/README.md +++ b/quaddtype/README.md @@ -25,45 +25,30 @@ np.array([1,2,3], dtype=QuadPrecDType("longdouble")) ## Installation from source -The code needs the quad precision pieces of the sleef library, which is not available on most systems by default, so we have to generate that first. Choose the appropriate section below based on your operating system. - -### Linux/Unix/macOS +#### Prerequisites -The below assumes one has the required pieces to build sleef (cmake and libmpfr-dev), and that one is in the package directory locally. +- **gcc/clang** +- **CMake** (≥3.15) +- **Python 3.10+** +- **Git** -```bash -git clone --branch 3.8 https://github.com/shibatch/sleef.git -cd sleef -cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -cmake --build build/ --clean-first -j -cd .. -``` +### Linux/Unix/macOS -Building the `numpy-quaddtype` package from locally installed sleef: +Building the `numpy-quaddtype` package: ```bash -export SLEEF_DIR=$PWD/sleef/build -export LIBRARY_PATH=$SLEEF_DIR/lib -export C_INCLUDE_PATH=$SLEEF_DIR/include -export CPLUS_INCLUDE_PATH=$SLEEF_DIR/include - # setup the virtual env python3 -m venv temp source temp/bin/activate # Install the package -pip install meson-python numpy pytest - -# If you see errors about a missing atomics library, you might need -latomic -export LDFLAGS="-Wl,-rpath,$SLEEF_DIR/lib -fopenmp -lpthread" -export CFLAGS="-fPIC" -export CXXFLAGS="-fPIC" +pip install numpy pytest # To build without QBLAS (default for MSVC) -# export CFLAGS="-fPIC -DDISABLE_QUADBLAS" -# export CXXFLAGS="-fPIC -DDISABLE_QUADBLAS" +# export CFLAGS="-DDISABLE_QUADBLAS" +# export CXXFLAGS="-DDISABLE_QUADBLAS" -python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' +python -m pip install . -v # Run the tests cd .. @@ -76,7 +61,7 @@ python -m pytest - **Visual Studio 2017 or later** (with MSVC compiler) - **CMake** (≥3.15) -- **Python 3.10+** +- **Python 3.10+** - **Git** #### Step-by-Step Installation @@ -85,24 +70,7 @@ python -m pytest Open a **Developer Command Prompt for VS** or **Developer PowerShell for VS** to ensure MSVC is properly configured. -2. **Clone and Build SLEEF** - - ```powershell - # Clone SLEEF library - git clone --branch 3.8 https://github.com/shibatch/sleef.git - cd sleef - - # Configure with CMake for Windows - cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON - - # Build and install SLEEF - cmake --build build --config Release - cmake --install build --prefix "C:/sleef" --config Release - - cd .. - ``` - -3. **Setup Python Environment** +2. **Setup Python Environment** ```powershell # Create and activate virtual environment @@ -111,49 +79,36 @@ python -m pytest # Install build dependencies pip install -U pip - pip install meson-python numpy pytest ninja meson + pip install numpy pytest ninja meson ``` -4. **Set Environment Variables** +3. **Set Environment Variables** ```powershell - # Set up paths and compiler flags - $env:INCLUDE = "C:/sleef/include;$env:INCLUDE" - $env:LIB = "C:/sleef/lib;$env:LIB" - $env:PATH = "C:/sleef/bin;$env:PATH" - # Note: QBLAS is disabled on Windows due to MSVC compatibility issues - $env:CFLAGS = "/IC:/sleef/include /DDISABLE_QUADBLAS" - $env:CXXFLAGS = "/IC:/sleef/include /DDISABLE_QUADBLAS" - $env:LDFLAGS = "C:/sleef/lib/sleef.lib C:/sleef/lib/sleefquad.lib" + $env:CFLAGS = "/DDISABLE_QUADBLAS" + $env:CXXFLAGS = "/DDISABLE_QUADBLAS" ``` -5. **Build and Install numpy-quaddtype** +4. **Build and Install numpy-quaddtype** ```powershell - # Ensure submodules are initialized - git submodule update --init --recursive - # Build and install the package - python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' + python -m pip install . -v ``` -6. **Test Installation** +5. **Test Installation** ```powershell # Run tests pytest -s tests/ ``` -1. **QBLAS Disabled**: QuadBLAS optimization is automatically disabled on Windows builds due to MSVC compatibility issues. This is handled by the `-DDISABLE_QUADBLAS` compiler flag. +6. **QBLAS Disabled**: QuadBLAS optimization is automatically disabled on Windows builds due to MSVC compatibility issues. This is handled by the `-DDISABLE_QUADBLAS` compiler flag. + +7. **Visual Studio Version**: The instructions assume Visual Studio 2022. For other versions, adjust the generator string: -2. **Visual Studio Version**: The instructions assume Visual Studio 2022. For other versions, adjust the generator string: - VS 2019: `"Visual Studio 16 2019"` - VS 2017: `"Visual Studio 15 2017"` -3. **Architecture**: The instructions are for x64. For x86 builds, change `-A x64` to `-A Win32`. - -4. **Alternative SLEEF Location**: If you prefer to install SLEEF elsewhere, update all path references accordingly. - -#### Windows Troubleshooting -- **Link errors**: Verify that `sleef.lib` and `sleefquad.lib` exist in `C:/sleef/lib/` \ No newline at end of file +8. **Architecture**: The instructions are for x64. For x86 builds, change `-A x64` to `-A Win32`. diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 735db3fc..69e4edf7 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -13,23 +13,32 @@ if is_windows add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp']) endif -sleef_dep = [ - c.find_library('sleef', required : true), - c.find_library('sleefquad', required : true) -] +sleef_subproj = subproject('sleef', required: true) +sleef_dep = sleef_subproj.get_variable('sleef_dep') +sleefquad_dep = sleef_subproj.get_variable('sleefquad_dep') incdir_numpy = run_command(py, ['-c', 'import numpy; print(numpy.get_include())'], check : true ).stdout().strip() -# Add OpenMP dependency (optional, for threading) +# OpenMP dependency (optional, for threading) openmp_dep = dependency('openmp', required: false) -dependencies = [sleef_dep, py_dep] +qblas_dep = dependency('qblas', fallback: ['qblas', 'qblas_dep']) +dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep] if openmp_dep.found() dependencies += openmp_dep endif +# compiler flags for QBLAS compatibility +if not is_windows + # QBLAS requires extended numeric literals for Q suffix support + # if compiler supports (usually gcc) + if cpp.has_argument('-fext-numeric-literals') + add_project_arguments('-fext-numeric-literals', language: 'cpp') + endif +endif + # Thread-local storage detection (borrowed from NumPy) optional_variable_attributes = [ ['thread_local', 'HAVE_THREAD_LOCAL'], # C23 @@ -66,12 +75,10 @@ configure_file( configuration: cdata ) -build_includes = include_directories('.') - +build_includes = include_directories('.') # compile time generated headers as per system includes = include_directories( [ incdir_numpy, - 'numpy_quaddtype/QBLAS/include', 'numpy_quaddtype/src', ] ) @@ -117,10 +124,9 @@ py.install_sources( py.extension_module('_quaddtype_main', srcs, - link_args: is_windows ? ['/DEFAULTLIB:sleef', '/DEFAULTLIB:sleefquad'] : ['-lsleef', '-lsleefquad'], link_language: 'cpp', dependencies: dependencies, install: true, subdir: 'numpy_quaddtype', - include_directories: [includes, build_includes] + include_directories: [includes, build_includes], ) \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/QBLAS b/quaddtype/numpy_quaddtype/QBLAS deleted file mode 160000 index 9468e24a..00000000 --- a/quaddtype/numpy_quaddtype/QBLAS +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9468e24a02b731563eba2aee0350e9219b36c102 diff --git a/quaddtype/numpy_quaddtype/src/quadblas_interface.cpp b/quaddtype/numpy_quaddtype/src/quadblas_interface.cpp index 65feb604..b51851a3 100644 --- a/quaddtype/numpy_quaddtype/src/quadblas_interface.cpp +++ b/quaddtype/numpy_quaddtype/src/quadblas_interface.cpp @@ -3,7 +3,7 @@ #include #ifndef DISABLE_QUADBLAS -#include "../QBLAS/include/quadblas/quadblas.hpp" +#include "../subprojects/qblas/include/quadblas/quadblas.hpp" #endif // DISABLE_QUADBLAS extern "C" { diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index b46b3737..2353ca64 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -12,6 +12,7 @@ name = "numpy_quaddtype" description = "Quad (128-bit) float dtype for numpy" version = "0.1.0" readme = 'README.md' +license = { file = "LICENSE" } authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.10.0" dependencies = [ diff --git a/quaddtype/reinstall.sh b/quaddtype/reinstall.sh index 1c08f84e..b5e04876 100755 --- a/quaddtype/reinstall.sh +++ b/quaddtype/reinstall.sh @@ -1,21 +1,13 @@ #!/bin/bash -set -xeuo pipefail -IFS=$'\n\t' +set -x -if [ -d "build/" ] -then +if [ -d "build/" ]; then rm -r build + rm -rf dist/ + rm -rf subprojects/qblas + rm -rf subprojects/sleef fi -export CC=clang -export CXX=clang++ -export SLEEF_DIR=$PWD/sleef/build -export LIBRARY_PATH=$SLEEF_DIR/lib -export C_INCLUDE_PATH=$SLEEF_DIR/include -export CPLUS_INCLUDE_PATH=$SLEEF_DIR/include - -# Set RPATH via LDFLAGS -export LDFLAGS="-Wl,-rpath,$SLEEF_DIR/lib" python -m pip uninstall -y numpy_quaddtype -python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' \ No newline at end of file +python -m pip install . -v \ No newline at end of file diff --git a/quaddtype/sdist_test.sh b/quaddtype/sdist_test.sh new file mode 100644 index 00000000..786f05fd --- /dev/null +++ b/quaddtype/sdist_test.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -x + +if [ -d "build/" ]; then + rm -rf dist/ +fi + +python -m pip uninstall -y numpy_quaddtype +python -m build --sdist --outdir dist/ +python -m pip install dist/*.tar.gz -v \ No newline at end of file diff --git a/quaddtype/subprojects/packagefiles/qblas/meson.build b/quaddtype/subprojects/packagefiles/qblas/meson.build new file mode 100644 index 00000000..810ee5d0 --- /dev/null +++ b/quaddtype/subprojects/packagefiles/qblas/meson.build @@ -0,0 +1,8 @@ +project('qblas', version: '1.0.0') + +qblas_inc = include_directories('include') + +qblas_dep = declare_dependency( + include_directories: qblas_inc, + version: meson.project_version() +) diff --git a/quaddtype/subprojects/packagefiles/sleef/meson.build b/quaddtype/subprojects/packagefiles/sleef/meson.build new file mode 100644 index 00000000..20faeff4 --- /dev/null +++ b/quaddtype/subprojects/packagefiles/sleef/meson.build @@ -0,0 +1,64 @@ +project('sleef', version: '3.8') + +cmake = find_program('cmake') +ninja = find_program('ninja', 'make', required: false) + +sleef_build_dir = 'sleef_build' +sleef_install_dir = 'sleef_install' + +# turning off parallel build in windows +parallel_flag = ['--parallel'] +if host_machine.system() == 'windows' + parallel_flag = [] +endif + +sleef_configure = run_command([ + cmake, + '-S', meson.current_source_dir(), + '-B', meson.current_build_dir() / sleef_build_dir, + '-DCMAKE_BUILD_TYPE=Release', + '-DSLEEF_BUILD_QUAD=ON', + '-DSLEEF_BUILD_SHARED_LIBS=OFF', + '-DSLEEF_BUILD_TESTS=OFF', + '-DSLEEF_BUILD_INLINE_HEADERS=OFF', + '-DCMAKE_POSITION_INDEPENDENT_CODE=ON', + '-DCMAKE_INSTALL_PREFIX=' + meson.current_build_dir() / sleef_install_dir +], check: false, capture: true) + +if sleef_configure.returncode() != 0 + error('SLEEF CMake configuration failed: ' + sleef_configure.stderr()) +endif + +sleef_build_target = custom_target('sleef_build', + command: [cmake, '--build', meson.current_build_dir() / sleef_build_dir, '--target', 'install'] + parallel_flag, + output: 'sleef_built.stamp', + console: true, + build_always_stale: true, + build_by_default: true +) + +sleef_include_path = meson.current_build_dir() / sleef_install_dir / 'include' + +sleef_build_dep = declare_dependency(sources: [sleef_build_target]) + +sleef_static_define = '' +if host_machine.system() == 'windows' + sleef_static_define = '-DSLEEF_STATIC_LIBS' +endif + +compile_args_list = ['-I' + sleef_include_path] +if sleef_static_define != '' + compile_args_list += sleef_static_define +endif + +sleef_dep = declare_dependency( + dependencies: [sleef_build_dep], + compile_args: compile_args_list, + link_args: ['-L' + meson.current_build_dir() / sleef_install_dir / 'lib', '-L' + meson.current_build_dir() / sleef_install_dir / 'lib64', '-lsleef'] #both lib and lib64 because of ubuntu vs redhat compatibility +) + +sleefquad_dep = declare_dependency( + dependencies: [sleef_build_dep], + compile_args: compile_args_list, + link_args: ['-L' + meson.current_build_dir() / sleef_install_dir / 'lib', '-L' + meson.current_build_dir() / sleef_install_dir / 'lib64', '-lsleefquad'] +) \ No newline at end of file diff --git a/quaddtype/subprojects/qblas.wrap b/quaddtype/subprojects/qblas.wrap new file mode 100644 index 00000000..7b4710ff --- /dev/null +++ b/quaddtype/subprojects/qblas.wrap @@ -0,0 +1,8 @@ +[wrap-git] +directory=qblas +url=https://github.com/SwayamInSync/QBLAS.git +revision=9468e24a02b731563eba2aee0350e9219b36c102 +patch_directory = qblas + +[provide] +qblas = qblas_dep diff --git a/quaddtype/subprojects/sleef.wrap b/quaddtype/subprojects/sleef.wrap new file mode 100644 index 00000000..8e87d722 --- /dev/null +++ b/quaddtype/subprojects/sleef.wrap @@ -0,0 +1,9 @@ +[wrap-git] +directory=sleef +url=https://github.com/shibatch/sleef.git +revision=3.8 +patch_directory=sleef + +[provide] +sleef = sleef_dep +sleefquad = sleefquad_dep \ No newline at end of file