Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
68d0633
Update viphreeqc.py
DocMT Jun 27, 2025
a135989
Update appveyor.yml
DocMT Jun 27, 2025
1f8bd4c
Update viphreeqc.py
DocMT Jun 27, 2025
5039c5e
Create python-package.yml
DocMT Jun 28, 2025
6c7f26b
Update viphreeqc.py to pass flake8 analysis
DocMT Jun 28, 2025
5b5a305
Update test_phreeqpython.py
DocMT Jun 28, 2025
0bd5ca1
Update test_utility.py
DocMT Jun 28, 2025
abcbdcb
Update setup.py
DocMT Jun 28, 2025
ca97720
Update setup.py
DocMT Jun 28, 2025
aa2f30a
Update setup.py
DocMT Jun 28, 2025
8cdbfb5
Update python-package.yml
DocMT Jun 28, 2025
33406d8
Update README.md
DocMT Jun 28, 2025
487ab29
Update README.md
DocMT Jun 28, 2025
2da5456
Update README.md
DocMT Jun 28, 2025
1982a66
Update python-package.yml
DocMT Jun 29, 2025
b3cca6b
Update python-package.yml
DocMT Jun 29, 2025
7143c0c
Update README.md
DocMT Jun 29, 2025
72c8ad7
Update appveyor.yml
DocMT Jul 1, 2025
d047395
Update appveyor.yml
DocMT Jul 1, 2025
a8f4e68
Update appveyor.yml
DocMT Jul 1, 2025
a1580bd
Update appveyor.yml
DocMT Jul 1, 2025
9bf2612
Update appveyor.yml
DocMT Jul 1, 2025
87157b9
Update appveyor.yml
DocMT Jul 1, 2025
13ce0f9
Update appveyor.yml
DocMT Jul 1, 2025
5a69d43
Update appveyor.yml
DocMT Jul 1, 2025
6ad40a8
Update appveyor.yml
DocMT Jul 1, 2025
4a4d6ed
Update appveyor.yml
DocMT Jul 1, 2025
6c25f05
Merge pull request #48 from DocMT/master
AbelHeinsbroek Feb 23, 2026
ffe37c4
add wasm, remove scipy from dependencies for now
AbelHeinsbroek Apr 29, 2026
2f0805e
Merge branch 'master' into emscripten
AbelHeinsbroek Apr 29, 2026
e002001
make scipy an optional dependency to keep wasm build lightweight
AbelHeinsbroek Apr 29, 2026
6e5ee54
Merge branch 'emscripten' of https://github.com/VitensTC/phreeqpython…
AbelHeinsbroek Apr 29, 2026
eeba418
remove mol to ug conversion test for now
AbelHeinsbroek Apr 29, 2026
2b6dbe9
change test runner to target different architectures
AbelHeinsbroek Apr 29, 2026
d1bbfb5
fix ci
AbelHeinsbroek Apr 29, 2026
400bcb8
add wheels/publish action, create lightweight wheels per platform, in…
AbelHeinsbroek Apr 29, 2026
12580c9
fix wheel generation
AbelHeinsbroek Apr 29, 2026
db0f2eb
fix wheel generator for linux
AbelHeinsbroek Apr 29, 2026
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
41 changes: 41 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow installs dependencies, lints, and runs tests across OS runners
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
architecture: ${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install flake8 pytest
python -m pip install numpy scipy periodictable
python -m pip install .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
131 changes: 131 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Build wheels

on:
workflow_dispatch:
push:
branches: ["master", "emscripten"]
tags: ["v*"]

jobs:
native-wheels:
name: Native wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-14]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install build tooling
run: python -m pip install --upgrade pip cibuildwheel

- name: Build wheels
run: python -m cibuildwheel --output-dir dist
env:
CIBW_BUILD: cp312-*
CIBW_SKIP: pp* *-musllinux_*
CIBW_ARCHS_MACOS: arm64
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=26.0

