From c3fde55e7ad98b33b0e559c8719b00a13794c740 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Fri, 10 Nov 2023 12:49:20 +0000 Subject: [PATCH] Put test dependencies into print_deps --- .github/workflows/build.ps1 | 9 +++++---- .github/workflows/build.sh | 9 ++++----- .github/workflows/wheels-linux.yml | 1 - .github/workflows/wheels-macos.yml | 1 - print_deps.py | 14 ++++++++++---- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.ps1 b/.github/workflows/build.ps1 index 916e1b8..7da28ff 100644 --- a/.github/workflows/build.ps1 +++ b/.github/workflows/build.ps1 @@ -8,11 +8,12 @@ echo "::group::Build wheel" echo "::endgroup::" echo "::group::Install wheel" - pip install --find-links ./wheelhouse --pre nipy - pip install -r nipy/dev-requirements.txt + $test_dep = python .\print_deps.py $env:MB_PYTHON_VERSION ${env:REPO_DIR} -p test + pip install @($test_dep.split()) + pip install --find-links ./wheelhouse --pre nipy echo "::endgroup::" echo "::group::Test wheel" - python --version - pytest --doctest-plus --pyargs nipy + python --version + pytest --doctest-plus --pyargs nipy echo "::endgroup::" diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh index 78b5209..8d68446 100755 --- a/.github/workflows/build.sh +++ b/.github/workflows/build.sh @@ -32,8 +32,7 @@ echo "::group::Build wheel" ls -l "${GITHUB_WORKSPACE}/${WHEEL_SDIR}/" echo "::endgroup::" -if [[ $MACOSX_DEPLOYMENT_TARGET != "11.0" ]]; then - echo "::group::Test wheel" - install_run - echo "::endgroup::" -fi +echo "::group::Test wheel" + export TEST_DEPENDS=$(python ./print_deps.py ${MB_PYTHON_VERSION} ${REPO_DIR} -p test) + install_run +echo "::endgroup::" diff --git a/.github/workflows/wheels-linux.yml b/.github/workflows/wheels-linux.yml index 3038f94..d05f888 100644 --- a/.github/workflows/wheels-linux.yml +++ b/.github/workflows/wheels-linux.yml @@ -12,7 +12,6 @@ on: env: REPO_DIR: nipy - TEST_DEPENDS: "-r nipy/dev-requirements.txt" jobs: build: diff --git a/.github/workflows/wheels-macos.yml b/.github/workflows/wheels-macos.yml index e7802c8..5470d04 100644 --- a/.github/workflows/wheels-macos.yml +++ b/.github/workflows/wheels-macos.yml @@ -12,7 +12,6 @@ on: env: REPO_DIR: nipy - TEST_DEPENDS: "-r nipy/dev-requirements.txt" jobs: build: diff --git a/print_deps.py b/print_deps.py index 1d25641..cd6b17b 100755 --- a/print_deps.py +++ b/print_deps.py @@ -9,10 +9,14 @@ import tomlkit -def get_build_requirements(repo_path): +def get_phase_requirements(repo_path, phase='build'): toml = (Path(repo_path) / 'pyproject.toml').read_text() config = tomlkit.loads(toml) - requires = config.get('build-system', {}).get('requires', []) + if phase == 'build': + requires = config.get('build-system', {}).get('requires', []) + else: + dep_dict =config.get('project', {}).get('optional-dependencies', {}) + requires = dep_dict.get('default', []) + dep_dict.get(phase, []) base_req = [R for R in requires if not 'numpy' in R] return ' '.join(base_req) @@ -36,15 +40,17 @@ def get_parser(): formatter_class=RawDescriptionHelpFormatter) parser.add_argument("py_ver", help='Python version e.g. 3.11') parser.add_argument("repo_dir", help='Path to source repo') + parser.add_argument('-p', '--phase', default='build', + help='Phase ("build" or "test")') return parser def main(): parser = get_parser() args = parser.parse_args() + base = get_phase_requirements(args.repo_dir, args.phase) np_req = get_numpy_requirement(args.py_ver) - build_base = get_build_requirements(args.repo_dir) - print(f'{build_base} numpy=={np_req}') + print(f'numpy=={np_req} {base}') if __name__ == '__main__':