Skip to content

Commit

Permalink
[NFC] Remove dead code related to using of subprocess.check_call (#…
Browse files Browse the repository at this point in the history
…5537)

According to
https://docs.python.org/3.9/library/subprocess.html#subprocess.check_call:
`If the return code was zero then return, otherwise raise
CalledProcessError.`

---------

Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev authored Jan 7, 2025
1 parent 126a7e1 commit 82625a5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 81 deletions.
36 changes: 1 addition & 35 deletions python/test/backend/test_device_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import tempfile
from pathlib import Path

import setuptools
import torch

import triton
import triton.language as tl
from triton.common.backend import (BaseBackend, compute_core_version_key, register_backend)
from triton.common.build import quiet
from triton.compiler.make_launcher import make_so_cache_key
from triton.runtime.cache import get_cache_manager
from triton.runtime.driver import DriverBase
Expand Down Expand Up @@ -43,39 +41,7 @@ def build_for_backend(name, src, srcdir):
scheme = 'posix_prefix'
py_include_dir = sysconfig.get_paths(scheme=scheme)["include"]

ret = subprocess.check_call([cc, src, f"-I{py_include_dir}", f"-I{srcdir}", "-shared", "-fPIC", "-o", so])
if ret == 0:
return so
# fallback on setuptools
extra_compile_args = []
library_dirs = []
include_dirs = [srcdir]
libraries = []
# extra arguments
extra_link_args = []
# create extension module
ext = setuptools.Extension(
name=name,
language='c',
sources=[src],
include_dirs=include_dirs,
extra_compile_args=extra_compile_args + ['-O3'],
extra_link_args=extra_link_args,
library_dirs=library_dirs,
libraries=libraries,
)
# build extension module
args = ['build_ext']
args.append('--build-temp=' + srcdir)
args.append('--build-lib=' + srcdir)
args.append('-q')
args = dict(
name=name,
ext_modules=[ext],
script_args=args,
)
with quiet():
setuptools.setup(**args)
subprocess.check_call([cc, src, f"-I{py_include_dir}", f"-I{srcdir}", "-shared", "-fPIC", "-o", so])
return so


Expand Down
45 changes: 1 addition & 44 deletions python/triton/runtime/build.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import contextlib
import sys
import io
import sysconfig
import os
import shutil
import subprocess
import setuptools


@contextlib.contextmanager
def quiet():
old_stdout, old_stderr = sys.stdout, sys.stderr
sys.stdout, sys.stderr = io.StringIO(), io.StringIO()
try:
yield
finally:
sys.stdout, sys.stderr = old_stdout, old_stderr


def _build(name, src, srcdir, library_dirs, include_dirs, libraries):
Expand Down Expand Up @@ -47,34 +33,5 @@ def _build(name, src, srcdir, library_dirs, include_dirs, libraries):
cc_cmd += [f'-l{lib}' for lib in libraries]
cc_cmd += [f"-L{dir}" for dir in library_dirs]
cc_cmd += [f"-I{dir}" for dir in include_dirs if dir is not None]
ret = subprocess.check_call(cc_cmd)
if ret == 0:
return so
# fallback on setuptools
extra_compile_args = []
# extra arguments
extra_link_args = []
# create extension module
ext = setuptools.Extension(
name=name,
language='c',
sources=[src],
include_dirs=include_dirs,
extra_compile_args=extra_compile_args + ['-O3'],
extra_link_args=extra_link_args,
library_dirs=library_dirs,
libraries=libraries,
)
# build extension module
args = ['build_ext']
args.append('--build-temp=' + srcdir)
args.append('--build-lib=' + srcdir)
args.append('-q')
args = dict(
name=name,
ext_modules=[ext],
script_args=args,
)
with quiet():
setuptools.setup(**args)
subprocess.check_call(cc_cmd, stdout=subprocess.DEVNULL)
return so
3 changes: 1 addition & 2 deletions third_party/proton/test/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

def test_help():
# Only check if the viewer can be invoked
ret = subprocess.check_call(["proton-viewer", "-h"], stdout=subprocess.DEVNULL)
assert ret == 0
subprocess.check_call(["proton-viewer", "-h"], stdout=subprocess.DEVNULL)


def test_sort():
Expand Down

0 comments on commit 82625a5

Please sign in to comment.