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

Remove wurlitzer dependency #2423

Merged
merged 1 commit into from
May 6, 2024
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
1 change: 0 additions & 1 deletion python/sdist/amici/setup.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def get_extension() -> CMakeExtension:
ext_modules=[MODEL_EXT],
packages=find_namespace_packages(),
install_requires=["amici==TPL_AMICI_VERSION"],
extras_require={"wurlitzer": ["wurlitzer"]},
python_requires=">=3.10",
package_data={},
zip_safe=False,
Expand Down
42 changes: 11 additions & 31 deletions python/sdist/amici/swig_wrappers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Convenience wrappers for the swig interface"""

import logging
import sys
import warnings
from contextlib import contextmanager, suppress
from typing import Any

import amici
Expand All @@ -30,22 +28,6 @@
"get_model_settings",
]

try:
from wurlitzer import sys_pipes
except ModuleNotFoundError:
sys_pipes = suppress


@contextmanager
def _capture_cstdout():
"""Redirect C/C++ stdout to python stdout if python stdout is redirected,
e.g. in ipython notebook"""
if sys.stdout == sys.__stdout__:
yield
else:
with sys_pipes():
yield


def runAmiciSimulation(
model: AmiciModel,
Expand Down Expand Up @@ -82,10 +64,9 @@ def runAmiciSimulation(
stacklevel=1,
)

with _capture_cstdout():
rdata = amici_swig.runAmiciSimulation(
_get_ptr(solver), _get_ptr(edata), _get_ptr(model)
)
rdata = amici_swig.runAmiciSimulation(
_get_ptr(solver), _get_ptr(edata), _get_ptr(model)
)
_log_simulation(rdata)
if solver.getReturnDataReportingMode() == amici.RDataReporting.full:
_ids_and_names_to_rdata(rdata, model)
Expand Down Expand Up @@ -124,15 +105,14 @@ def runAmiciSimulations(
stacklevel=1,
)

with _capture_cstdout():
edata_ptr_vector = amici_swig.ExpDataPtrVector(edata_list)
rdata_ptr_list = amici_swig.runAmiciSimulations(
_get_ptr(solver),
edata_ptr_vector,
_get_ptr(model),
failfast,
num_threads,
)
edata_ptr_vector = amici_swig.ExpDataPtrVector(edata_list)
rdata_ptr_list = amici_swig.runAmiciSimulations(
_get_ptr(solver),
edata_ptr_vector,
_get_ptr(model),
failfast,
num_threads,
)
for rdata in rdata_ptr_list:
_log_simulation(rdata)
if solver.getReturnDataReportingMode() == amici.RDataReporting.full:
Expand Down
1 change: 0 additions & 1 deletion python/sdist/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ dependencies = [
"python-libsbml",
"pandas>=2.0.2",
"pyarrow",
"wurlitzer",
"toposort",
"setuptools>=48",
"mpmath",
Expand Down
Loading