Skip to content

Commit 1bccd86

Browse files
authored
Fix broken CI for package only PRs, make dateutil not strictly required (spack#24484)
* Force the Python interpreter with an env variable This commit forces the Python interpreter with an environment variable, to ensure that the Python set by the "setup-python" action is the one being used. Due to the policy adopted by Spack to prefer python3 over python we may end up picking a Python 3.X interpreter where Python 2.7 was meant to be used. * Revert "Update conftest.py (spack#24473)" This reverts commit 477c8ce. * Make python-dateutil a soft dependency for unit tests Before spack#23212 people could clone spack and run ``` spack unit-tests ``` while now this is not possible, since python-dateutil is a required but not vendored dependency. This change makes it not a hard requirement, i.e. it will be used if found in the current interpreter. * Workaround mypy complaint
1 parent 97f0c3c commit 1bccd86

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.github/workflows/unit_tests.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,16 @@ jobs:
156156
make -C ${KCOV_ROOT}/build && sudo make -C ${KCOV_ROOT}/build install
157157
- name: Bootstrap clingo from sources
158158
if: ${{ matrix.concretizer == 'clingo' }}
159+
env:
160+
SPACK_PYTHON: python
159161
run: |
160162
. share/spack/setup-env.sh
161163
spack external find --not-buildable cmake bison
162164
spack -v solve zlib
163165
- name: Run unit tests (full suite with coverage)
164166
if: ${{ needs.changes.outputs.with_coverage == 'true' }}
165167
env:
168+
SPACK_PYTHON: python
166169
COVERAGE: true
167170
SPACK_TEST_SOLVER: ${{ matrix.concretizer }}
168171
run: |
@@ -172,6 +175,7 @@ jobs:
172175
- name: Run unit tests (reduced suite without coverage)
173176
if: ${{ needs.changes.outputs.with_coverage == 'false' }}
174177
env:
178+
SPACK_PYTHON: python
175179
ONLY_PACKAGES: true
176180
SPACK_TEST_SOLVER: ${{ matrix.concretizer }}
177181
run: |

lib/spack/spack/test/conftest.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212
import os.path
1313
import re
1414
import shutil
15-
import sys
1615
import tempfile
1716
import xml.etree.ElementTree
1817

19-
if sys.version_info >= (3,):
18+
try:
2019
# CVS outputs dates in different formats on different systems. We are using
2120
# the dateutil package to parse these dates. This package does not exist
22-
# for Python 2.x. That means that we cannot test checkouts "by date" for
21+
# for Python <2.7. That means that we cannot test checkouts "by date" for
2322
# CVS respositories. (We can still use CVS repos with all features, only
2423
# our tests break.)
2524
from dateutil.parser import parse as parse_date
26-
else:
27-
def parse_date(string):
28-
pytest.skip("dateutil package not available for Python 2.6")
25+
except ImportError:
26+
def parse_date(string): # type: ignore
27+
pytest.skip("dateutil package not available")
2928

3029
import py
3130
import pytest

0 commit comments

Comments
 (0)