Skip to content

Commit a4ce6ad

Browse files
committed
ci: configure tox to pass environment variables for PyTorch
tox's isolated environment blocks `USERNAME` by default, causing PyTorch's `torch._inductor` to fail during import when it calls `getpass.getuser()` for cache directory setup. Pass through username and temp directory variables, and set `TORCHINDUCTOR_CACHE_DIR` explicitly to avoid the getpass call. Fixes Windows Python 3.10/3.11 test failures.
1 parent 4fbdc7c commit a4ce6ad

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

.github/workflows/test_and_deploy.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
name: tests
55

6-
on:
6+
on:
77
push:
88
branches:
99
- main
@@ -14,7 +14,7 @@ on:
1414
- main
1515
workflow_dispatch:
1616

17-
jobs:
17+
jobs:
1818
test:
1919
name: ${{ matrix.platform }} py${{ matrix.python-version }}
2020
runs-on: ${{ matrix.platform }}
@@ -26,10 +26,12 @@ jobs:
2626

2727
steps:
2828
- uses: actions/checkout@v4
29+
2930
- name: Set up Python ${{ matrix.python-version }}
3031
uses: actions/setup-python@v5
3132
with:
3233
python-version: ${{ matrix.python-version }}
34+
3335
- name: Install dependencies
3436
run: |
3537
python -m pip install --upgrade pip
@@ -45,21 +47,25 @@ jobs:
4547

4648
deploy:
4749
# this will run when you have tagged a commit, starting with "v*"
48-
# and requires that you have put your twine API key in your
50+
# and requires that you have put your twine API key in your
4951
# github secrets (see readme for details)
5052
needs: [test]
5153
runs-on: ubuntu-latest
5254
if: contains(github.ref, 'tags')
55+
5356
steps:
5457
- uses: actions/checkout@v4
58+
5559
- name: Set up Python
56-
uses: actions/setup-python@v4
60+
uses: actions/setup-python@v5
5761
with:
5862
python-version: "3.x"
63+
5964
- name: Install dependencies
6065
run: |
6166
python -m pip install --upgrade pip
6267
pip install -U setuptools setuptools_scm wheel twine
68+
6369
- name: Build and publish
6470
env:
6571
TWINE_USERNAME: __token__

tox.ini

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,44 @@ python =
88
3.10: py310
99
3.11: py311
1010
fail_on_no_env = True
11-
11+
1212
[gh-actions:env]
1313
PLATFORM =
1414
ubuntu-latest: linux
1515
macos-latest: macos
1616
windows-latest: windows
1717

1818
[testenv]
19-
platform =
19+
platform =
2020
macos: darwin
2121
linux: linux
2222
windows: win32
23-
passenv =
23+
passenv =
2424
CI
2525
GITHUB_ACTIONS
2626
DISPLAY,XAUTHORITY
2727
NUMPY_EXPERIMENTAL_ARRAY_FUNCTION
2828
PYVISTA_OFF_SCREEN
29+
USERNAME
30+
USER
31+
LOGNAME
32+
LNAME
33+
TEMP
34+
TMP
35+
TMPDIR
36+
TORCHINDUCTOR_CACHE_DIR
37+
setenv =
38+
windows: TORCHINDUCTOR_CACHE_DIR = {env:TEMP}{/}torchinductor
39+
macos: TORCHINDUCTOR_CACHE_DIR = {env:TMPDIR}{/}torchinductor
40+
linux: TORCHINDUCTOR_CACHE_DIR = {env:TMPDIR:/tmp}{/}torchinductor
2941
extras = gui
30-
deps =
42+
deps =
3143
.[gui]
3244
py
3345
pytest
3446
pytest-cov
3547
pytest-xvfb
3648
# ignoring contrib tests for now
37-
commands =
49+
commands =
3850
#linux: apt-get update && apt-get install libgl1
3951
pytest -vv -rA --color=yes --cov=cellpose --cov-report=xml --ignore=tests/contrib --durations=0

0 commit comments

Comments
 (0)