diff --git a/client/devpi/main.py b/client/devpi/main.py index 6b431606f..952ca29ac 100644 --- a/client/devpi/main.py +++ b/client/devpi/main.py @@ -6,6 +6,7 @@ import py import argparse import shlex +import shutil import subprocess import textwrap from base64 import b64encode @@ -391,10 +392,10 @@ def popen_output(self, args, cwd=None, report=True): args = [str(x) for x in args] if cwd is None: cwd = self.cwd - cmd = py.path.local.sysfind(args[0]) - if not cmd: + cmd = shutil.which(args[0]) + if cmd is None: self.fatal("command not found: %s" % args[0]) - args[0] = str(cmd) + args[0] = cmd if report: self.report_popen(args, cwd) encoding = sys.getdefaultencoding() diff --git a/client/devpi/test.py b/client/devpi/test.py index 124108f04..b64d100a3 100644 --- a/client/devpi/test.py +++ b/client/devpi/test.py @@ -3,7 +3,7 @@ import re import shlex import hashlib -import py +import shutil from devpi_common.archive import Archive from devpi_common.metadata import parse_requirement import json @@ -72,8 +72,8 @@ def runtox(self, link, pkg, sdist_pkg=None, upload_tox_results=True): "tox", venvdir=self.hub.venv, glob=True) if not tox_path: # try outside of venv - tox_path = py.path.local.sysfind("tox") - if not tox_path: + tox_path = shutil.which("tox") + if tox_path is None: self.hub.fatal("no tox binary found") toxcmd = [ str(tox_path), diff --git a/client/devpi/upload.py b/client/devpi/upload.py index 6a1ff5f09..80697ecd5 100644 --- a/client/devpi/upload.py +++ b/client/devpi/upload.py @@ -3,6 +3,7 @@ import sys import py import re +import shutil import zipfile import build.util @@ -386,7 +387,7 @@ def python(self): def _virtualenv_python(self): if 'VIRTUAL_ENV' in os.environ: - return py.path.local.sysfind("python") + return shutil.which("python") def __str__(self): return "" % self.rootpath diff --git a/client/devpi/use.py b/client/devpi/use.py index 6a33d8227..11c5cd24a 100644 --- a/client/devpi/use.py +++ b/client/devpi/use.py @@ -10,6 +10,7 @@ import py import re import json +import shutil from devpi_common.types import cached_property from devpi_common.url import URL @@ -360,9 +361,9 @@ def getvenvbin(self, name, venvdir=None, glob=True): venvdir = self.venvdir if venvdir: bindir = py.path.local(venvdir).join(vbin) - return py.path.local.sysfind(name, paths=[bindir]) + return shutil.which(name, path=str(bindir)) if glob: - return py.path.local.sysfind(name) + return shutil.which(name) @property def root_url(self): diff --git a/client/testing/conftest.py b/client/testing/conftest.py index cddad0e4d..f7990901a 100644 --- a/client/testing/conftest.py +++ b/client/testing/conftest.py @@ -9,6 +9,7 @@ import socket import textwrap import py +import shutil import sys import json import time @@ -101,10 +102,9 @@ def find_python3(): 'python3.9', 'python3'] for name in names: - path = py.path.local.sysfind(name) - if not path: + path = shutil.which(name) + if path is None: continue - path = str(path) try: print("Checking %s at %s" % (name, path)) output = subprocess.check_output([path, '--version']) @@ -132,10 +132,10 @@ def server_executable(request, tmpdir_factory): if not requirements: requirements = ['devpi-server>=6dev'] # first try installed devpi-server for quick runs during development - path = py.path.local.sysfind("devpi-server") - if path: + path = shutil.which("devpi-server") + if path is not None: print("server_executable: Using existing devpi-server at %s" % path) - return str(path) + return path # there is no devpi-server installed python3 = find_python3() # prepare environment for subprocess call diff --git a/client/testing/test_upload.py b/client/testing/test_upload.py index 6cc477359..1c21271f7 100644 --- a/client/testing/test_upload.py +++ b/client/testing/test_upload.py @@ -4,6 +4,7 @@ import py import pytest import re +import shutil import sys import tarfile from devpi.upload import Checkout @@ -28,7 +29,7 @@ def runproc(cmd): args = cmd.split() path0 = args[0] if not os.path.isabs(path0): - path0 = py.path.local.sysfind(path0) + path0 = shutil.which(path0) if not path0: pytest.skip("%r not found" % args[0]) return check_output([str(path0)] + args[1:]) @@ -75,7 +76,7 @@ def repo(self, request, setupdir_rel, tmpdir_factory): unicode_fn = str(unicode_fn, "utf8") setupdir.ensure(unicode_fn) if request.param == "hg": - if not py.path.local.sysfind("hg"): + if not shutil.which("hg"): pytest.skip("'hg' command not found") with repo.as_cwd(): runproc("hg init") @@ -84,7 +85,7 @@ def repo(self, request, setupdir_rel, tmpdir_factory): unicode_fn)) runproc("hg commit --config ui.username=whatever -m message") return repo - if not py.path.local.sysfind("git"): + if not shutil.which("git"): pytest.skip("'git' command not found") with repo.as_cwd(): runproc("git init") diff --git a/common/testing/test_archive.py b/common/testing/test_archive.py index 42ba1bf72..66a17c174 100644 --- a/common/testing/test_archive.py +++ b/common/testing/test_archive.py @@ -6,6 +6,7 @@ from subprocess import Popen, PIPE import py import pytest +import shutil import sys @@ -30,7 +31,7 @@ def _writedir(tmpdir, contentdict, prefixes=()): def create_tarfile_fromdict(tmpdir, contentdict): - tar = py.path.local.sysfind("tar") + tar = shutil.which("tar") if not tar: pytest.skip("tar command not found") if sys.platform.startswith('win'): diff --git a/server/test_devpi_server/conftest.py b/server/test_devpi_server/conftest.py index 779acacc1..087c5fcdd 100644 --- a/server/test_devpi_server/conftest.py +++ b/server/test_devpi_server/conftest.py @@ -9,6 +9,7 @@ import pytest import py import requests +import shutil import socket import sys import time @@ -1027,10 +1028,10 @@ def server_directory(): @pytest.fixture(scope="module") def call_devpi_in_dir(): # let xproc find the correct executable instead of py.test - devpigenconfig = str(py.path.local.sysfind("devpi-gen-config")) - devpiimport = str(py.path.local.sysfind("devpi-import")) - devpiinit = str(py.path.local.sysfind("devpi-init")) - devpiserver = str(py.path.local.sysfind("devpi-server")) + devpigenconfig = shutil.which("devpi-gen-config") + devpiimport = shutil.which("devpi-import") + devpiinit = shutil.which("devpi-init") + devpiserver = shutil.which("devpi-server") def devpi(server_dir, args): from devpi_server.genconfig import genconfig @@ -1194,7 +1195,7 @@ def adjust_nginx_conf_content(content): def _nginx_host_port(host, port, call_devpi_in_dir, server_directory, adjust_nginx_conf_content): # let xproc find the correct executable instead of py.test - nginx = py.path.local.sysfind("nginx") + nginx = shutil.which("nginx") if nginx is None: pytest.skip("No nginx executable found.") nginx = str(nginx)