Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
b56a27b5
"src/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "5308cce994ffb1b2c169d62a8f49d445442dff47"
Unverified
Commit
b56a27b5
authored
Jun 04, 2020
by
moto
Committed by
GitHub
Jun 04, 2020
Browse files
Remove Py2 code from common_utils (#691)
parent
87ca9e99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
25 deletions
+4
-25
torchaudio/common_utils.py
torchaudio/common_utils.py
+4
-25
No files found.
torchaudio/common_utils.py
View file @
b56a27b5
import
sys
import
importlib.util
PY3
=
sys
.
version_info
>
(
3
,
0
)
PY34
=
sys
.
version_info
>=
(
3
,
4
)
def
_check_module_exists
(
name
:
str
)
->
bool
:
def
_check_module_exists
(
name
:
str
)
->
bool
:
...
@@ -11,28 +8,10 @@ def _check_module_exists(name: str) -> bool:
...
@@ -11,28 +8,10 @@ def _check_module_exists(name: str) -> bool:
our tests, e.g., setting multiprocessing start method when imported
our tests, e.g., setting multiprocessing start method when imported
(see librosa/#747, torchvision/#544).
(see librosa/#747, torchvision/#544).
"""
"""
if
not
PY3
:
# Python 2
spec
=
importlib
.
util
.
find_spec
(
name
)
import
imp
return
spec
is
not
None
try
:
imp
.
find_module
(
name
)
return
True
except
ImportError
:
return
False
elif
not
PY34
:
# Python [3, 3.4)
import
importlib
loader
=
importlib
.
find_loader
(
name
)
return
loader
is
not
None
else
:
# Python >= 3.4
import
importlib
import
importlib.util
spec
=
importlib
.
util
.
find_spec
(
name
)
return
spec
is
not
None
IMPORT_NUMPY
=
_check_module_exists
(
'numpy'
)
IMPORT_NUMPY
=
_check_module_exists
(
'numpy'
)
IMPORT_KALDI_IO
=
_check_module_exists
(
'kaldi_io'
)
IMPORT_KALDI_IO
=
_check_module_exists
(
'kaldi_io'
)
IMPORT_SCIPY
=
_check_module_exists
(
'scipy'
)
IMPORT_SCIPY
=
_check_module_exists
(
'scipy'
)
IMPORT_LIBROSA
=
_check_module_exists
(
'librosa'
)
# On Py2, importing librosa 0.6.1 triggers a TypeError (if using newest joblib)
# see librosa/librosa#729.
# TODO: allow Py2 when librosa 0.6.2 releases
IMPORT_LIBROSA
=
_check_module_exists
(
'librosa'
)
and
PY3
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment