Skip to content

Commit 2712b9d

Browse files
authored
Fix: CMake-Built Wheel Install (#131)
* 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.
1 parent c0741b6 commit 2712b9d

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

.github/workflows/ubuntu.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ jobs:
6464
run: |
6565
ctest --test-dir build --output-on-failure
6666
67+
- name: Unit tests as installed
68+
run: |
69+
sudo cp build/lib/libamrex_*.so /usr/lib/
70+
rm -rf build
71+
python3 -m pytest tests
72+
6773
clang6:
6874
name: [email protected] w/o MPI
6975
runs-on: ubuntu-20.04

.github/workflows/windows.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ jobs:
6464
if(!$?) { Exit $LASTEXITCODE }
6565
cmake --build build --config Debug --target pip_install
6666
if(!$?) { Exit $LASTEXITCODE }
67+
- name: Unit tests as Installed
68+
run: |
69+
$env:PATH += ';C:/Program Files (x86)/pyAMReX/bin/'
70+
rm -r -fo build
71+
python3 -m pytest tests

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ set(pyAMReX_CUSTOM_TARGET_PREFIX "${_pyAMReX_CUSTOM_TARGET_PREFIX_DEFAULT}"
249249
add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_wheel
250250
${CMAKE_COMMAND} -E rm -f -r amrex-whl
251251
COMMAND
252-
${CMAKE_COMMAND} -E env PYAMREX_LIBDIR=$<TARGET_FILE_DIR:pyAMReX_${AMReX_SPACEDIM_LAST}d>
252+
${CMAKE_COMMAND} -E env PYAMREX_LIBDIR=${CMAKE_PYTHON_OUTPUT_DIRECTORY}/amrex/
253253
${Python_EXECUTABLE} -m pip wheel -v --no-build-isolation --no-deps --wheel-dir=amrex-whl ${pyAMReX_SOURCE_DIR}
254254
WORKING_DIRECTORY
255255
${pyAMReX_BINARY_DIR}

setup.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,9 @@ def run(self):
4141
# call superclass
4242
build.run(self)
4343

44-
# matches: amrex_*d_pybind.*.(so|pyd)
45-
re_libprefix = re.compile(r"amrex_.d_pybind\..*\.(?:so|pyd)")
46-
libs_found = []
47-
for lib_name in os.listdir(PYAMREX_libdir):
48-
if re_libprefix.match(lib_name):
49-
lib_path = os.path.join(PYAMREX_libdir, lib_name)
50-
libs_found.append(lib_path)
51-
if len(libs_found) == 0:
52-
raise RuntimeError(
53-
"Error: no pre-build pyAMReX libraries found in "
54-
"PYAMREX_libdir='{}'".format(PYAMREX_libdir)
55-
)
56-
57-
# copy external libs into collection of files in a temporary build dir
44+
# copy Python module artifacts and sources
5845
dst_path = os.path.join(self.build_lib, "amrex")
59-
for lib_path in libs_found:
60-
shutil.copy(lib_path, dst_path)
46+
shutil.copytree(PYAMREX_libdir, dst_path, dirs_exist_ok=True)
6147

6248

6349
class CMakeExtension(Extension):

0 commit comments

Comments
 (0)