Skip to content

Commit 00ace66

Browse files
committed
Move imports at the top of the file
1 parent cf93e55 commit 00ace66

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

tools/safety_checks.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
from typing import List
1515

1616
import packaging.version
17+
import pefile
18+
from auditwheel.elfutils import elf_find_versioned_symbols
19+
from auditwheel.lddtree import lddtree
20+
from elftools.elf.elffile import ELFFile
1721

1822

1923
def check_dll_architecture(path: str, x86=False):
2024
arch = '32bit' if x86 else '64bit'
2125
print(f'Checking if file {path} is {arch}...')
22-
try:
23-
import pefile
24-
except ImportError:
25-
print('Install pefile: pip install pefile')
26-
sys.exit(1)
2726

2827
if not os.path.exists(path):
2928
print(f'File {path} is missing!')
@@ -44,11 +43,6 @@ def check_dll_is_static(path: str, allowed_imports: List = None):
4443
"""
4544

4645
print(f'Checking if file {path} is static...')
47-
try:
48-
import pefile
49-
except ImportError:
50-
print('Install pefile: pip install pefile')
51-
sys.exit(1)
5246

5347
if not os.path.exists(path):
5448
print(f'File {path} is missing!')
@@ -72,12 +66,6 @@ def check_dll_is_static(path: str, allowed_imports: List = None):
7266
def check_so_architecture(path: str, x86=False):
7367
arch = '32bit' if x86 else '64bit'
7468
print(f'Checking if file {path} is {arch}...')
75-
try:
76-
import elftools
77-
except ImportError:
78-
print('Install elftools: pip install pyelftools')
79-
sys.exit(1)
80-
from elftools.elf.elffile import ELFFile
8169

8270
if not os.path.exists(path):
8371
print(f'File {path} is missing!')
@@ -130,15 +118,6 @@ def check_so_is_manylinux2014(path: str, allowed_imports: List = None):
130118
allowed_imports_lower.add(allowed_import)
131119

132120
print(f'Checking if file {path} is manylinux2014...')
133-
try:
134-
import auditwheel
135-
except ImportError:
136-
print('Install auditwheel: pip install auditwheel')
137-
sys.exit(1)
138-
139-
from auditwheel.lddtree import lddtree
140-
from auditwheel.elfutils import elf_find_versioned_symbols
141-
from elftools.elf.elffile import ELFFile
142121

143122
if not os.path.exists(path):
144123
print(f'File {path} is missing!')

0 commit comments

Comments
 (0)