Skip to content

Commit

Permalink
BLD: Update and simplify configure and make.
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Mar 3, 2024
1 parent bbafbc5 commit 4e3d84d
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 14 deletions.
32 changes: 19 additions & 13 deletions pywrapper/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
ifeq ($(plat), )
plat=linux
PY=python
AW=auditwheel repair --plat manylinux_2_17_x86_64 ./dist/*.whl
endif
ifeq ($(plat), windows)
plat=linux
ifeq ($(PLATFORM), windows)
PY=py -
endif
ifeq ($(plat), linux)
plat=linux
ifeq ($(PLATFORM), linux)
PY=python
AW=auditwheel repair --plat manylinux_2_17_x86_64 ./dist/*.whl
endif
ifeq ($(plat), darwin)
plat=darwin
ifeq ($(PLATFORM), darwin)
PY=python
endif

DIRS=build dist *.egg-info __pycache__ wheelhouse
SETUP=setup.py pyproject.toml

all: python3.8 python3.9 python3.10 python3.11 python3.12
Expand Down Expand Up @@ -60,4 +51,19 @@ python3.8: $(SETUP)
@echo "#################################"

clean:
rm -rf $(DIRS)
rm -rf build
rm -rf dist
rm -rf *.egg-info
rm -rf __pycache__
rm -rf wheelhouse
rm -rf $(PYW_SRC)/__pycache__

cleanall: clean

rm -f $(PYW_SRC)/$(HEADER_PREFIX)*.h
rm -f $(PYW_SRC)/*.a
rm -f $(PYW_SRC)/*.so
rm -f $(PYW_SRC)/*.dylib
rm -f $(PYW_SRC)/*.dll
rm -f $(PYW_SRC)/*.dll.a
rm -f $(PYW_SRC)/*.pyd
86 changes: 86 additions & 0 deletions pywrapper/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
PYW_SRC="./src/py$HEADER_PREFIX"
LIB_INCLUDE_DIR="../include"
LIB_BUILD_DIR="../build"

EXT=".so"

LIBS=("libgfortran.5" "libquadmath.0" "libgcc_s.1.1")
LIBSWINDOWS=("libwinpthread")

ROOTLINUX=/usr/lib/
ROOTDARWIN=/usr/local/opt/gcc/lib/gcc/current
ROOTWINDOWS=/C/msys64/mingw64/bin
ROOT=$ROOTLINUX

export PYW_SRC
echo "PYW_SRC=" $PYW_SRC

export LIB_INCLUDE_DIR
echo "LIB_INCLUDE_DIR=" $LIB_INCLUDE_DIR

export LIB_BUILD_DIR
echo "LIB_BUILD_DIR=" $LIB_BUILD_DIR


if [ "$PLATFORM" = "darwin" ]; then
ROOT=$ROOTDARWIN
EXT=".dylib"
fi

if [ "$PLATFORM" = "windows" ]; then
ROOT=$ROOTWINDOWS
EXT=".dll"
LIBS+=$LIBSWINDOWS
fi

if ! [ -z $1 ]; then
ROOT=$1
fi

# LIBRARY
echo "$LIBNAME folder: $LIB_BUILD_DIR"
fpath=$LIB_BUILD_DIR/$LIBNAME$EXT
if [ -f $fpath ]; then
echo -n " $fpath exists."
cp $fpath $PYW_SRC
echo " Copied."
if [ "$PLATFORM" = "windows" ]; then
cp $fpath.a $PYW_SRC
fi
else
echo " $fpath does not exist."
fi


# C HEADERS
echo "Include folder: $LIB_INCLUDE_DIR"
for header in "$LIB_INCLUDE_DIR"/*; do
echo -n " $header."
cp $LIB_INCLUDE_DIR/$header $PYW_SRC
echo " Copied."
done


# GFORTRAN LIBRARIES
echo "Gfortran libraries: $ROOT"
for lib in ${LIBS[@]}; do
fpath=$ROOT/$lib$EXT
if [ -f "$fpath" ]; then
echo -n " $fpath exists."
cp "$fpath" $PYW_SRC
if [ "$PLATFORM" = "darwin" ]; then
install_name_tool -change "$fpath" "@loader_path/$lib$EXT" $PYW_SRC/$LIBNAME$EXT
echo " Copied. Changed rpath in $LIBNAME$EXT."
else
echo " Copied."
fi
else
echo " $fpath does not exist."
fi
done


if [ "$PLATFORM" = "darwin" ]; then
echo "Check rpaths:"
otool -L $PYW_SRC/$LIBNAME$EXT
fi
2 changes: 1 addition & 1 deletion pywrapper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ include-package-data = false
where = ["src"]

[tool.setuptools.package-data]
pyiapws = ["libiapws.*"]
pyiapws = ["libiapws.*", "libgfortran*", "libquadmath*", "libgcc_s*", "libwinpthread*"]

0 comments on commit 4e3d84d

Please sign in to comment.