Skip to content

Commit b1e1969

Browse files
committed
Creating a script instead of code duplication
1 parent 2eff24c commit b1e1969

File tree

2 files changed

+25
-64
lines changed

2 files changed

+25
-64
lines changed

.github/scripts/smoke_depthai.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os, sys, traceback, platform
2+
3+
try:
4+
import depthai as dai
5+
except Exception:
6+
traceback.print_exc()
7+
sys.exit(1)
8+
9+
expected = os.environ.get("EXPECTED_VERSION") or os.environ.get("ver")
10+
installed = getattr(dai, "__version__", "<unknown>")
11+
if installed != expected:
12+
print(f"Version mismatch: installed {installed} vs expected {expected}", file=sys.stderr)
13+
sys.exit(1)
14+
15+
print("depthai:", installed)
16+
print("python:", platform.python_version(), "ABI:", sys.implementation.cache_tag)

.github/workflows/python-main.yml

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -414,30 +414,13 @@ jobs:
414414
415415
# Install from Artifactory snapshot
416416
python -m pip install -U pip
417-
python -m pip uninstall -y depthai || true
418-
python -m pip install -U --prefer-binary \
417+
python -m pip install --force-reinstall -U --prefer-binary \
419418
--extra-index-url "$ARTIFACTORY_URL/luxonis-python-snapshot-local" \
420419
"depthai==$ver" \
421420
--trusted-host 3.145.46.25
422421
423-
# Smoke test: fail hard on any exception or version mismatch
424-
ver="$ver" "$PYBIN" - <<'PY'
425-
import os, sys, traceback, platform
426-
try:
427-
import depthai as dai
428-
except Exception:
429-
traceback.print_exc()
430-
sys.exit(1)
431-
432-
expected = os.environ["ver"] # read the env var you passed in
433-
installed = getattr(dai, "__version__", "<unknown>")
434-
if installed != expected:
435-
print(f"Version mismatch: installed {installed} vs expected {expected}", file=sys.stderr)
436-
sys.exit(1)
437-
438-
print("depthai:", installed)
439-
print("python:", platform.python_version(), "ABI:", sys.implementation.cache_tag)
440-
PY
422+
EXPECTED_VERSION="$ver" python .github/scripts/smoke_depthai.py
423+
441424
# This job builds wheels for x86_64 arch
442425
build-linux-x86_64:
443426
needs: build-docstrings
@@ -559,27 +542,10 @@ jobs:
559542
# Install from Artifactory snapshot
560543
"$PYBIN" -m ensurepip --upgrade || true
561544
"$PYBIN" -m pip install -U pip
562-
"$PYBIN" -m pip uninstall -y depthai || true
563-
"$PYBIN" -m pip install -U --prefer-binary --extra-index-url "$ARTIFACTORY_URL/luxonis-python-snapshot-local" "depthai==$ver" --trusted-host 3.145.46.25
545+
"$PYBIN" -m pip install --force-reinstall -U --prefer-binary --extra-index-url "$ARTIFACTORY_URL/luxonis-python-snapshot-local" "depthai==$ver" --trusted-host 3.145.46.25
564546
565547
# Smoke test: fail hard on any exception or version mismatch
566-
ver="$ver" "$PYBIN" - <<'PY'
567-
import os, sys, traceback, platform
568-
try:
569-
import depthai as dai
570-
except Exception:
571-
traceback.print_exc()
572-
sys.exit(1)
573-
574-
expected = os.environ["ver"] # read the env var you passed in
575-
installed = getattr(dai, "__version__", "<unknown>")
576-
if installed != expected:
577-
print(f"Version mismatch: installed {installed} vs expected {expected}", file=sys.stderr)
578-
sys.exit(1)
579-
580-
print("depthai:", installed)
581-
print("python:", platform.python_version(), "ABI:", sys.implementation.cache_tag)
582-
PY
548+
EXPECTED_VERSION="$ver" python .github/scripts/smoke_depthai.py
583549
584550
# This job builds wheels for ARM64 arch
585551
build-linux-arm64:
@@ -704,27 +670,9 @@ jobs:
704670
# Install from Artifactory snapshot
705671
"$PYBIN" -m ensurepip --upgrade || true
706672
"$PYBIN" -m pip install -U pip
707-
"$PYBIN" -m pip uninstall -y depthai || true
708-
"$PYBIN" -m pip install -U --prefer-binary --extra-index-url "$ARTIFACTORY_URL/luxonis-python-snapshot-local" "depthai==$ver" --trusted-host 3.145.46.25
673+
"$PYBIN" -m pip install --force-reinstall -U --prefer-binary --extra-index-url "$ARTIFACTORY_URL/luxonis-python-snapshot-local" "depthai==$ver" --trusted-host 3.145.46.25
709674
710-
# Smoke test: fail hard on any exception or version mismatch
711-
ver="$ver" "$PYBIN" - <<'PY'
712-
import os, sys, traceback, platform
713-
try:
714-
import depthai as dai
715-
except Exception:
716-
traceback.print_exc()
717-
sys.exit(1)
718-
719-
expected = os.environ["ver"] # read the env var you passed in
720-
installed = getattr(dai, "__version__", "<unknown>")
721-
if installed != expected:
722-
print(f"Version mismatch: installed {installed} vs expected {expected}", file=sys.stderr)
723-
sys.exit(1)
724-
725-
print("depthai:", installed)
726-
print("python:", platform.python_version(), "ABI:", sys.implementation.cache_tag)
727-
PY
675+
EXPECTED_VERSION="$ver" "$PYBIN" .github/scripts/smoke_depthai.py
728676
729677
combine-windows-x86_64-wheels:
730678
needs: build-windows-x86_64
@@ -777,16 +725,13 @@ jobs:
777725
778726
# Install from Artifactory snapshot
779727
python -m pip install -U pip
780-
python -m pip uninstall -y depthai 2>$null | Out-Null
781-
python -m pip install -U --prefer-binary `
728+
python -m pip install --force-reinstall -U --prefer-binary `
782729
--extra-index-url "$env:ARTIFACTORY_URL/luxonis-python-snapshot-local" `
783730
"depthai==$ver" `
784731
--trusted-host 3.145.46.25
785732
786733
# Smoke test (no heredoc; YAML-safe). Fail on import error or version mismatch.
787-
$env:EXPECTED_VERSION = $ver
788-
python -c "import os,sys,platform; import depthai as d; e=os.environ['EXPECTED_VERSION']; i=getattr(d,'__version__','<unknown>'); assert i==e, f'Version mismatch: {i} vs {e}'; print('depthai:', i); print('python:', platform.python_version(), 'ABI:', sys.implementation.cache_tag)"
789-
734+
$env:EXPECTED_VERSION = $ver "python .github/scripts/smoke_depthai.py
790735
release:
791736
if: startsWith(github.ref, 'refs/tags/v')
792737
# needs: [pytest, build-linux-armhf, build-windows-x86_64, build-macos-x86_64, build-macos-arm64, build-linux-x86_64, build-linux-arm64]

0 commit comments

Comments
 (0)