Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-pymeilisearch
Browse files Browse the repository at this point in the history
  • Loading branch information
Revathyvenugopal162 authored Oct 13, 2023
2 parents 03046a8 + 5ee39a2 commit 7850d7f
Show file tree
Hide file tree
Showing 86 changed files with 1,779 additions and 677 deletions.
94 changes: 94 additions & 0 deletions .ci/build_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# This script generates the different versions of the ansys-dpf-core wheels based on a given input.
# Input can be one of ["any", "win", "manylinux1", "manylinux_2_17"]

import argparse
import pathlib
import subprocess
import os
import sys
import shutil
import tempfile


supported_platforms = {
"any": "any",
"win": "win_amd64",
"manylinux1": "manylinux1_x86_64",
"manylinux_2_17": "manylinux_2_17_x86_64"
}

argParser = argparse.ArgumentParser()
argParser.add_argument("-p", "--platform", help="platform")
argParser.add_argument("-w", "--wheelhouse", help="platform", action='store_true')

args = argParser.parse_args()

if args.platform not in supported_platforms:
raise ValueError(f"Platform {args.platform} is not supported. "
f"Supported platforms are: {list(supported_platforms.keys())}")
else:
requested_platform = supported_platforms[args.platform]
print(requested_platform)

# Move binaries out of the source depending on platform requested
# any: move all binaries out before building
# win: move .so binaries out before building
# lin: move .dll binaries out before building
with tempfile.TemporaryDirectory() as tmpdirname:
print('Created temporary directory: ', tmpdirname)

# Create the temporary build-opts.cfg
build_opts_path = os.path.join(tmpdirname, "build-opts.cfg")
with open(build_opts_path, "w") as build_opts_file:
build_opts_file.write(f"[bdist_wheel]\nplat-name={requested_platform}")
os.environ["DIST_EXTRA_CONFIG"] = build_opts_path

# Move the binaries
gatebin_folder_path = os.path.join(
os.path.curdir,
os.path.join("src", "ansys", "dpf", "gatebin")
)
binaries_to_move = []
moved = []
if "win" in requested_platform or "any" == requested_platform:
# Move linux binaries
binaries_to_move.extend(["libAns.Dpf.GrpcClient.so", "libDPFClientAPI.so"])
if "linux" in requested_platform or "any" == requested_platform:
# Move windows binaries
binaries_to_move.extend(["Ans.Dpf.GrpcClient.dll", "DPFClientAPI.dll"])
if "any" == requested_platform:
binaries_to_move.extend(["_version.py"])

for binary_name in binaries_to_move:
src = os.path.join(gatebin_folder_path, binary_name)
dst = os.path.join(tmpdirname, binary_name)
print(f"Moving {src} to {dst}")
shutil.move(src=src, dst=dst)
moved.append([dst, src])

if "any" == requested_platform:
# Also remove the gatebin folder
os.rmdir(gatebin_folder_path)

# Call the build
if not args.wheelhouse:
cmd = [sys.executable, "-m", "build", "--wheel"]
else:
cmd = [sys.executable, "-m", "pip", "wheel", "-w", "dist", "."]
try:
subprocess.run(cmd, capture_output=False, text=True)
print("Done building the wheel.")
except Exception as e:
print(f"Build failed with error: {e}")

if "any" == requested_platform:
# Recreate the gatebin folder
os.mkdir(gatebin_folder_path)

# Move binaries back
for move_back in moved:
print(f"Moving back {move_back[0]} to {move_back[1]}")
shutil.move(src=move_back[0], dst=move_back[1])
print("Binaries moved back.")

print(f"Done building {requested_platform} wheel for ansys-dpf-core!")
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,32 @@ jobs:
- name: "Run pre-commit"
run: pre-commit run --all-files --show-diff-on-failure

build_linux1:
name: "Build linux1 wheel"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: "Install requirements"
run: pip install -r requirements/requirements_build.txt

- name: "Build the manylinux1 wheel"
shell: bash
id: wheel
run: |
python .ci/build_wheel.py -p manylinux1
cd dist
export name=`ls ansys_dpf_core*.whl`
echo ${name}
echo "wheel_name=${name[0]}" >> $GITHUB_OUTPUT
cd ..
- name: "Upload wheel any as artifact"
uses: actions/upload-artifact@v3
with:
name: ${{ steps.wheel.outputs.wheel_name }}
path: dist/${{ steps.wheel.outputs.wheel_name }}

tests:
uses: ./.github/workflows/tests.yml
with:
Expand All @@ -62,6 +88,17 @@ jobs:
standalone_suffix: ${{ github.event.inputs.standalone_branch_suffix || '' }}
secrets: inherit

tests_any:
uses: ./.github/workflows/tests.yml
with:
ANSYS_VERSION: "241"
python_versions: '["3.8"]'
wheel: true
wheelhouse: false
standalone_suffix: ${{ github.event.inputs.standalone_branch_suffix || '' }}
test_any: true
secrets: inherit

docker_tests:
name: "Build and Test on Docker"
uses: ./.github/workflows/test_docker.yml
Expand Down
48 changes: 38 additions & 10 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@ jobs:
- name: "Run pre-commit"
run: pre-commit run --all-files --show-diff-on-failure

build_linux1:
name: "Build linux1 wheel"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: "Install requirements"
run: pip install -r requirements/requirements_build.txt

