From ff76871f4e4d727a4196ed0c28b362ccd52523c4 Mon Sep 17 00:00:00 2001 From: Teddy Date: Thu, 9 Oct 2025 19:30:29 +0200 Subject: [PATCH] replacing os.path with pathlib --- setup.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index e772828d4..d5985fc92 100755 --- a/setup.py +++ b/setup.py @@ -9,9 +9,8 @@ import re import ast import os -import os.path import sys - +from pathlib import Path # Add repo root to path so we can import scripts. Prior to PEP517 support this # was the default behavior for setuptools. # https://github.com/pypa/setuptools/issues/3939#issuecomment-1573619382 @@ -25,7 +24,7 @@ import setuptools try: - BASEDIR = os.path.dirname(os.path.realpath(__file__)) + BASEDIR = Path(__file__).resolve().parent except NameError: BASEDIR = None @@ -50,8 +49,8 @@ def _get_constant(name): The value of the argument. """ field_re = re.compile(r'__{}__\s+=\s+(.*)'.format(re.escape(name))) - path = os.path.join(BASEDIR, 'qutebrowser', '__init__.py') - line = field_re.search(read_file(path)).group(1) + init_path = BASEDIR / 'qutebrowser' / '__init__.py' + line = field_re.search(read_file(init_path)).group(1) value = ast.literal_eval(line) return value @@ -99,6 +98,6 @@ try: ) finally: if BASEDIR is not None: - path = os.path.join(BASEDIR, 'qutebrowser', 'git-commit-id') - if os.path.exists(path): - os.remove(path) + git_commit_id_path = BASEDIR / 'qutebrowser' / 'git-commit-id' + if git_commit_id_path.exists(): + git_commit_id_path.unlink()