@@ -34,16 +34,22 @@ def build_dist(dist_dir, clean=True):
34
34
util .run (f"python setup.py bdist_wheel --dist-dir { dest } " , quiet = True )
35
35
36
36
37
- def check_dist (dist_file , test_cmd = "" ):
37
+ def check_dist (dist_file , test_cmd = "" , python_imports = None ):
38
38
"""Check a Python package locally (not as a cli)"""
39
39
dist_file = util .normalize_path (dist_file )
40
40
util .run (f"twine check { dist_file } " )
41
41
42
- if not test_cmd :
42
+ test_commands = []
43
+
44
+ if test_cmd :
45
+ test_commands .append (test_cmd )
46
+ elif python_imports is not None :
47
+ test_commands .extend ([f'python -c "import { name } "' for name in python_imports ])
48
+ else :
43
49
# Get the package name from the dist file name
44
50
name = re .match (r"(\S+)-\d" , osp .basename (dist_file )).groups ()[0 ]
45
51
name = name .replace ("-" , "_" )
46
- test_cmd = f'python -c "import { name } "'
52
+ test_commands . append ( f'python -c "import { name } "' )
47
53
48
54
# Create venvs to install dist file
49
55
# run the test command in the venv
@@ -60,11 +66,12 @@ def check_dist(dist_file, test_cmd=""):
60
66
util .run (f"{ bin_path } /python -m pip install -q -U pip" )
61
67
util .run (f"{ bin_path } /pip install -q { dist_file } " )
62
68
try :
63
- util .run (f"{ bin_path } /{ test_cmd } " )
69
+ for cmd in test_commands :
70
+ util .run (f"{ bin_path } /{ cmd } " )
64
71
except CalledProcessError as e :
65
72
if test_cmd == "" :
66
73
util .log (
67
- 'You may need to set "python_target " to an appropriate Python package name in the config file.'
74
+ 'You may need to set "check_imports " to appropriate Python package names in the config file.'
68
75
)
69
76
raise e
70
77
0 commit comments