Skip to content

Commit

Permalink
Put test dependencies into print_deps
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-brett committed Nov 10, 2023
1 parent db69dad commit c3fde55
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
9 changes: 4 additions & 5 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
1 change: 0 additions & 1 deletion .github/workflows/wheels-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:

env:
REPO_DIR: nipy
TEST_DEPENDS: "-r nipy/dev-requirements.txt"

jobs:
build:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/wheels-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:

env:
REPO_DIR: nipy
TEST_DEPENDS: "-r nipy/dev-requirements.txt"

jobs:
build:
Expand Down
14 changes: 10 additions & 4 deletions print_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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__':
Expand Down

0 comments on commit c3fde55

Please sign in to comment.