Skip to content

Commit

Permalink
Fix: CMake-Built Wheel Install (#131)
Browse files Browse the repository at this point in the history
* CI: Unit Tests as Installed by CMake

* Powershell rm -r -fo

* Fix: CMake-based Wheel Build

Pre-builts the libraries that are picked up by `setup.py`.

* CI: Make Shared AMReX lib available

* Add Missing __init__.py Files

Recursive copy was not yet needed.
  • Loading branch information
ax3l authored May 25, 2023
1 parent c0741b6 commit 2712b9d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ jobs:
run: |
ctest --test-dir build --output-on-failure
- name: Unit tests as installed
run: |
sudo cp build/lib/libamrex_*.so /usr/lib/
rm -rf build
python3 -m pytest tests
clang6:
name: [email protected] w/o MPI
runs-on: ubuntu-20.04
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ jobs:
if(!$?) { Exit $LASTEXITCODE }
cmake --build build --config Debug --target pip_install
if(!$?) { Exit $LASTEXITCODE }
- name: Unit tests as Installed
run: |
$env:PATH += ';C:/Program Files (x86)/pyAMReX/bin/'
rm -r -fo build
python3 -m pytest tests
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ set(pyAMReX_CUSTOM_TARGET_PREFIX "${_pyAMReX_CUSTOM_TARGET_PREFIX_DEFAULT}"
add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_wheel
${CMAKE_COMMAND} -E rm -f -r amrex-whl
COMMAND
${CMAKE_COMMAND} -E env PYAMREX_LIBDIR=$<TARGET_FILE_DIR:pyAMReX_${AMReX_SPACEDIM_LAST}d>
${CMAKE_COMMAND} -E env PYAMREX_LIBDIR=${CMAKE_PYTHON_OUTPUT_DIRECTORY}/amrex/
${Python_EXECUTABLE} -m pip wheel -v --no-build-isolation --no-deps --wheel-dir=amrex-whl ${pyAMReX_SOURCE_DIR}
WORKING_DIRECTORY
${pyAMReX_BINARY_DIR}
Expand Down
18 changes: 2 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,9 @@ def run(self):
# call superclass
build.run(self)

# matches: amrex_*d_pybind.*.(so|pyd)
re_libprefix = re.compile(r"amrex_.d_pybind\..*\.(?:so|pyd)")
libs_found = []
for lib_name in os.listdir(PYAMREX_libdir):
if re_libprefix.match(lib_name):
lib_path = os.path.join(PYAMREX_libdir, lib_name)
libs_found.append(lib_path)
if len(libs_found) == 0:
raise RuntimeError(
"Error: no pre-build pyAMReX libraries found in "
"PYAMREX_libdir='{}'".format(PYAMREX_libdir)
)

# copy external libs into collection of files in a temporary build dir
# copy Python module artifacts and sources
dst_path = os.path.join(self.build_lib, "amrex")
for lib_path in libs_found:
shutil.copy(lib_path, dst_path)
shutil.copytree(PYAMREX_libdir, dst_path, dirs_exist_ok=True)


class CMakeExtension(Extension):
Expand Down

0 comments on commit 2712b9d

Please sign in to comment.