Skip to content

Commit

Permalink
BLD: Switch to src layout for pywrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Feb 11, 2024
1 parent 3f149b0 commit dc99a18
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 11 deletions.
4 changes: 2 additions & 2 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FC=gfortran
PYW_DIR="./pywrapper"
BUILD_DIR="./build"
INCLUDE_DIR="./include"
PYW_MOD_DIR="$PYW_DIR/py$LIBNAME"
PYW_MOD_DIR="$PYW_DIR/src/py$LIBNAME"
FPM_FFLAGS="-std=f2008 -pedantic -Wall -Wextra"
FPM_CFLAGS="-std=c11 -pedantic -Wall -Wextra"
FPM_LDFLAGS="-static"
Expand Down Expand Up @@ -64,4 +64,4 @@ echo "PYW DIR=" $PYW_DIR
echo "PYW MOD DIR=" $PYW_MOD_DIR
echo "BUILD DIR=" $BUILD_DIR
echo "INCLUDE_DIR=" $INCLUDE_DIR
echo "FC=" $FC
echo "FC=" $FC
4 changes: 2 additions & 2 deletions documentation/sphinx/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import os
import sys, importlib.util
sys.path.insert(0, os.path.abspath('../../../pywrapper/'))
cautodoc_root = os.path.abspath('../../../pywrapper/')
sys.path.insert(0, os.path.abspath('../../../pywrapper/src/'))
cautodoc_root = os.path.abspath('../../../pywrapper/src/')


# -- General configuration ------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion pywrapper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ classifiers=["Development Status :: 5 - Production/Stable",
Documentation = "https://milanskocic.github.io/iapws/index.html"
Source = "https://github.com/MilanSkocic/iapws"

[tool.setuptools]
include-package-data = false

[tool.setuptools.packages.find]
where = ["."]
where = ["src"]

[tool.setuptools.package-data]
pyiapws = ["libiapws.*"]
12 changes: 6 additions & 6 deletions pywrapper/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@

if platform.system() == "Linux":
libraries = ["iapws"]
library_dirs = ["./pyiapws"]
library_dirs = ["./src/pyiapws"]
runtime_library_dirs = ["$ORIGIN"]
if platform.system() == "Windows":
extra_objects = ["./pyiapws/libiapws.dll.a"]
extra_objects = ["./src/pyiapws/libiapws.dll.a"]
if platform.system() == "Darwin":
libraries = ["iapws"]
library_dirs = ["./pyiapws"]
library_dirs = ["./src/pyiapws"]
runtime_library_dirs = ["@loader_path"]

if __name__ == "__main__":

mod_g704 = Extension(name="pyiapws.g704",
sources=["./pyiapws/cpy_iapws_g704.c"],
sources=["./src/pyiapws/cpy_iapws_g704.c"],
libraries=libraries,
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects)
mod_r283 = Extension(name="pyiapws.r283",
sources=["./pyiapws/cpy_iapws_r283.c"],
sources=["./src/pyiapws/cpy_iapws_r283.c"],
libraries=libraries,
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects)
mod_version = Extension(name="pyiapws.version",
sources=["./pyiapws/cpy_iapws_version.c"],
sources=["./src/pyiapws/cpy_iapws_version.c"],
libraries=libraries,
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions pywrapper/src/pyiapws/iapws.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @file iapws.h
* @brief Main C header for the IAPWS library.
*/
#ifndef IAPWS_H
#define IAPWS_H
#include "iapws_version.h"
#include "iapws_g704.h"
#include "iapws_r283.h"
#endif
15 changes: 15 additions & 0 deletions pywrapper/src/pyiapws/iapws_g704.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @file iapws_g704.h
* @brief C header for the module iapws_g704.
*/

#ifndef IAPWS_G704_H
#define IAPWS_G704_H

extern void iapws_g704_capi_kh(double *T, char *gas, int heavywater, double *k, int size_gas, size_t size_T);
extern void iapws_g704_capi_kd(double *T, char *gas, int heavywater, double *k, int size_gas, size_t size_T);
extern int iapws_g704_capi_ngases(int heavywater);
extern char **iapws_g704_capi_gases(int heavywater);
extern char *iapws_g704_capi_gases2(int heavywater);

#endif
24 changes: 24 additions & 0 deletions pywrapper/src/pyiapws/iapws_r283.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @file iapws_r283.h
* @brief C header for the module iapws_r283.
*/

#ifndef IAPWS_R283_H
#define IAPWS_R283_H

#if _MSC_VER
#define ADD_IMPORT __declspec(dllimport)
#else
#define ADD_IMPORT
#endif

ADD_IMPORT extern const double iapws_Tc_H2O;
ADD_IMPORT extern const double iapws_Tc_D2O;

ADD_IMPORT extern const double iapws_pc_H2O;
ADD_IMPORT extern const double iapws_pc_D2O;

ADD_IMPORT extern const double iapws_rhoc_H2O;
ADD_IMPORT extern const double iapws_rhoc_D2O;

#endif
10 changes: 10 additions & 0 deletions pywrapper/src/pyiapws/iapws_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @file
* @brief Version
*/

#ifndef iapws_VERSION_H
#define iapws_VERSION_H
extern char* iapws_get_version(void);
#endif

Binary file added pywrapper/src/pyiapws/libiapws.dylib
Binary file not shown.
5 changes: 5 additions & 0 deletions pywrapper/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
import sys
PROJECT_PATH = os.getcwd()
SOURCE_PATH = os.path.join(PROJECT_PATH,"src")
sys.path.append(SOURCE_PATH)
2 changes: 2 additions & 0 deletions pywrapper/tests/test_g704.py → pywrapper/test/test_g704.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from pyiapws import g704
import numpy as np

print(g704.__file__)

T_KELVIN = 273.15

class TestkH(unittest.TestCase):
Expand Down
File renamed without changes.
File renamed without changes.
Empty file removed pywrapper/tests/__init__.py
Empty file.

0 comments on commit dc99a18

Please sign in to comment.