Skip to content

Commit c3fde55

Browse files
committed
Put test dependencies into print_deps
1 parent db69dad commit c3fde55

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

.github/workflows/build.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ echo "::group::Build wheel"
88
echo "::endgroup::"
99

1010
echo "::group::Install wheel"
11-
pip install --find-links ./wheelhouse --pre nipy
12-
pip install -r nipy/dev-requirements.txt
11+
$test_dep = python .\print_deps.py $env:MB_PYTHON_VERSION ${env:REPO_DIR} -p test
12+
pip install @($test_dep.split())
13+
pip install --find-links ./wheelhouse --pre nipy
1314
echo "::endgroup::"
1415

1516
echo "::group::Test wheel"
16-
python --version
17-
pytest --doctest-plus --pyargs nipy
17+
python --version
18+
pytest --doctest-plus --pyargs nipy
1819
echo "::endgroup::"

.github/workflows/build.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ echo "::group::Build wheel"
3232
ls -l "${GITHUB_WORKSPACE}/${WHEEL_SDIR}/"
3333
echo "::endgroup::"
3434

35-
if [[ $MACOSX_DEPLOYMENT_TARGET != "11.0" ]]; then
36-
echo "::group::Test wheel"
37-
install_run
38-
echo "::endgroup::"
39-
fi
35+
echo "::group::Test wheel"
36+
export TEST_DEPENDS=$(python ./print_deps.py ${MB_PYTHON_VERSION} ${REPO_DIR} -p test)
37+
install_run
38+
echo "::endgroup::"

.github/workflows/wheels-linux.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212

1313
env:
1414
REPO_DIR: nipy
15-
TEST_DEPENDS: "-r nipy/dev-requirements.txt"
1615

1716
jobs:
1817
build:

.github/workflows/wheels-macos.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212

1313
env:
1414
REPO_DIR: nipy
15-
TEST_DEPENDS: "-r nipy/dev-requirements.txt"
1615

1716
jobs:
1817
build:

print_deps.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
import tomlkit
1010

1111

12-
def get_build_requirements(repo_path):
12+
def get_phase_requirements(repo_path, phase='build'):
1313
toml = (Path(repo_path) / 'pyproject.toml').read_text()
1414
config = tomlkit.loads(toml)
15-
requires = config.get('build-system', {}).get('requires', [])
15+
if phase == 'build':
16+
requires = config.get('build-system', {}).get('requires', [])
17+
else:
18+
dep_dict =config.get('project', {}).get('optional-dependencies', {})
19+
requires = dep_dict.get('default', []) + dep_dict.get(phase, [])
1620
base_req = [R for R in requires if not 'numpy' in R]
1721
return ' '.join(base_req)
1822

@@ -36,15 +40,17 @@ def get_parser():
3640
formatter_class=RawDescriptionHelpFormatter)
3741
parser.add_argument("py_ver", help='Python version e.g. 3.11')
3842
parser.add_argument("repo_dir", help='Path to source repo')
43+
parser.add_argument('-p', '--phase', default='build',
44+
help='Phase ("build" or "test")')
3945
return parser
4046

4147

4248
def main():
4349
parser = get_parser()
4450
args = parser.parse_args()
51+
base = get_phase_requirements(args.repo_dir, args.phase)
4552
np_req = get_numpy_requirement(args.py_ver)
46-
build_base = get_build_requirements(args.repo_dir)
47-
print(f'{build_base} numpy=={np_req}')
53+
print(f'numpy=={np_req} {base}')
4854

4955

5056
if __name__ == '__main__':

0 commit comments

Comments
 (0)