diff --git a/.github/workflows/conda-package-cf.yml b/.github/workflows/conda-package-cf.yml new file mode 100644 index 0000000..f3dada5 --- /dev/null +++ b/.github/workflows/conda-package-cf.yml @@ -0,0 +1,303 @@ +name: Conda package using conda-forge + +on: + push: + branches: + - master + pull_request: + +permissions: read-all + +env: + PACKAGE_NAME: mkl-service + MODULE_NAME: mkl + TEST_ENV_NAME: test_mkl_service + VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); " + VER_SCRIPT2: "d = j['mkl-service'][0]; print('='.join((d[s] for s in ('version', 'build'))))" + +jobs: + build_linux: + runs-on: ubuntu-latest + + strategy: + matrix: + python: ['3.10', '3.11', '3.12', '3.13', '3.14'] + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0 + with: + access_token: ${{ github.token }} + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + + - name: Set pkgs_dirs + run: | + echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + + - name: Cache conda packages + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + env: + CACHE_NUMBER: 0 # Increase to reset cache + with: + path: ~/.conda/pkgs + key: + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }} + restore-keys: | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + + - name: Add conda to system path + run: echo "$CONDA/bin" >> "$GITHUB_PATH" + + - name: Install conda-build + run: conda install conda-build + + - name: Store conda paths as envs + shell: bash -el {0} + run: | + echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> "$GITHUB_ENV" + echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV" + + - name: Build conda package + run: | + CHANNELS=(-c conda-forge -c conda-forge/label/python_rc --override-channels) + VERSIONS=(--python "${{ matrix.python }}") + TEST=(--no-test) + + conda build \ + "${TEST[@]}" \ + "${VERSIONS[@]}" \ + "${CHANNELS[@]}" \ + conda-recipe-cf + + - name: Upload artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda + + - name: Upload wheels artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }} + path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl + + build_windows: + runs-on: windows-latest + + strategy: + matrix: + python: ['3.10', '3.11', '3.12', '3.13', '3.14'] + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0 + with: + access_token: ${{ github.token }} + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 + with: + miniforge-version: latest + activate-environment: build + channels: conda-forge + python-version: ${{ matrix.python }} + + - name: Cache conda packages + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + env: + CACHE_NUMBER: 3 # Increase to reset cache + with: + path: /home/runner/conda_pkgs_dir + key: + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }} + restore-keys: | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + + - name: Store conda paths as envs + shell: bash -el {0} + run: | + echo "CONDA_BLD=$CONDA\\conda-bld\\win-64\\" >> "$GITHUB_ENV" + echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE\\" >> "$GITHUB_ENV" + + - name: Install conda build + run: | + conda install -n base -y conda-build + conda list -n base + + - name: Build conda package + run: conda build --no-test --python ${{ matrix.python }} -c conda-forge -c conda-forge/label/python_rc --override-channels conda-recipe-cf + + - name: Upload artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda + + - name: Upload wheels artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }} + path: ${{ env.WHEELS_OUTPUT_FOLDER }}mkl_service-*.whl + + test_linux: + needs: build_linux + runs-on: ${{ matrix.runner }} + + strategy: + matrix: + python: ['3.10', '3.11', '3.12', '3.13', '3.14'] + experimental: [false] + runner: [ubuntu-latest] + continue-on-error: ${{ matrix.experimental }} + env: + CHANNELS: -c conda-forge -c conda-forge/label/python_rc --override-channels + + steps: + - name: Download artifact + uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + + - name: Add conda to system path + run: echo "$CONDA/bin" >> "$GITHUB_PATH" + + - name: Install conda-build + run: conda install conda-build + + - name: Create conda channel + run: | + mkdir -p "$GITHUB_WORKSPACE/channel/linux-64" + conda index "$GITHUB_WORKSPACE/channel" || exit 1 + mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1 + conda index "$GITHUB_WORKSPACE/channel" || exit 1 + # Test channel + conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json" + cat ver.json + + - name: Collect dependencies + run: | + . "$CONDA/etc/profile.d/conda.sh" + CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels) + PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")" + export PACKAGE_VERSION + conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" "python=${{ matrix.python }}" "${CHANNELS[@]}" --only-deps --dry-run > lockfile + cat lockfile + + - name: Set pkgs_dirs + run: | + echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + + - name: Cache conda packages + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + env: + CACHE_NUMBER: 0 # Increase to reset cache + with: + path: ~/.conda/pkgs + key: + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} + restore-keys: | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + + - name: Install mkl-service + run: | + . "$CONDA/etc/profile.d/conda.sh" + CHANNELS=(-c "$GITHUB_WORKSPACE/channel" -c conda-forge -c conda-forge/label/python_rc --override-channels) + PACKAGE_VERSION="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")" + export PACKAGE_VERSION + conda create -n "${{ env.TEST_ENV_NAME }}" "$PACKAGE_NAME=$PACKAGE_VERSION" pytest "python=${{ matrix.python }}" "${CHANNELS[@]}" + # Test installed packages + conda list + + - name: Run tests + run: | + . "$CONDA/etc/profile.d/conda.sh" + conda activate ${{ env.TEST_ENV_NAME }} + pytest -vv --pyargs ${{ env.MODULE_NAME }} + + test_windows: + needs: build_windows + runs-on: ${{ matrix.runner }} + + strategy: + matrix: + python: ['3.10', '3.11', '3.12', '3.13', '3.14'] + experimental: [false] + runner: [windows-latest] + continue-on-error: ${{ matrix.experimental }} + env: + CHANNELS: -c conda-forge -c conda-forge/label/python_rc --override-channels + + steps: + - name: Download artifact + uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 + with: + miniforge-version: latest + channels: conda-forge + activate-environment: ${{ env.TEST_ENV_NAME }} + python-version: ${{ matrix.python }} + + - name: Install conda-index + run: conda install conda-index + + - name: Create conda channel + run: | + mkdir ${{ env.GITHUB_WORKSPACE }}/channel/win-64 + move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}/channel/win-64 + python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel + + # Test channel + conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}/ver.json + more ${{ env.GITHUB_WORKSPACE }}/ver.json + + - name: Collect dependencies + shell: cmd + run: | + @ECHO ON + copy /Y ${{ env.GITHUB_WORKSPACE }}\ver.json . + set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%" + FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO ( + SET PACKAGE_VERSION=%%F + ) + conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile + more lockfile + + - name: Cache conda packages + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + env: + CACHE_NUMBER: 3 # Increase to reset cache + with: + path: /home/runner/conda_pkgs_dir + key: + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} + restore-keys: | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + + - name: Install mkl-service + shell: cmd + run: | + @ECHO ON + copy /Y ${{ env.GITHUB_WORKSPACE }}\ver.json . + set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%" + FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO ( + SET PACKAGE_VERSION=%%F + ) + conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% pytest python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} + # Test installed packages + conda list + + - name: Run tests + run: | + conda activate ${{ env.TEST_ENV_NAME }} + pytest -v --pyargs ${{ env.MODULE_NAME }} diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index cc03bfd..2aa5e12 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -104,10 +104,9 @@ jobs: - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 with: miniforge-version: latest - use-mamba: 'true' - conda-remove-defaults: 'true' - activate-environment: 'build' - python-version: '3.13' # no python 3.14 support by conda-build + activate-environment: build + channels: conda-forge + python-version: ${{ matrix.python }} - name: Cache conda packages uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 @@ -121,15 +120,17 @@ jobs: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- - - name: Install conda-build - run: conda install conda-build - - name: Store conda paths as envs shell: bash -el {0} run: | - echo "CONDA_BLD=$CONDA_PREFIX\\conda-bld\\win-64\\" >> "$GITHUB_ENV" + echo "CONDA_BLD=$CONDA\\conda-bld\\win-64\\" >> "$GITHUB_ENV" echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE\\" >> "$GITHUB_ENV" + - name: Install conda build + run: | + conda install -n base -y conda-build + conda list -n base + - name: Build conda package run: conda build --no-test --python ${{ matrix.python }} -c https://software.repos.intel.com/python/conda -c conda-forge -c conda-forge/label/python_rc --override-channels conda-recipe @@ -242,10 +243,9 @@ jobs: - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 with: miniforge-version: latest - use-mamba: 'true' - conda-remove-defaults: 'true' - activate-environment: 'test' - python-version: '3.13' # no python 3.14 support by conda-index + channels: conda-forge + activate-environment: ${{ env.TEST_ENV_NAME }} + python-version: ${{ matrix.python }} - name: Install conda-index run: conda install conda-index @@ -254,7 +254,7 @@ jobs: run: | mkdir ${{ env.GITHUB_WORKSPACE }}/channel/win-64 move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.GITHUB_WORKSPACE }}/channel/win-64 - python -m conda_index "${{ env.GITHUB_WORKSPACE }}/channel" + python -m conda_index ${{ env.GITHUB_WORKSPACE }}/channel # Test channel conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}/ver.json @@ -269,7 +269,7 @@ jobs: FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO ( SET PACKAGE_VERSION=%%F ) - conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile + conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile more lockfile - name: Cache conda packages @@ -302,5 +302,5 @@ jobs: - name: Run tests run: | - conda activate -n ${{ env.TEST_ENV_NAME }} + conda activate ${{ env.TEST_ENV_NAME }} pytest -v --pyargs ${{ env.MODULE_NAME }} diff --git a/conda-recipe-cf/bld.bat b/conda-recipe-cf/bld.bat new file mode 100644 index 0000000..cc55004 --- /dev/null +++ b/conda-recipe-cf/bld.bat @@ -0,0 +1,5 @@ +@rem Remember to activate Intel Compiler, or remove these two lines to use Microsoft Visual Studio compiler + +set MKLROOT=%PREFIX% +%PYTHON% setup.py build --force install --old-and-unmanageable +if errorlevel 1 exit 1 diff --git a/conda-recipe-cf/build.sh b/conda-recipe-cf/build.sh new file mode 100644 index 0000000..5d36203 --- /dev/null +++ b/conda-recipe-cf/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash -x +MKLROOT=$PREFIX $PYTHON setup.py build --force install --old-and-unmanageable diff --git a/conda-recipe-cf/conda_build_config.yaml b/conda-recipe-cf/conda_build_config.yaml new file mode 100644 index 0000000..d4b34a3 --- /dev/null +++ b/conda-recipe-cf/conda_build_config.yaml @@ -0,0 +1,16 @@ +c_compiler: # [linux] + - gcc # [linux] +cxx_compiler: # [linux] + - gxx # [linux] +cxx_compiler_version: # [linux] + - '14' # [linux] +c_stdlib: # [linux] + - sysroot # [linux] +c_stdlib_version: # [linux] + - '2.28' # [linux] +c_stdlib: # [win] + - vs # [win] +cxx_compiler: # [win] + - vs2022 # [win] +c_compiler: # [win] + - vs2022 # [win] diff --git a/conda-recipe-cf/meta.yaml b/conda-recipe-cf/meta.yaml new file mode 100644 index 0000000..c6653f5 --- /dev/null +++ b/conda-recipe-cf/meta.yaml @@ -0,0 +1,61 @@ +package: + name: mkl-service + version: {{ GIT_DESCRIBE_TAG }} + +source: + path: .. + +build: + number: {{ GIT_DESCRIBE_NUMBER }} + script_env: + - WHEELS_OUTPUT_FOLDER + ignore_run_exports: + - blas + - mkl-service + +requirements: + build: + - {{ compiler('c') }} + - {{ stdlib('c') }} + host: + - python + - python-gil # [py>=314] + - pip >=25.0 + - setuptools >=77 + - mkl-devel + - cython + - wheel >=0.45.1 + - python-build >=1.2.2 + run: + - python + - python-gil # [py>=314] + - {{ pin_compatible('mkl') }} + +test: + requires: + - pytest + imports: + - mkl + commands: + - pytest -vv --pyargs mkl + +about: + home: http://github.com/IntelPython/mkl-service + license: BSD-3-Clause + license_file: LICENSE.txt + summary: Python hooks for IntelĀ® oneAPI Math Kernel Library (oneMKL) runtime control settings + description: | + LEGAL NOTICE: Use of this software package is subject to the + software license agreement (as set forth above, in the license section of + the installed Conda package and/or the README file) and all notices, + disclaimers or license terms for third party or open source software + included in or with the software. +

+ EULA: BSD-3-Clause +

+ +extra: + recipe-maintainers: + - ndgrigorian + - antonwolfy + - xaleryb diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index ea420be..c6653f5 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -56,6 +56,6 @@ about: extra: recipe-maintainers: - - ekomarova - - vtavana + - ndgrigorian + - antonwolfy - xaleryb