[tox]
envlist = py39, py310, py311, py39-user, py310-user, py311-user

requires =
    # Because of https://github.com/tox-dev/tox/issues/3238, need <4.14.1
    tox<4.14.1

[testenv:.pkg]
basepython = py311
passenv =
   MAKE
   # So that .homebrew-build-env will work
   HOMEBREW

setenv =
   HOME={work_dir}/home
   # Passed to 'make' instead of 'build'. We test here:
   # - frobby (standalone program with dependency on gmp; tests that .homebrew-build-env is invoked correctly)
   # - lrcalc_python (builds a platform wheel, possibly with use of system library)
   # - coxeter3 (which allows us to build sagemath-coxeter3)
   SAGE_CONF_TARGETS=frobby lrcalc_python coxeter3

[testenv:python]
package = wheel
deps =
    # For the 'sage' script
    sagemath-environment
setenv =
    HOME={work_dir}/home
allowlist_externals =
   bash
   env
commands =
   bash -c 'set -ex; eval $SETENV; \
            sage-config; \
            ls $(sage-config SAGE_SPKG_WHEELS); \
            sage -sh -c "frobby genideal"; \
            {envpython} -m pip install $(sage-config SAGE_SPKG_WHEELS)/*.whl'

[testenv:python-user]
package = wheel
deps =
    {[testenv:python]deps}
setenv =
    {[testenv:python]setenv}
    PYTHONUSERBASE={work_dir}/userbase
    SETENV=export PATH={env:PYTHONUSERBASE}/bin:{env:PATH}
system_site_packages = True
install_command = env PATH={env:PYTHONUSERBASE}/bin:{env_bin_dir} python -I -m pip install --user {opts} {packages}
allowlist_externals =
   {[testenv:python]allowlist_externals}
commands =
   {[testenv:python]commands}
