Skip to content

Commit

Permalink
PR #74090: Removing distutils leftover
Browse files Browse the repository at this point in the history
Imported from GitHub PR tensorflow/tensorflow#74090

This aims to finish #58073. The patch is untested but follow https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html.
I did not touch the install scripts.

Thanks,
Copybara import of the project:

--
fe3c0659eb168dc155f7d579255953dfc89b1387 by Alexis Praga <[email protected]>:

Removing distutils leftover

--
57c24de0b367dd3ba78211f08ef4397014cff48f by Alexis Praga <[email protected]>:

Fix linter error

--
9476971caa2e5805cecdfcad9b0f5a7f0e331d9e by Alexis Praga <[email protected]>:

Correcting import order for linter

Shutil mainly

--
d74adacac6e544d75b6446d5565ec85bb4f25b6f by Alexis Praga <[email protected]>:

Fix conflict between sysconfig

__init__py has :
  from tensorflow._api.v2 import sysconfig
which conflict with python sysconfig

Merging this change closes #74090

Reverts changelist a CL rolling back a previous version of this PR

PiperOrigin-RevId: 681589525
  • Loading branch information
apraga authored and Google-ML-Automation committed Oct 2, 2024
1 parent 1a1bfe0 commit bed2300
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
10 changes: 2 additions & 8 deletions third_party/tsl/third_party/gpus/check_cuda_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@
import os
import os.path
import platform
import shutil
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
# pylint: enable=g-import-not-at-top,g-importing-member


class ConfigError(Exception):
pass
Expand All @@ -59,7 +53,7 @@ def check_cuda_lib(path, check_soname=True):
"""
if not os.path.isfile(path):
raise ConfigError("No library found under: " + path)
objdump = which("objdump")
objdump = shutil.which("objdump")
if check_soname and objdump is not None and not _is_windows():
# Decode is necessary as in py3 the return type changed from str to bytes
output = subprocess.check_output([objdump, "-p", path]).decode("utf-8")
Expand Down
12 changes: 3 additions & 9 deletions third_party/tsl/third_party/gpus/find_cuda_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,15 @@
tf_<library>_library_dir: ...
"""

import glob
import io
import os
import glob
import platform
import re
import shutil
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
# pylint: enable=g-import-not-at-top


class ConfigError(Exception):
pass
Expand Down Expand Up @@ -139,7 +133,7 @@ def _get_ld_config_paths():
"""Returns all directories from 'ldconfig -p'."""
if not _is_linux():
return []
ldconfig_path = which("ldconfig") or "/sbin/ldconfig"
ldconfig_path = shutil.which("ldconfig") or "/sbin/ldconfig"
output = subprocess.check_output([ldconfig_path, "-p"])
pattern = re.compile(".* => (.*)")
result = set()
Expand Down

0 comments on commit bed2300

Please sign in to comment.