Skip to content

Commit

Permalink
Fixing MacOs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kemuk committed Jan 13, 2025
1 parent 27bf65d commit 598a633
Showing 1 changed file with 26 additions and 48 deletions.
74 changes: 26 additions & 48 deletions .github/workflows/test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
fail-fast: false
matrix:
R: ['4.1.0']
python-version: ['3.10'] # Explicitly define Python version in matrix

steps:
- name: Checkout repository
Expand All @@ -30,15 +31,16 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}

- name: cache R installed packages
- name: Cache R packages
uses: actions/cache@v2
id: cache
with:
Expand All @@ -54,67 +56,43 @@ jobs:
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: setup r-reticulate venv
- name: Setup Python environment
shell: Rscript {0}
run: |
library(reticulate)
reticulate::py_run_string("
import sys
import subprocess
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip'])
")
# Install required packages
reticulate::py_run_string("
import sys
import subprocess
# Use the GitHub Actions Python
Sys.setenv(RETICULATE_PYTHON = Sys.which("python"))
# Install basic packages
packages = ['numpy', 'pandas', 'matplotlib']
for package in packages:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', package])
# Install pip packages
system2("pip", c("install", "--upgrade", "pip"))
system2("pip", c("install", "--upgrade", "numpy", "pandas", "matplotlib"))
system2("pip", c("install", "--upgrade", "git+https://github.com/SABS-R3-Epidemiology/epiabm.git@main#egg=pyEpiabm&subdirectory=pyEpiabm"))
# Install pyEpiabm from GitHub
subprocess.check_call([
sys.executable, '-m', 'pip', 'install', '--upgrade',
'git+https://github.com/SABS-R3-Epidemiology/epiabm.git@main#egg=pyEpiabm&subdirectory=pyEpiabm'
])
")
# Verify Python configuration
py_config <- reticulate::py_config()
message("Python configuration:")
message(paste("Python version:", py_config$version))
message(paste("Python path:", py_config$python))
env_name <- "r-py-env"
python_version = "3.9"
tryCatch({
# Check if virtualenv package is available
if (!reticulate::virtualenv_exists(env_name)) {
message(sprintf("Creating new Python virtual environment: %s", env_name))
# Create virtual environment with system site packages to help with SSL
reticulate::virtualenv_create(
envname = env_name,
version = python_version,
packages = "pip",
system_site_packages = TRUE
)
}
# Activate the environment
reticulate::use_virtualenv(env_name, required = TRUE)
return(TRUE)
}, error = function(e) {
warning(sprintf("Failed to create/activate Python environment: %s", e$message))
return(FALSE)
})
# Test imports
reticulate::py_run_string("
import numpy
import pandas
import matplotlib
import pyEpiabm
print('All required Python packages successfully imported')
")
- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
RETICULATE_PYTHON: ${{ env.pythonLocation }}/python
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true

0 comments on commit 598a633

Please sign in to comment.