- name: "Build the manylinux1 wheel"
shell: bash
id: wheel
run: |
python .ci/build_wheel.py -p manylinux1
cd dist
export name=`ls ansys_dpf_core*.whl`
echo ${name}
echo "wheel_name=${name[0]}" >> $GITHUB_OUTPUT
cd ..
- name: "Upload wheel any as artifact"
uses: actions/upload-artifact@v3
with:
name: ${{ steps.wheel.outputs.wheel_name }}
path: dist/${{ steps.wheel.outputs.wheel_name }}

tests:
uses: ./.github/workflows/tests.yml
with:
Expand All @@ -64,6 +90,17 @@ jobs:
standalone_suffix: ${{ github.event.inputs.standalone_branch_suffix || '.pre0' }}
secrets: inherit

tests_any:
uses: ./.github/workflows/tests.yml
with:
ANSYS_VERSION: "241"
python_versions: '["3.8", "3.9", "3.10"]'
wheel: true
wheelhouse: false
standalone_suffix: ${{ github.event.inputs.standalone_branch_suffix || '.pre0' }}
test_any: true
secrets: inherit

docs:
uses: ./.github/workflows/docs.yml
with:
Expand Down Expand Up @@ -137,15 +174,6 @@ jobs:
ANSYS_VERSION: "222"
secrets: inherit

gate:
name: "gate"
uses: ./.github/workflows/gate.yml
with:
python_versions: '["3.8"]'
ANSYS_VERSION: "241"
standalone_suffix: ${{ github.event.inputs.standalone_branch_suffix || '.pre0' }}
secrets: inherit

docker_tests:
name: "Build and Test on Docker"
uses: ./.github/workflows/test_docker.yml
Expand All @@ -166,7 +194,7 @@ jobs:
draft_release:
name: "Draft Release"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [style, tests, docs, examples, retro_232, retro_231, retro_222, gate, docker_tests]
needs: [style, tests, docs, examples, retro_232, retro_231, retro_222, docker_tests]
runs-on: ubuntu-latest
steps:
- name: "Download artifacts"
Expand Down
53 changes: 41 additions & 12 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,53 @@ jobs:
echo "ANSYS_DPF_ACCEPT_LA=Y" >> $GITHUB_ENV
echo "ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }}" >> $GITHUB_ENV
- name: Setup Python
uses: actions/[email protected].0
- name: "Setup Python"
uses: actions/[email protected].1
with:
python-version: ${{ inputs.python_version }}

- name: "Build Package"
id: build-package
uses: ansys/pydpf-actions/[email protected]
- name: "Install requirements"
run: pip install -r requirements/requirements_build.txt

- name: "Build the wheel"
shell: bash
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
export platform="manylinux_2_17"
else
export platform="win"
fi
python .ci/build_wheel.py -p $platform -w
- name: "Expose the wheel"
shell: bash
id: wheel
working-directory: dist
run: |
export name=`ls ansys_dpf_core*.whl`
echo ${name}
echo "wheel_name=${name[0]}" >> $GITHUB_OUTPUT
- name: "Install package wheel"
shell: bash
run: |
pip install dist/${{ steps.wheel.outputs.wheel_name }}[plotting]
- name: "Install DPF"
id: set-server-path
uses: ansys/pydpf-actions/[email protected]
with:
python-version: ${{ inputs.python_version }}
ANSYS_VERSION: ${{inputs.ANSYS_VERSION}}
PACKAGE_NAME: ${{env.PACKAGE_NAME}}
MODULE: ${{env.MODULE}}
dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}}
install_extras: plotting
wheel: false
wheelhouse: false
standalone_suffix: ${{ inputs.standalone_suffix }}
ANSYS_VERSION : ${{inputs.ANSYS_VERSION}}

- name: "Check licences of packages"
uses: ansys/pydpf-actions/[email protected]

- name: "Test import"
shell: bash
working-directory: tests
run: python -c "from ansys.dpf import core"

- name: "Setup headless display"
uses: pyvista/setup-headless-display-action@v1
Expand Down
50 changes: 40 additions & 10 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,53 @@ jobs:
echo "ANSYS_DPF_ACCEPT_LA=Y" >> $GITHUB_ENV
echo "ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }}" >> $GITHUB_ENV
- name: Setup Python
- name: "Setup Python"
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: "Build Package"
uses: ansys/pydpf-actions/[email protected]
- name: "Install requirements"
run: pip install -r requirements/requirements_build.txt

- name: "Build the wheel"
shell: bash
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
export platform="manylinux_2_17"
else
export platform="win"
fi
python .ci/build_wheel.py -p $platform -w
- name: "Expose the wheel"
shell: bash
id: wheel
working-directory: dist
run: |
export name=`ls ansys_dpf_core*.whl`
echo ${name}
echo "wheel_name=${name[0]}" >> $GITHUB_OUTPUT
- name: "Install package wheel"
shell: bash
run: |
pip install dist/${{ steps.wheel.outputs.wheel_name }}[plotting]
- name: "Install DPF"
id: set-server-path
uses: ansys/pydpf-actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
ANSYS_VERSION: ${{inputs.ANSYS_VERSION}}
PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
MODULE: ${{ env.MODULE }}
dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}}
install_extras: plotting
wheelhouse: false
wheel: false
standalone_suffix: ${{ inputs.standalone_suffix }}
ANSYS_VERSION : ${{inputs.ANSYS_VERSION}}

- name: "Check licences of packages"
uses: ansys/pydpf-actions/[email protected]

- name: "Test import"
shell: bash
working-directory: tests
run: python -c "from ansys.dpf import core"

- name: "Prepare Testing Environment"
uses: ansys/pydpf-actions/[email protected]
Expand Down
Loading

0 comments on commit 7850d7f

Please sign in to comment.