Skip to content

Adding dismod-at to conda-forge #29516

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

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e9bc565
dismod-at: first version that builds on Linux.
bradbell Mar 23, 2025
8505ff3
dismod-at: use patch file instead of sed to patch source.
bradbell Mar 23, 2025
54a37cc
dismod-at: use patch (instead of sed) to patch source code.
bradbell Mar 23, 2025
0e2e7fd
Merge remote-tracking branch 'refs/remotes/origin/main'
bradbell Mar 23, 2025
30d8cd0
dismod_at: convert build to use ninja and add build.bat.
bradbell Mar 24, 2025
e8871b1
Merge branch 'conda-forge:main' into main
bradbell Mar 24, 2025
b01a5bf
dismod-at: 2025.0.1: CMakeLists.txt: splite3.pc is misisng on windows.
bradbell Mar 24, 2025
b7ec52c
dismod-at: 2025.0.1: init_command.cpp: fix (not -> !).
bradbell Mar 24, 2025
c9b1132
dismod-at: fix another if expression, reduce chance of failure in bal…
bradbell Mar 25, 2025
312a5bd
dismod-at: run_test.py: list sitepackages directory.
bradbell Mar 25, 2025
382e128
dismod-at: build.bat: add c++17 compiler flag.
bradbell Mar 25, 2025
9aa32a3
dismod-at: advance to 2025.0.2 to fix some conda install problems.
bradbell Mar 26, 2025
5b43460
dismod-at: put python in host section (try to fix pip install).
bradbell Mar 26, 2025
e57fa7b
dismod-at: Trying to get proper version of pytyhon to run pip.
bradbell Mar 26, 2025
645b954
dismod-at: 2025.0.2.patch: C++: close open sqlite databases.
bradbell Apr 3, 2025
12a7ef5
dismod-at: dismodat.py.bat: wrapper for dismodat.py on DOS.
bradbell Apr 3, 2025
a8a6315
dismod_at: build.bat: change python3 -> python.
bradbell Apr 3, 2025
8479c6b
dismod-at: another attempt to get windows sandbox test to run.
bradbell Apr 3, 2025
3e91ff4
dismod-at: 2025.0.2.patch: fix path in dismodat.py, fix exit in user_…
bradbell Apr 4, 2025
421350f
dismod-at: build.sh: change python -> $PREFIX/bin/python.
bradbell Apr 4, 2025
333fc53
Merge branch 'conda-forge:main' into main
bradbell Apr 4, 2025
0485e15
dismod-at: put python in host:, print python version and sys.path.
bradbell Apr 4, 2025
f19a555
Update recipes/dismod-at/recipe.yaml
bradbell Apr 7, 2025
92a2650
Update recipes/dismod-at/recipe.yaml
bradbell Apr 7, 2025
6cd1605
Update recipes/dismod-at/build.sh
bradbell Apr 7, 2025
2de3c77
recipe.yaml: Need runtime modules during build inorder to make check.
bradbell Apr 7, 2025
785d156
2025.0.2.patch: Do not run balanced_pair_xam (to many random failures).
bradbell Apr 7, 2025
409c598
Advance to dismod_at-2025.4.11 (special version for conda).
bradbell Apr 11, 2025
d471441
Merge branch 'main' into main
bradbell Apr 11, 2025
6edb300
run_test.py: change to a test that uses db2csv command.
bradbell Apr 11, 2025
934b9e0
recipe.yaml: balance_pair_xam.cpp: try 3 times instead of 2.
bradbell Apr 12, 2025
2e0e8ea
run_test.py: Improve messaging, change test_file in place.
bradbell Apr 12, 2025
446f069
run_test.py: Trying to figure out why dismod-at script not found on
bradbell Apr 12, 2025
f540fa2
run_test.py: add default exception message.
bradbell Apr 13, 2025
c08da51
run_test.py: change run_test: OK -> run_test.py: OK.
bradbell Apr 14, 2025
5ac590f
run_test.py: fix error message, make sandbox2installed a funciton, an…
bradbell Apr 14, 2025
767de5e
remove spaces at end of lines
bradbell Apr 14, 2025
9f13f30
Merge branch 'main' into main
bradbell Apr 14, 2025
70d8475
run_test.py: system_command: better error messaging.
bradbell Apr 15, 2025
5212040
recipe.yaml: advance to dismod_at-2025.4.16 (for better system_comman…
bradbell Apr 16, 2025
1f3b380
run_test.py: skip test that fails on windows.
bradbell Apr 16, 2025
822098f
run_test.py: fix platform.system -> platform.system().
bradbell Apr 16, 2025
b44d02f
build.bat: remove setting of PKG_CONFIG_PATH.
bradbell Apr 29, 2025
d445682
Merge branch 'main' into main
bradbell Apr 29, 2025
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
46 changes: 46 additions & 0 deletions recipes/dismod-at/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
:: echo
echo off

:: build
mkdir build
cd build

:: cmake
cmake -S %SRC_DIR% -B . ^
-G "Ninja" ^
-D CMAKE_BUILD_TYPE=Release ^
-D extra_cxx_flags="/std:c++17" ^
-D dismod_at_prefix="%PREFIX%\Library" ^
-D cmake_libdir=lib ^
-D python3_executable="python"
if errorlevel 1 exit 1

:: build
:: dismod_at C++ executable
ninja -j%CPU_COUNT% dismod_at
if errorlevel 1 exit 1

:: build
:: dismod_at unit tests (developer tests) can be built in parallel
ninja -j%CPU_COUNT% example_devel test_devel
if errorlevel 1 exit 1

:: check
:: This target does not support parallel execution because many of the
:: user tests use the same file name.
ninja -j1 check
if errorlevel 1 exit 1

:: C++ install
ninja -j%CPU_COUNT% install
if errorlevel 1 exit 1

:: install python module
%PYTHON% --version
if errorlevel 1 exit 1
%PYTHON% -m pip install %SRC_DIR%/python -vv --no-deps --no-build-isolation
if errorlevel 1 exit 1
%PYTHON% -m pip show dismod_at
if errorlevel 1 exit 1

echo 'build.bat: OK'
49 changes: 49 additions & 0 deletions recipes/dismod-at/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#! /usr/bin/env bash
echo "build.sh: pwd = $(pwd)"
#
# extra_cxx_flags
extra_cxx_flags='-Wpedantic -std=c++17 -Wall -Wshadow -Wconversion'
extra_cxx_flags+=' -Wno-bitwise-instead-of-logical'
if [[ "${target_platform}" == osx-* ]]; then
# https://conda-forge.org/docs/maintainer/knowledge_base.html#
# newer-c-features-with-old-sdk
extra_cxx_flags+=" -D_LIBCPP_DISABLE_AVAILABILITY"
fi
extra_cxx_flags+=' -Wno-sign-conversion'
#
# build
mkdir build && cd build
#
# cmake
cmake -S $SRC_DIR -B . \
-G 'Ninja' \
-D CMAKE_BUILD_TYPE=Release \
-D extra_cxx_flags="'$extra_cxx_flags'" \
-D dismod_at_prefix="$PREFIX" \
-D cmake_libdir=lib \
-D python3_executable="python3"
#
# build
# dismod_at C++ executable
ninja -j$CPU_COUNT dismod_at
#
# build
# dismod_at unit tests (developer tests) can be built in parallel
ninja -j$CPU_COUNT example_devel test_devel
#
#
# check
# This target does not support parallel execution because many of the
# user tests use the same file name.
ninja -j1 check
#
# C++ install
ninja -j$CPU_COUNT install
#
# install python module
echo 'build.sh: python version = '
"${PYTHON}" --version
"${PYTHON}" -m pip install $SRC_DIR/python -vv --no-deps --no-build-isolation
"${PYTHON}" -m pip show dismod_at
#
echo 'build.sh: OK'
78 changes: 78 additions & 0 deletions recipes/dismod-at/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
schema_version: 1

context:
name: dismod-at
version: 2025.4.16

package:
name: ${{ name }}
version: ${{ version }}

source:
#
url: https://github.com/bradbell/dismod_at/archive/${{ version }}.tar.gz
sha256: 0237d219817057d51a12f6e4902ffc0a176ca8b46d2b6f2f4adf166c5cd1c395
#
patches:
# dismodat.py: no patches for this version (yet)
# - ${{ version }}.patch

build:
# first build on this version
number: 0

requirements:
build:
- ${{ compiler('c') }}
- ${{ stdlib('c') }}
- ${{ compiler('cxx') }}
- cmake
- ninja
host:
- python
- pip
- setuptools
- pkg-config
- cppad-mixed
- sqlite
- eigen
- numpy
- matplotlib-base
- scipy
run:
- python
- numpy
- matplotlib-base
- scipy
run_exports:
- ${{ pin_subpackage(name, upper_bound='x.x') }}

tests:
- script:
interpreter: python
file: run_test.py
requirements:
run:
- python
- numpy
- matplotlib
- scipy
- sqlite
files:
source:
# see test_file at top of run_test.py
- example/get_started/get_started_db.py
- example/get_started/fit_command.py
- test/user/db2csv.py

about:
license: AGPL-3.0-or-later
license_file: agpl-3.0.txt
summary: Estimating disease rates as functions of age and time.
homepage: https://dismod-at.readthedocs.io/stable-2025
repository: https://github.com/bradbell/dismod_at
documentation: https://dismod-at.readthedocs.io/stable-2025/

extra:
recipe-maintainers:
- bradbell
126 changes: 126 additions & 0 deletions recipes/dismod-at/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#! /usr/bin/env python
#
# test_file_list
# These files must be in the test.sources of recipe.yaml.
# In addition, if any of the example/get_started/*.py appears below,
# example/get_started/get_started_db.py must be in test.sources of recipe.yaml.
test_file_list = [
'example/get_started/fit_command.py',
'test/user/db2csv.py' ,
]
#
# imports
import sys
import os
import re
import subprocess
import platform
import dismod_at
#
# sandbox2installed
def sandbox2installed(test_file) :
#
# test_file
assert test_file[-3 :] == '.py'
if not os.path.isfile(test_file) :
sys.exit( f'run_test.py: cannot find test file = {test_file}' )
#
# file_data
with open( test_file, 'r') as file_obj :
file_data = file_obj.read()
#
# file_data
# Change from sandbox dismod_at to installed dismod_at
pattern = r'\.\./\.\./devel/dismod_at'
replace = r'dismod_at'
file_data = re.sub(pattern, replace, file_data)
#
# file_data
# Change from sandbox dismodat.py to installed dismod-at
pattern = r'python/bin/dismodat.py'
replace = r'dismod-at'
file_data = re.sub(pattern, replace, file_data)
#
# file_data
# Remove python from font of dismod-at commands
pattern = r'python_exe *,'
replace = r''
file_data = re.sub(pattern, replace, file_data)
#
# test_file
with open(test_file , 'w') as file_obj :
file_obj.write(file_data)

#
# main
# Put this code in a function so as to not polute the file namespace
def main() :
#
# work_dir
work_dir = os.getcwd().replace('/', '|').replace('\\', '|')
print( f'run_test.py: work directory with / and \\ repalced by |')
print( work_dir )
#
# prefix_dir
prefix_dir = os.environ['PREFIX'].replace('/', '|').replace('\\', '|')
print( f'run_test.py: prefix directory with / and \\ repalced by |')
print( prefix_dir )
#
# sys.path
print( f'run_test.py: sys.path =\n{sys.path}' )
#
# sys.argv[0]
print( f'run_test.py: sys.argv[0] = {sys.argv[0]}' )
#
# platform.system
print( 'run_test.py: platform.system() = ', platform.system() )
#
# dismod_at, dismod-at
dir_list = os.environ['PATH'].replace(';', ':').split(':')
for directory in dir_list :
for file_name in [ 'dismod_at', 'dismod-at' ] :
file_path = f'{directory}/{file_name}'
if os.path.isfile( file_path ) :
print( f'run_test.py: found {file_path}' )
if platform.system() == 'Windows' :
for extension in [ 'exe', 'bat' ] :
if os.path.isfile( f'{file_path}.{extension}' ) :
print( f'run_test.py: found {file_path}.{extension}' )
#
# test_file
for test_file in test_file_list :
#
# skip
# test/user/db2csv.py tests the installed dismod-at python script.
# This is failing on the conda-forge test machine, but works
# doing a local rattler-build on a windows machine. At this point
# I think it is a problem with the conda test system.
skip = test_file=='test/user/db2csv.py' and platform.system() =='Windows'
if not skip :
#
# sandbox2installed
sandbox2installed(test_file)
#
# test_file
command = [ 'python', test_file ]
result = dismod_at.system_command_prc(
command ,
print_command = True ,
return_stdout = True ,
return_stderr = True ,
)
if result.stdout != '' :
print( result.stdout )
if result.returncode == 0 :
assert result.stderr == ''
else :
print( 'system_command_prc: Error Message:' )
print( result.stderr )
sys.exit(1)
#
print( 'run_test.py: OK' )
#
#
# python main
if __name__ == "__main__" :
main()