[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-04-13 00:00:18 +00:00
parent 72ad6dc953
commit f4cd1ba0d6
813 changed files with 66015 additions and 58839 deletions

View file

@ -1,14 +1,17 @@
from distutils.util import convert_path
from distutils import log
from distutils.errors import DistutilsError, DistutilsOptionError
import os
from __future__ import annotations
import glob
import io
import os
import pkg_resources
from setuptools.command.easy_install import easy_install
from setuptools import namespaces
import setuptools
from distutils import log
from distutils.errors import DistutilsError
from distutils.errors import DistutilsOptionError
from distutils.util import convert_path
from setuptools import namespaces
from setuptools.command.easy_install import easy_install
class develop(namespaces.DevelopInstaller, easy_install):
@ -17,8 +20,8 @@ class develop(namespaces.DevelopInstaller, easy_install):
description = "install package in 'development mode'"
user_options = easy_install.user_options + [
("uninstall", "u", "Uninstall this source package"),
("egg-path=", None, "Set the path to be used in the .egg-link file"),
('uninstall', 'u', 'Uninstall this source package'),
('egg-path=', None, 'Set the path to be used in the .egg-link file'),
]
boolean_options = easy_install.boolean_options + ['uninstall']
@ -42,7 +45,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
self.always_copy_from = '.' # always copy eggs installed in curdir
def finalize_options(self):
ei = self.get_finalized_command("egg_info")
ei = self.get_finalized_command('egg_info')
if ei.broken_egg_info:
template = "Please rename %r to %r before using 'develop'"
args = ei.egg_info, ei.broken_egg_info
@ -63,12 +66,12 @@ class develop(namespaces.DevelopInstaller, easy_install):
target = pkg_resources.normalize_path(self.egg_base)
egg_path = pkg_resources.normalize_path(
os.path.join(self.install_dir, self.egg_path)
os.path.join(self.install_dir, self.egg_path),
)
if egg_path != target:
raise DistutilsOptionError(
"--egg-path must be a relative path from the install"
" directory to " + target
'--egg-path must be a relative path from the install'
' directory to ' + target,
)
# Make a distribution for the package's source
@ -95,12 +98,12 @@ class develop(namespaces.DevelopInstaller, easy_install):
if path_to_setup != os.curdir:
path_to_setup = '../' * (path_to_setup.count('/') + 1)
resolved = pkg_resources.normalize_path(
os.path.join(install_dir, egg_path, path_to_setup)
os.path.join(install_dir, egg_path, path_to_setup),
)
if resolved != pkg_resources.normalize_path(os.curdir):
raise DistutilsOptionError(
"Can't get a consistent path to setup script from"
" installation directory",
' installation directory',
resolved,
pkg_resources.normalize_path(os.curdir),
)
@ -120,22 +123,22 @@ class develop(namespaces.DevelopInstaller, easy_install):
self.install_namespaces()
# create an .egg-link in the installation dir, pointing to our egg
log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
log.info('Creating %s (link to %s)', self.egg_link, self.egg_base)
if not self.dry_run:
with open(self.egg_link, "w") as f:
f.write(self.egg_path + "\n" + self.setup_path)
with open(self.egg_link, 'w') as f:
f.write(self.egg_path + '\n' + self.setup_path)
# postprocess the installed distro, fixing up .pth, installing scripts,
# and handling requirements
self.process_distribution(None, self.dist, not self.no_deps)
def uninstall_link(self):
if os.path.exists(self.egg_link):
log.info("Removing %s (link to %s)", self.egg_link, self.egg_base)
log.info('Removing %s (link to %s)', self.egg_link, self.egg_base)
egg_link_file = open(self.egg_link)
contents = [line.rstrip() for line in egg_link_file]
egg_link_file.close()
if contents not in ([self.egg_path], [self.egg_path, self.setup_path]):
log.warn("Link points to %s: uninstall aborted", contents)
log.warn('Link points to %s: uninstall aborted', contents)
return
if not self.dry_run:
os.unlink(self.egg_link)
@ -143,7 +146,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
self.update_pth(self.dist) # remove any .pth link to us
if self.distribution.scripts:
# XXX should also check for entry point scripts!
log.warn("Note: you must uninstall or replace scripts manually!")
log.warn('Note: you must uninstall or replace scripts manually!')
def install_egg_scripts(self, dist):
if dist is not self.dist:
@ -159,7 +162,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
for script_name in self.distribution.scripts or []:
script_path = os.path.abspath(convert_path(script_name))
script_name = os.path.basename(script_path)
with io.open(script_path) as strm:
with open(script_path) as strm:
script_text = strm.read()
self.install_script(dist, script_name, script_text, script_path)