mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 00:19:58 +01:00
Removing distutils leftover
This commit is contained in:
parent
2fe29379f6
commit
fe3c0659eb
|
|
@ -29,7 +29,6 @@ cat >pythons.txt <<EOF
|
|||
$VERSION
|
||||
$VERSION-dev
|
||||
$VERSION-venv
|
||||
$VERSION-distutils
|
||||
EOF
|
||||
/setup.packages.sh pythons.txt
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,7 @@ import subprocess
|
|||
import sys
|
||||
|
||||
# pylint: disable=g-import-not-at-top
|
||||
try:
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
from distutils.spawn import find_executable as which
|
||||
from shutil import which
|
||||
# pylint: enable=g-import-not-at-top
|
||||
|
||||
_DEFAULT_CUDA_COMPUTE_CAPABILITIES = '3.5,7.0'
|
||||
|
|
@ -164,8 +161,8 @@ def get_python_path(environ_cp, python_bin_path):
|
|||
library_paths = [
|
||||
run_shell([
|
||||
python_bin_path, '-c',
|
||||
'from distutils.sysconfig import get_python_lib;'
|
||||
'print(get_python_lib())'
|
||||
'import sysconfig;'
|
||||
'print(sysconfig.get_path("purelib")'
|
||||
])
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ this file with a file generated from [`api_template.__init__.py`](https://www.gi
|
|||
"""
|
||||
# pylint: disable=g-bad-import-order,protected-access,g-import-not-at-top
|
||||
|
||||
import distutils as _distutils
|
||||
import sysconfig
|
||||
import importlib
|
||||
import inspect as _inspect
|
||||
import os as _os
|
||||
|
|
@ -100,8 +100,9 @@ _site_packages_dirs += [p for p in _sys.path if "site-packages" in p]
|
|||
if "getsitepackages" in dir(_site):
|
||||
_site_packages_dirs += _site.getsitepackages()
|
||||
|
||||
if "sysconfig" in dir(_distutils):
|
||||
_site_packages_dirs += [_distutils.sysconfig.get_python_lib()]
|
||||
for scheme in sysconfig.get_scheme_names():
|
||||
for name in ['purelib', 'platlib']:
|
||||
_site_packages_dirs += [sysconfig.get_path(name, scheme)]
|
||||
|
||||
_site_packages_dirs = list(set(_site_packages_dirs))
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
# ==============================================================================
|
||||
"""Bring in all of the public TensorFlow interface into this module."""
|
||||
|
||||
import distutils as _distutils
|
||||
import importlib
|
||||
import sysconfig
|
||||
import inspect as _inspect
|
||||
import os as _os
|
||||
import site as _site
|
||||
|
|
@ -147,8 +147,9 @@ _site_packages_dirs += [p for p in _sys.path if "site-packages" in p]
|
|||
if "getsitepackages" in dir(_site):
|
||||
_site_packages_dirs += _site.getsitepackages()
|
||||
|
||||
if "sysconfig" in dir(_distutils):
|
||||
_site_packages_dirs += [_distutils.sysconfig.get_python_lib()]
|
||||
for scheme in sysconfig.get_scheme_names():
|
||||
for name in ['purelib', 'platlib']:
|
||||
_site_packages_dirs += [sysconfig.get_path(name, scheme)]
|
||||
|
||||
_site_packages_dirs = list(set(_site_packages_dirs))
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
# ==============================================================================
|
||||
"""Converts a frozen graph into a TFLite FlatBuffer."""
|
||||
|
||||
import distutils.spawn
|
||||
from shutil import which
|
||||
import enum
|
||||
import hashlib
|
||||
import os as _os
|
||||
|
|
@ -408,7 +408,7 @@ def _run_deprecated_conversion_binary(
|
|||
RuntimeError: When conversion fails, an exception is raised with the error
|
||||
message embedded.
|
||||
"""
|
||||
if distutils.spawn.find_executable(_deprecated_conversion_binary) is None:
|
||||
if which(_deprecated_conversion_binary) is None:
|
||||
raise ConverterError("""Could not find `toco_from_protos` binary, make sure
|
||||
your virtualenv bin directory or pip local bin directory is in your path.
|
||||
In particular, if you have installed TensorFlow with --user, make sure you
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ RUN apt-get update && \
|
|||
python$PYTHON_VERSION \
|
||||
python$PYTHON_VERSION-dev \
|
||||
python$PYTHON_VERSION-venv \
|
||||
python$PYTHON_VERSION-distutils \
|
||||
libpython$PYTHON_VERSION-dev \
|
||||
libpython$PYTHON_VERSION-dev:armhf \
|
||||
libpython$PYTHON_VERSION-dev:arm64
|
||||
|
|
|
|||
|
|
@ -25,12 +25,9 @@ from tensorflow.python.ops import manip_ops
|
|||
from tensorflow.python.platform import test as test_lib
|
||||
|
||||
# pylint: disable=g-import-not-at-top
|
||||
try:
|
||||
from distutils.version import StrictVersion as Version
|
||||
# numpy.roll for multiple shifts was introduced in numpy version 1.12.0
|
||||
NP_ROLL_CAN_MULTISHIFT = Version(np.version.version) >= Version("1.12.0")
|
||||
except ImportError:
|
||||
NP_ROLL_CAN_MULTISHIFT = False
|
||||
from packaging.version import StrictVersion as Version
|
||||
# numpy.roll for multiple shifts was introduced in numpy version 1.12.0
|
||||
NP_ROLL_CAN_MULTISHIFT = Version(np.version.version) >= Version("1.12.0")
|
||||
# pylint: enable=g-import-not-at-top
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@
|
|||
# ==============================================================================
|
||||
"""Tests for tensorflow.ops.math_ops.linspace."""
|
||||
|
||||
# Using distutils.version.LooseVersion was resulting in an error, so importing
|
||||
# directly.
|
||||
from distutils.version import LooseVersion # pylint: disable=g-importing-member
|
||||
from packaging.version import Version # pylint: disable=g-importing-member
|
||||
|
||||
from absl.testing import parameterized
|
||||
import numpy as np
|
||||
|
|
@ -47,7 +45,7 @@ class LinspaceTest(test_util.TensorFlowTestCase, parameterized.TestCase):
|
|||
])
|
||||
# pylint: enable=g-complex-comprehension
|
||||
def testLinspaceBroadcasts(self, start_shape, stop_shape, dtype, num):
|
||||
if LooseVersion(np.version.version) < LooseVersion("1.16.0"):
|
||||
if Version(np.version.version) < Version("1.16.0"):
|
||||
self.skipTest("numpy doesn't support axes before version 1.16.0")
|
||||
|
||||
ndims = max(len(start_shape), len(stop_shape))
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
# ==============================================================================
|
||||
"""NumPy test utilities."""
|
||||
from contextlib import contextmanager
|
||||
from distutils.util import strtobool
|
||||
import functools
|
||||
from functools import partial
|
||||
import re
|
||||
|
|
@ -49,6 +48,12 @@ tree_multimap = nest.map_structure
|
|||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
# https://danielms.site/zet/2023/pythons-distutil-strtobool-replacement/
|
||||
def strtobool(value: str) -> bool:
|
||||
value = value.lower()
|
||||
if value in ("y", "yes", "on", "1", "true", "t"):
|
||||
return True
|
||||
return False
|
||||
|
||||
# TODO(wangpeng): Remove this flag after broken tests are fixed
|
||||
flags.DEFINE_bool('enable_x64',
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import sys
|
|||
|
||||
from absl import app
|
||||
from absl import flags
|
||||
from distutils.version import LooseVersion
|
||||
from packaging.version import Version
|
||||
|
||||
from tensorflow.python.distribute.cluster_resolver import tpu_cluster_resolver as resolver
|
||||
from tensorflow.python.profiler import profiler_client
|
||||
|
|
@ -139,7 +139,7 @@ def main(unused_argv=None):
|
|||
print('TensorFlow version %s detected' % tf_version)
|
||||
print('Welcome to the Cloud TPU Profiler v%s' % profiler_version.__version__)
|
||||
|
||||
if LooseVersion(tf_version) < LooseVersion('2.2.0'):
|
||||
if Version(tf_version) < Version('2.2.0'):
|
||||
sys.exit('You must install tensorflow >= 2.2.0 to use this plugin.')
|
||||
|
||||
if not FLAGS.service_addr and not FLAGS.tpu:
|
||||
|
|
@ -188,7 +188,7 @@ def main(unused_argv=None):
|
|||
gfile.MakeDirs(FLAGS.logdir)
|
||||
|
||||
try:
|
||||
if LooseVersion(tf_version) < LooseVersion('2.3.0'):
|
||||
if Version(tf_version) < Version('2.3.0'):
|
||||
profiler_client.trace(service_addr, os.path.expanduser(FLAGS.logdir),
|
||||
duration_ms, workers_list,
|
||||
FLAGS.num_tracing_attempts)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ cat >pythons.txt <<EOF
|
|||
$VERSION
|
||||
$VERSION-dev
|
||||
$VERSION-venv
|
||||
$VERSION-distutils
|
||||
EOF
|
||||
/setup.packages.sh pythons.txt
|
||||
|
||||
|
|
|
|||
5
third_party/gpus/check_cuda_libs.py
vendored
5
third_party/gpus/check_cuda_libs.py
vendored
|
|
@ -31,10 +31,7 @@ import subprocess
|
|||
import sys
|
||||
|
||||
# pylint: disable=g-import-not-at-top,g-importing-member
|
||||
try:
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
from distutils.spawn import find_executable as which
|
||||
from shutil import which
|
||||
# pylint: enable=g-import-not-at-top,g-importing-member
|
||||
|
||||
|
||||
|
|
|
|||
5
third_party/gpus/find_cuda_config.py
vendored
5
third_party/gpus/find_cuda_config.py
vendored
|
|
@ -65,10 +65,7 @@ import subprocess
|
|||
import sys
|
||||
|
||||
# pylint: disable=g-import-not-at-top
|
||||
try:
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
from distutils.spawn import find_executable as which
|
||||
from shutil import which
|
||||
# pylint: enable=g-import-not-at-top
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,7 @@ import subprocess
|
|||
import sys
|
||||
|
||||
# pylint: disable=g-import-not-at-top,g-importing-member
|
||||
try:
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
from distutils.spawn import find_executable as which
|
||||
from shutil import which
|
||||
# pylint: enable=g-import-not-at-top,g-importing-member
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,10 +65,7 @@ import subprocess
|
|||
import sys
|
||||
|
||||
# pylint: disable=g-import-not-at-top
|
||||
try:
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
from distutils.spawn import find_executable as which
|
||||
from shutil import which
|
||||
# pylint: enable=g-import-not-at-top
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user