- name: Upload native wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: dist/*.whl

wasm-wheel:
name: WASM wheel (Pyodide)
runs-on: ubuntu-latest
env:
PYODIDE_EMSCRIPTEN_TAG: emscripten_3_1_58_wasm32

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install build tooling
run: python -m pip install --upgrade pip build wheel

- name: Build wasm wheel
run: python -m build --wheel
env:
PHREEQPYTHON_TARGET: wasm

- name: Retag wheel for Pyodide
shell: bash
run: |
set -euo pipefail
WHEEL_PATH=$(ls dist/*.whl)
python -m wheel tags \
--python-tag cp312 \
--abi-tag cp312 \
--platform-tag "${PYODIDE_EMSCRIPTEN_TAG}" \
"${WHEEL_PATH}"
rm -f "${WHEEL_PATH}"

- name: Upload wasm wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheels-wasm
path: dist/*.whl

sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install build tooling
run: python -m pip install --upgrade pip build

- name: Build sdist
run: python -m build --sdist

- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz

pypi-publish:
name: Publish to PyPI
needs: [native-wheels, wasm-wheel, sdist]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
steps:
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true

- name: Download sdist artifact
uses: actions/download-artifact@v4
with:
name: sdist
path: dist

- name: Show artifacts
shell: bash
run: ls -la dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ For more examples, take a look at the `examples` folder.
* Using PhreeqPython on Windows requires installing [Visual C++ Redistributable 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145)

## Unit Tests
| **Mac/Linux** | **Windows** | **Coverage** |
|---|---|---|
| [![Build Status](https://travis-ci.com/Vitens/phreeqpython.svg?branch=master)](https://travis-ci.com/Vitens/phreeqpython) | [![Build status](https://ci.appveyor.com/api/projects/status/lr1jwspxdkgo85bv?svg=true)](https://ci.appveyor.com/project/abelheinsbroek/phreeqpython) | [![codecov](https://codecov.io/gh/Vitens/phreeqpython/branch/master/graph/badge.svg)](https://codecov.io/gh/Vitens/phreeqpython) |
| **Mac/Linux** and **Windows** | **Coverage** |
|---|---|
| [![Python package](https://github.com/DocMT/phreeqpython/actions/workflows/python-package.yml/badge.svg)](https://github.com/DocMT/phreeqpython/actions/workflows/python-package.yml)| [![codecov](https://codecov.io/gh/Vitens/phreeqpython/branch/master/graph/badge.svg)](https://codecov.io/gh/Vitens/phreeqpython) |


## Acknowledgements
Expand Down
19 changes: 0 additions & 19 deletions appveyor.yml

This file was deleted.

Binary file modified phreeqpython/lib/viphreeqc.dylib
Binary file not shown.
Binary file added phreeqpython/lib/viphreeqcwasm.so
Binary file not shown.
8 changes: 7 additions & 1 deletion phreeqpython/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from .equilibriumphase import EquilibriumPhase
from .gas import Gas

from scipy.integrate import odeint
import numpy as np

class Solution(object):
Expand Down Expand Up @@ -160,6 +159,13 @@ def end(self):


def kinetics(self, element, rate_function, time, m0=0, args=(), units='mmol'):
try:
from scipy.integrate import odeint
except ImportError as exc:
raise ImportError(
"kinetics requires scipy. Install with "
"'pip install phreeqpython[kinetics]' or install scipy manually."
) from exc

def calc_rate(y, t, m0, *args):
temp = self.copy()
Expand Down
22 changes: 17 additions & 5 deletions phreeqpython/viphreeqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def bytes(str_, encoding): #pylint: disable-msg=W0613
"""Compatibilty function for Python 3.
"""
return str_
range = xrange #pylint: disable-msg=C0103
range = xrange #pylint: disable-msg=C0103 # noqa: F821
#pylint: enable-msg=W0622


Expand All @@ -39,15 +39,27 @@ def __init__(self, dll_path=None):
"""
if not dll_path:
if sys.platform == 'win32':
dll_name = './lib/VIPhreeqc.dll'
dll_names = ['./lib/viphreeqc.dll', './lib/VIPhreeqc.dll']
elif 'linux' in sys.platform:
dll_name = './lib/viphreeqc.so'
dll_names = ['./lib/viphreeqc.so']
elif sys.platform == 'darwin':
dll_name = './lib/viphreeqc.dylib'
dll_names = ['./lib/viphreeqc.dylib']
elif 'emscripten' in sys.platform:
dll_names = ['./.libs/viphreeqc.so', './lib/viphreeqcwasm.so']
else:
msg = 'Platform %s is not supported.' % sys.platform
raise NotImplementedError(msg)
dll_path = os.path.join(os.path.dirname(__file__), dll_name)

module_dir = os.path.dirname(__file__)
dll_path = None
for dll_name in dll_names:
candidate = os.path.join(module_dir, dll_name)
if os.path.exists(candidate):
dll_path = candidate
break

if dll_path is None:
dll_path = os.path.join(module_dir, dll_names[0])
phreeqc = ctypes.cdll.LoadLibrary(dll_path)
self.debug = False
self.dll = phreeqc
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
root_is_pure = false
Loading
Loading