Skip to content

Commit

Permalink
Merge branch 'master' into ci/remove_restriction_protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
PProfizi authored Oct 16, 2023
2 parents 45ecbb2 + a63f620 commit 62f6c1c
Show file tree
Hide file tree
Showing 33 changed files with 692 additions and 426 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!")
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ body:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
validations:
required: true

Expand Down
46 changes: 0 additions & 46 deletions .github/ISSUE_TEMPLATE/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,3 @@ body:
as a .zip file.
validations:
required: true

- type: dropdown
id: os-name
attributes:
label: '💻 Which operating system are you using?'
multiple: false
options:
- 'Windows'
- 'MacOS'
- 'Linux'
validations:
required: true

- type: textarea
id: ansys-version
attributes:
label: '📀 Which ANSYS version are you using?'
placeholder: Indicate the ANSYS version of the products you are using.

validations:
required: false

- type: dropdown
id: python-version
attributes:
label: '🐍 Which Python version are you using?'
description: Run `python --version` to verify your Python version
multiple: false
options:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
validations:
required: true

- type: textarea
id: installed-packages
attributes:
label: '📦 Installed packages'
description: Run `python -m pip freeze` to list installed packages
placeholder: Paste the output of `python -m pip freeze` here.
render: shell
validations:
required: true
68 changes: 61 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ concurrency:

env:
DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com'
MAIN_PYTHON_VERSION: '3.8'
MAIN_PYTHON_VERSION: '3.9'
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }}

jobs:
debug:
Expand Down Expand Up @@ -50,14 +52,51 @@ 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:
ANSYS_VERSION: "241"
python_versions: '["3.8"]'
python_versions: '["3.9"]'
wheel: true
wheelhouse: false
standalone_suffix: ${{ github.event.inputs.standalone_branch_suffix || '' }}
secrets: inherit

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

docker_tests:
Expand All @@ -73,7 +112,7 @@ jobs:
uses: ./.github/workflows/examples_docker.yml
with:
ANSYS_VERSION: "241"
python_versions: '["3.8"]'
python_versions: '["3.9"]'
standalone_suffix: ${{ github.event.inputs.standalone_branch_suffix || '' }}
secrets: inherit

Expand All @@ -99,12 +138,27 @@ jobs:
doc-artifact-name: HTML-doc-ansys-dpf-core.zip
decompress-artifact: true

doc-index-dev:
name: "Deploy dev index docs"
runs-on: ubuntu-latest
needs: upload-development-docs
steps:
- name: "Deploy the latest documentation index"
uses: ansys/actions/doc-deploy-index@v4
with:
cname: ${{ env.DOCUMENTATION_CNAME }}/version/dev
index-name: pydpf-core-vdev
host-url: ${{ vars.MEILISEARCH_HOST_URL }}
api-key: ${{ env.MEILISEARCH_API_KEY }}
doc-artifact-name: HTML-doc-ansys-dpf-core.zip
decompress-artifact: true

examples:
if: startsWith(github.head_ref, 'master') || github.event.action == 'ready_for_review' || !github.event.pull_request.draft
uses: ./.github/workflows/examples.yml
with:
ANSYS_VERSION: "241"
python_versions: '["3.8"]'
python_versions: '["3.9"]'
standalone_suffix: ${{ github.event.inputs.standalone_branch_suffix || '' }}
secrets: inherit

Expand All @@ -114,7 +168,7 @@ jobs:
uses: ./.github/workflows/tests.yml
with:
ANSYS_VERSION: "232"
python_versions: '["3.8"]'
python_versions: '["3.9"]'
DOCSTRING: false
standalone_suffix: ''
secrets: inherit
Expand All @@ -125,7 +179,7 @@ jobs:
uses: ./.github/workflows/tests.yml
with:
ANSYS_VERSION: "231"
python_versions: '["3.8"]'
python_versions: '["3.9"]'
DOCSTRING: false
secrets: inherit

Expand All @@ -135,7 +189,7 @@ jobs:
uses: ./.github/workflows/tests.yml
with:
ANSYS_VERSION: "222"
python_versions: '["3.8"]'
python_versions: '["3.9"]'
DOCSTRING: false
secrets: inherit

Expand Down
Loading

0 comments on commit 62f6c1c

Please sign in to comment.