Skip to content

Commit

Permalink
science/chemicalfun: Update g20220104 -> 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yurivict committed Jul 17, 2022
1 parent 1ce2648 commit 9a53618
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 8 deletions.
35 changes: 30 additions & 5 deletions science/chemicalfun/Makefile
@@ -1,22 +1,47 @@
PORTNAME= chemicalfun
DISTVERSION= g20220104
DISTVERSION= 0.1.3
CATEGORIES= science # chemistry
MASTER_SITES= https://bitbucket.org/${BB_ACCOUNT}/${PORTNAME}/get/${BB_COMMIT}${EXTRACT_SUFX}?dummy=/:src
DISTFILES= ${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX}:src

MAINTAINER= yuri@FreeBSD.org
COMMENT= C++ library for working with chemical reactions and formulas

BUILD_DEPENDS= nlohmann-json>0:devel/nlohmann-json
BUILD_DEPENDS= nlohmann-json>0:devel/nlohmann-json \
spdlog>0:devel/spdlog
LIB_DEPENDS= libfmt.so:devel/libfmt # due to SPDLOG_FMT_EXTERNAL

USES= cmake:testing eigen:3
USES= cmake:testing compiler:c++17-lang eigen:3 localbase

BB_ACCOUNT= gems4
BB_COMMIT= dd673f906517
BB_COMMIT= 0e0edc84688c

WRKSRC= ${WRKDIR}/${BB_ACCOUNT}-${PORTNAME}-${BB_COMMIT}

CMAKE_OFF= CHEMICALFUN_BUILD_PYTHON
CMAKE_TESTING_ON= CHEMICALFUN_BUILD_TESTS # tests fail to compile, BitBucket offers no easy way to report this
CMAKE_TESTING_TARGET= ${ALL_TARGET} # hack to prevent test run

CXXFLAGS+= -DSPDLOG_FMT_EXTERNAL # see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258073#c3
LDFLAGS+= -L${LOCALBASE}/lib -lfmt # due to SPDLOG_FMT_EXTERNAL

OPTIONS_DEFINE= PYTHON
OPTIONS_DEFAULT= PYTHON
OPTIONS_SUB= yes

PYTHON_USES= python
PYTHON_CMAKE_BOOL= CHEMICALFUN_BUILD_PYTHON
PYTHON_CMAKE_ON= -DFREEBSD_STAGEDIR=${STAGEDIR}
PYTHON_BUILD_DEPENDS= pybind11>0:devel/pybind11

post-install-PYTHON-on:
@${STRIP_CMD} ${STAGEDIR}${PYTHON_SITELIBDIR}/chemicalfun/PyChemicalFun${PYTHON_EXT_SUFFIX}.so

post-test:
@${ECHO} "==> run C++ tests"
@cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} tests/test_main

post-test-PYTHON-on:
@${ECHO} "==> run Python tests"
@cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} ${PYTHON_CMD} ${FILESDIR}/test.py

.include <bsd.port.mk>
6 changes: 3 additions & 3 deletions science/chemicalfun/distinfo
@@ -1,3 +1,3 @@
TIMESTAMP = 1642530020
SHA256 (chemicalfun-g20220104.tar.gz) = 2944e24ceda906511f7837ae29298d10aee47a0a9440f6955ff4be39899233c8
SIZE (chemicalfun-g20220104.tar.gz) = 931249
TIMESTAMP = 1658079527
SHA256 (chemicalfun-0.1.3.tar.gz) = ad6cbd46bb75fe5811f4fcae7966d7717bf30f4f0f4749783e09a9f53780e6e6
SIZE (chemicalfun-0.1.3.tar.gz) = 933523
11 changes: 11 additions & 0 deletions science/chemicalfun/files/patch-python_chemicalfun_CMakeLists.txt
@@ -0,0 +1,11 @@
--- python/chemicalfun/CMakeLists.txt.orig 2022-07-17 18:29:23 UTC
+++ python/chemicalfun/CMakeLists.txt
@@ -43,7 +43,7 @@ install(CODE
endif()

execute_process(
- COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install --prefix=\${CHEMICALFUN_PYTHON_INSTALL_PREFIX_NATIVE}
+ COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install --root=${FREEBSD_STAGEDIR} --prefix=\${CHEMICALFUN_PYTHON_INSTALL_PREFIX_NATIVE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
"
)
15 changes: 15 additions & 0 deletions science/chemicalfun/files/test.py
@@ -0,0 +1,15 @@
# test from README

import chemicalfun as cf

formulas = ['Ca+2', 'CO3-2', 'H+', 'OH-', 'HCO3-', 'CaCO3', 'H2O']

chemicalReactions = cf.ChemicalReactions(formulas)

reactions = chemicalReactions.generateReactions() # returns the reactions list as a list of tuples ('substance', coefficient)

# can be transformed to a list of dictionaries, with reaction substances as keys and the reaction coefficients as values
reactions_dic = [{el[0]: el[1] for el in r} for r in reactions]

print(chemicalReactions.printReactions())
print(reactions_dic)
4 changes: 4 additions & 0 deletions science/chemicalfun/pkg-plist
Expand Up @@ -13,3 +13,7 @@ lib/cmake/ChemicalFun/ChemicalFunConfigVersion.cmake
lib/cmake/ChemicalFun/ChemicalFunTargets-%%CMAKE_BUILD_TYPE%%.cmake
lib/cmake/ChemicalFun/ChemicalFunTargets.cmake
lib/libChemicalFun.so
%%PYTHON%%%%PYTHON_SITELIBDIR%%/chemicalfun/PyChemicalFun%%PYTHON_EXT_SUFFIX%%.so
%%PYTHON%%%%PYTHON_SITELIBDIR%%/chemicalfun/__init__.py
%%PYTHON%%%%PYTHON_SITELIBDIR%%/chemicalfun/__pycache__/__init__%%PYTHON_EXT_SUFFIX%%.pyc
%%PYTHON%%%%PYTHON_SITELIBDIR%%/chemicalfun-0.1.3-py%%PYTHON_VER%%.egg-info

0 comments on commit 9a53618

Please sign in to comment.