Skip to content

Commit 337edaa

Browse files
committed
add warning for running/installing on MS Windows
1 parent 99c8f1a commit 337edaa

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

cwltool/main.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import time
1414
import urllib
15+
import warnings
1516
from codecs import StreamWriter, getwriter
1617
from collections.abc import MutableMapping, MutableSequence
1718
from typing import (
@@ -1323,9 +1324,25 @@ def find_default_container(
13231324
return default_container
13241325

13251326

1326-
def run(*args, **kwargs):
1327-
# type: (*Any, **Any) -> None
1327+
def windows_check() -> None:
1328+
"""See if we are running on MS Windows and warn about the lack of support."""
1329+
if os.name == "nt":
1330+
warnings.warn(
1331+
"The CWL reference runner (cwltool) no longer supports running "
1332+
"CWL workflows natively on MS Windows as its previous MS Windows "
1333+
"support was incomplete and untested. Instead, please see "
1334+
"https://pypi.org/project/cwltool/#ms-windows-users "
1335+
"for instructions on running cwltool via "
1336+
"Windows Subsystem for Linux 2 (WSL2). If don't need to execute "
1337+
"CWL documents, then you can ignore this warning, but please "
1338+
"consider migrating to https://pypi.org/project/cwl-utils/ "
1339+
"for your CWL document processing needs."
1340+
)
1341+
1342+
1343+
def run(*args: Any, **kwargs: Any) -> None:
13281344
"""Run cwltool."""
1345+
windows_check()
13291346
signal.signal(signal.SIGTERM, _signal_handler)
13301347
try:
13311348
sys.exit(main(*args, **kwargs))

setup.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,24 @@
22
"""Setup for the reference implementation of the CWL standards."""
33
import os
44
import sys
5+
import warnings
56

67
import setuptools.command.egg_info as egg_info_cmd
78
from setuptools import setup
89

10+
if os.name == "nt":
11+
warnings.warn(
12+
"The CWL reference runner (cwltool) no longer supports running "
13+
"CWL workflows natively on MS Windows as its previous MS Windows "
14+
"support was incomplete and untested. Instead, please see "
15+
"https://pypi.org/project/cwltool/#ms-windows-users "
16+
"for instructions on running cwltool via "
17+
"Windows Subsystem for Linux 2 (WSL2). If don't need to execute "
18+
"CWL documents, then you can ignore this warning, but please "
19+
"consider migrating to https://pypi.org/project/cwl-utils/ "
20+
"for your CWL document processing needs."
21+
)
22+
923
SETUP_DIR = os.path.dirname(__file__)
1024
README = os.path.join(SETUP_DIR, "README.rst")
1125

tests/test_windows_warning.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Test user experience running on MS Windows."""
2+
3+
import os
4+
import warnings
5+
6+
import pytest
7+
8+
from cwltool import main
9+
10+
# Can't be just "import cwltool ; … cwltool.main.windows_check()"
11+
# needs a direct import to avoid path traversal after os.name is set to "nt"
12+
13+
14+
def test_windows_warning(monkeypatch: pytest.MonkeyPatch) -> None:
15+
"""Confirm that the windows warning is given."""
16+
with pytest.warns(UserWarning, match=r"Windows Subsystem for Linux 2"):
17+
# would normally just use the MonkeyPatch object directly
18+
# but if we don't use a context then os.name being "nt" causes problems
19+
# for pytest on non-Windows systems. So the context unravels the change
20+
# to os.name quickly, and then pytest will check for the desired warning
21+
with monkeypatch.context() as m:
22+
m.setattr(os, "name", "nt")
23+
main.windows_check()

0 commit comments

Comments
 (0)