Skip to content

Commit 62081f0

Browse files
committed
Remove all automatic installation of cmdstan from the package.
Now the package is distributed as pure python package, which should ease distribution. Instructions to use the stan model will be added in later commit.
1 parent 100687a commit 62081f0

File tree

6 files changed

+19
-242
lines changed

6 files changed

+19
-242
lines changed

.github/workflows/build-wheels.yaml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,29 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: ["macos-latest"] #, "ubuntu-latest", "windows-latest"]
15+
os: ["macos-latest", "ubuntu-latest", "windows-latest"]
1616
fail-fast: false
1717

1818
steps:
1919
- name: "Checkout repo"
2020
uses: actions/checkout@v4
2121

22-
- name: "Build wheels"
23-
uses: pypa/cibuildwheel@v2.8.1
22+
- name: "Set up Python"
23+
uses: actions/setup-python@v5
2424
with:
25-
package-dir: .
25+
python-version: '3.10'
2626

27-
env:
28-
CIBW_ENVIRONMENT: >
29-
PSEUDOBATCH_REPACKAGE_CMDSTAN=TRUE
27+
- name: "Install build"
28+
run: python -m pip install build
3029

31-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
32-
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-*
33-
CIBW_SKIP: "*musllinux*"
34-
CIBW_ARCHS: native
35-
CIBW_BUILD_FRONTEND: build
36-
# CIBW_TEST_REQUIRES: pytest
37-
# CIBW_TEST_COMMAND: "pytest {project}/tests"
30+
- name: "Build wheels"
31+
run: python -m build --wheel --outdir dist
3832

3933
- name: "Upload wheel as artifact"
4034
uses: actions/upload-artifact@v4
4135
with:
4236
name: artifact-${{ matrix.os }}-wheel
43-
path: "./**/*.whl"
37+
path: "./dist/*.whl"
4438

4539
make-sdist:
4640
name: Make source distribution

.github/workflows/documentation.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ permissions:
55

66
env:
77
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
8-
CMDSTAN_VERSION: "2.31.0"
8+
CMDSTAN_VERSION: "2.33.0"
99

1010
jobs:
1111
docs:
@@ -16,7 +16,7 @@ jobs:
1616
- name: Install cmdstanpy
1717
run: |
1818
python -m pip install --upgrade pip wheel
19-
pip install "cmdstanpy==1.0.4"
19+
pip install "cmdstanpy==1.1.0"
2020
- name: CmdStan installation cacheing
2121
uses: actions/cache@v2
2222
with:

.github/workflows/main.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
workflow_dispatch: {}
1414

1515
env:
16-
CMDSTAN_VERSION: "2.31.0"
16+
CMDSTAN_VERSION: "2.33.0"
1717

1818
jobs:
1919
sk-stan-learn:
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install cmdstanpy
3636
run: |
3737
python -m pip install --upgrade pip wheel
38-
pip install "cmdstanpy==1.0.4"
38+
pip install "cmdstanpy==1.1.0"
3939
4040
- name: CmdStan installation cacheing
4141
uses: actions/cache@v2

pseudobatch/error_propagation/__init__.py

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,14 @@
1616
cmdstanpy_installed = False
1717
raise ImportError(
1818
"cmdstanpy is not installed. To use the error propagation module, "
19-
"please install cmdstanpy by running 'pip install cmdstanpy'. "
20-
"Then install the CmdStan binaries by running 'cmdstanpy.install_cmdstan()'. "
21-
"Finally, install the remaining dependencies for the error propagation module "
22-
"by running 'pip install pseudobatch[error_propagation]'."
19+
"please install cmdstanpy and CmdStan. You can find installation instructions "
20+
"for different setups at https://mc-stan.org/cmdstanpy/installation.html."
21+
"After installing cmdstanpy and CmdStan install the remaining dependencies "
22+
"for the error propagation module by running "
23+
"'pip install pseudobatch[error_propagation]'."
2324
)
2425

2526
if cmdstanpy_installed:
2627
from pseudobatch.error_propagation.error_propagation import (
2728
run_error_propagation,
2829
)
29-
30-
STAN_FILES_FOLDER = Path(__file__).parent / "stan"
31-
CMDSTAN_VERSION = "2.31.0"
32-
33-
# on Windows specifically, we should point cmdstanpy to the repackaged
34-
# CmdStan if it exists. This lets cmdstanpy handle the TBB path for us.
35-
local_cmdstan = STAN_FILES_FOLDER / f"cmdstan-{CMDSTAN_VERSION}"
36-
if local_cmdstan.exists():
37-
cmdstanpy.set_cmdstan_path(str(local_cmdstan.resolve()))
38-
39-
def load_stan_model(name: str) -> cmdstanpy.CmdStanModel:
40-
"""
41-
Try to load precompiled Stan models. If that fails,
42-
compile them.
43-
"""
44-
try:
45-
model = cmdstanpy.CmdStanModel(
46-
exe_file=STAN_FILES_FOLDER / f"{name}.exe",
47-
stan_file=STAN_FILES_FOLDER / f"{name}.stan",
48-
compile=False,
49-
)
50-
except ValueError:
51-
warnings.warn(
52-
f"Failed to load pre-built model '{name}.exe', compiling"
53-
)
54-
model = cmdstanpy.CmdStanModel(
55-
stan_file=STAN_FILES_FOLDER / f"{name}.stan",
56-
stanc_options={"O1": True},
57-
)
58-
shutil.copy(
59-
model.exe_file, # type: ignore
60-
STAN_FILES_FOLDER / f"{name}.exe",
61-
)
62-
63-
return model
64-
65-
ERROR_PROPAGATION = load_stan_model("error_propagation")
66-
67-
# example: just print the info of the model
68-
print(ERROR_PROPAGATION.exe_info())

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "cmdstanpy==1.1.0"]
2+
requires = ["setuptools", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.isort]

setup.py

Lines changed: 0 additions & 178 deletions
This file was deleted.

0 commit comments

Comments
 (0)