Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8 version #9

Merged
merged 9 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ pywrapper/pyiapws/*.dll
pywrapper/pyiapws/*.dll.a
pywrapper/pyiapws/*.so
pywrapper/pyiapws/*.dylib
pywrapper/pyiapws/*.pyd
pywrapper/pyiapws/*.pyd
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ all: clean $(LIBNAME)

$(LIBNAME): build copy_a shared copy_h copy_shared

generator:
make -C srcgen generator

build: generator
build:
fpm build --profile=release

build_debug: generator
build_debug:
fpm build --profile=debug

test: build
Expand Down Expand Up @@ -68,7 +65,6 @@ copy_shared_windows:
clean:
fpm clean --all
rm -f src/*.mod
make -C srcgen clean
make -C $(PYW_MOD_DIR) clean

install: install_dirs install_$(PLATFORM)
Expand Down Expand Up @@ -97,4 +93,4 @@ uninstall:
rm -f $(install_dir)/lib/lib$(LIBNAME).so
rm -f $(install_dir)/lib/lib$(LIBNAME).dylib
rm -f $(install_dir)/lib/lib$(LIBNAME).dll.a
rm -f $(install_dir)/bin/lib$(LIBNAME).dll
rm -f $(install_dir)/bin/lib$(LIBNAME).dll
9 changes: 2 additions & 7 deletions documentation/sphinx/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
sys.path.insert(0, os.path.abspath('../../../pywrapper/'))
cautodoc_root = os.path.abspath('../../../pywrapper/')

# Import only version.py file for extracting the version
spec = importlib.util.spec_from_file_location('version', '../../../pywrapper/pyiapws/version.py')
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)


# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -47,7 +42,7 @@
# built documents.
#
# The short X.Y version.
version = mod.__version__
version = "0.2.2"
# The full version, including alpha/beta/rc tags.
release = version

Expand Down Expand Up @@ -187,4 +182,4 @@
numfig = True
math_numfig = True
numfig_secnum_depth = 2
math_eqref_format = "Eq.{number}"
math_eqref_format = "Eq.{number}"
2 changes: 1 addition & 1 deletion example/example_in_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(void){
int heavywater = 0;

printf("%s\n", "########################## IAPWS VERSION ##########################");
printf("version %s\n", iapws_version_capi_version);
printf("version %s\n", capi_get_version());

printf("%s\n", "########################## IAPWS R2-83 ##########################");
printf("%s %10.3f %s\n", "Tc in H2O", iapws_r283_capi_Tc_H2O, "K");
Expand Down
4 changes: 2 additions & 2 deletions example/example_in_f.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ program example_in_f
character(len=:), pointer :: gases_str

print *, '########################## IAPWS VERSION ##########################'
print *, "version ", iapws_version_version
print *, "version ", get_version()

print *, '########################## IAPWS R2-83 ##########################'
print "(a, f10.3, a)", "Tc in h2o=", iapws_r283_Tc_H2O, " k"
Expand Down Expand Up @@ -54,4 +54,4 @@ program example_in_f
print *, gases_list(i)%gas
enddo

end program
end program
4 changes: 2 additions & 2 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "iapws"
version = "0.2.2"
version = "0.2.2" # version must be also updated in: sources, pyproject.toml and sphinx conf.py
license = "GNU General Public License v3 (GPLv3)"
author = "Milan Skocic"
maintainer = "milan.skocic@icloud.com"
Expand Down Expand Up @@ -41,4 +41,4 @@ main = "test_g704_capi.c"

# [[test]]
# name = "test_r797"
# main = "test_r797.f90"
# main = "test_r797.f90"
4 changes: 2 additions & 2 deletions include/iapws_version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file
* @brief Version - autogenerated.
* @brief Version
*/

#ifndef iapws_VERSION_H
Expand All @@ -10,6 +10,6 @@
#else
#define ADD_IMPORT
#endif
ADD_IMPORT extern const char iapws_version_capi_version[ 6];
extern char* capi_get_version(void);
#endif

2 changes: 1 addition & 1 deletion pywrapper/pyiapws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Python wrapper of the (Modern Fortran) iapws library."""
from .version import *
from .version import __version__
from . import g704, r283
21 changes: 21 additions & 0 deletions pywrapper/pyiapws/cpy_iapws_version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "iapws.h"


PyDoc_STRVAR(module_docstring, "C extension for iapws version.");

static PyMethodDef myMethods[] = {{ NULL, NULL, 0, NULL }};
static struct PyModuleDef version= {PyModuleDef_HEAD_INIT, "version", module_docstring, -1, myMethods};

PyMODINIT_FUNC PyInit_version(void){
PyObject *m;
PyObject *d;
PyObject *v;
m = PyModule_Create(&version);
d = PyModule_GetDict(m);
v = PyUnicode_FromFormat("%s", capi_get_version());
PyDict_SetItemString(d, "__version__", v);
Py_INCREF(v);
return m;
}
12 changes: 12 additions & 0 deletions pywrapper/pyiapws/tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
r"""Tests for version."""
import unittest
from ..version import __version__


class TestVersion(unittest.TestCase):
r"""Test version module."""

def test_version(self):
value = __version__
expected = "0.2.2"
self.assertEqual(value, expected)
3 changes: 0 additions & 3 deletions pywrapper/pyiapws/version.py

This file was deleted.

8 changes: 7 additions & 1 deletion pywrapper/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects)
setup(ext_modules=[mod_g704, mod_r283])
mod_version = Extension(name="pyiapws.version",
sources=["./pyiapws/cpy_iapws_version.c"],
libraries=libraries,
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects)
setup(ext_modules=[mod_g704, mod_r283, mod_version])

26 changes: 24 additions & 2 deletions src/iapws_version.f90
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
module iapws__version
!! Version - autogenerated.
!! Version
use iso_fortran_env
implicit none
private

character(len= 5), parameter, public :: iapws_version_version = "0.2.2"
character(len=*), parameter :: version = "0.2.2"
character(len=:), allocatable, target :: version_f


public :: get_version

contains

function get_version()result(fptr)
!! Get the version.
implicit none

!! Returns
character(len=:), pointer :: fptr
!! Pointer to the version string.

if(allocated(version_f))then
deallocate(version_f)
endif
allocate(character(len=len(version)) :: version_f)
version_f = version
fptr => version_f
end function

end module iapws__version
30 changes: 27 additions & 3 deletions src/iapws_version_capi.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
module iapws__version_capi
!! Version C API - autogenerated.
!! Version C API
use iso_c_binding
use iapws__version
implicit none
private

character(kind=c_char), protected, public, bind(C) :: iapws_version_capi_version( 6) = &
["0", ".", "2", ".", "2", c_null_char]
character(len=:), allocatable, target :: version_c

public :: capi_get_version

contains

function capi_get_version()bind(c)result(cptr)
!! Get the version.
implicit none

! Returns
type(c_ptr) :: cptr
!! Pointer to version string.

character(len=:), pointer :: fptr
fptr => get_version()

if(allocated(version_c))then
deallocate(version_c)
endif
allocate(character(len=len(fptr)+1) :: version_c)

version_c = fptr // c_null_char
cptr = c_loc(fptr)
end function

end module iapws__version_capi
5 changes: 0 additions & 5 deletions srcgen/Makefile

This file was deleted.

20 changes: 0 additions & 20 deletions srcgen/version/Makefile

This file was deleted.

58 changes: 0 additions & 58 deletions srcgen/version/cheader.f90

This file was deleted.

Loading