Bump linters (#1823)
This commit is contained in:
parent
b8ded22edb
commit
11d922b85f
44 changed files with 188 additions and 160 deletions
|
|
@ -1,52 +1,61 @@
|
|||
repos:
|
||||
- repo: https://github.com/ambv/black
|
||||
rev: 19.10b0
|
||||
hooks:
|
||||
- id: black
|
||||
args: [--safe]
|
||||
language_version: python3.8
|
||||
- repo: https://github.com/asottile/blacken-docs
|
||||
rev: v1.6.0
|
||||
hooks:
|
||||
- id: blacken-docs
|
||||
additional_dependencies: [black==19.10b0]
|
||||
language_version: python3.8
|
||||
- repo: https://github.com/asottile/seed-isort-config
|
||||
rev: v2.1.1
|
||||
hooks:
|
||||
- id: seed-isort-config
|
||||
args: [--application-directories, '.:src']
|
||||
- repo: https://github.com/pre-commit/mirrors-isort
|
||||
rev: v4.3.21
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
- id: check-merge-conflict
|
||||
- id: trailing-whitespace
|
||||
- id: check-docstring-first
|
||||
- id: check-ast
|
||||
- id: check-docstring-first
|
||||
- id: check-toml
|
||||
- id: check-toml
|
||||
- id: flake8
|
||||
additional_dependencies: ["flake8-bugbear == 20.1.2"]
|
||||
language_version: python3.8
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||
rev: v1.5.1
|
||||
hooks:
|
||||
- id: rst-backticks
|
||||
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||
rev: v1.9.0
|
||||
hooks:
|
||||
- id: setup-cfg-fmt
|
||||
args: [--min-py3-version, "3.4"]
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: check-ast
|
||||
- id: check-builtin-literals
|
||||
- id: check-docstring-first
|
||||
- id: check-merge-conflict
|
||||
- id: check-yaml
|
||||
- id: check-toml
|
||||
- id: debug-statements
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/asottile/add-trailing-comma
|
||||
rev: v2.0.1
|
||||
hooks:
|
||||
- id: add-trailing-comma
|
||||
- repo: https://github.com/asottile/yesqa
|
||||
rev: v1.1.0
|
||||
hooks:
|
||||
- id: yesqa
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.4.1
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
- repo: https://github.com/asottile/seed-isort-config
|
||||
rev: v2.1.1
|
||||
hooks:
|
||||
- id: seed-isort-config
|
||||
args: [--application-directories, '.:src']
|
||||
- repo: https://github.com/pre-commit/mirrors-isort
|
||||
rev: v4.3.21
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/ambv/black
|
||||
rev: 19.10b0
|
||||
hooks:
|
||||
- id: black
|
||||
args: [--safe]
|
||||
language_version: python3.8
|
||||
- repo: https://github.com/asottile/blacken-docs
|
||||
rev: v1.7.0
|
||||
hooks:
|
||||
- id: blacken-docs
|
||||
additional_dependencies: [black==19.10b0]
|
||||
language_version: python3.8
|
||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||
rev: v1.5.1
|
||||
hooks:
|
||||
- id: rst-backticks
|
||||
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||
rev: v1.9.0
|
||||
hooks:
|
||||
- id: setup-cfg-fmt
|
||||
args: [--min-py3-version, "3.4"]
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: "3.8.1"
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies: ["flake8-bugbear == 20.1.2"]
|
||||
language_version: python3.8
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ class CliTable(SphinxDirective):
|
|||
if core_names:
|
||||
rows = [i for i in next(iter(results.values())) if tuple(i["name"]) in core_names]
|
||||
content.append(
|
||||
self._build_table(rows, title="core", description="options shared across all {}".format(key))
|
||||
self._build_table(rows, title="core", description="options shared across all {}".format(key)),
|
||||
)
|
||||
for name, group in results.items():
|
||||
rows = [i for i in group if tuple(i["name"]) not in core_names]
|
||||
if rows:
|
||||
content.append(
|
||||
self._build_table(rows, title=name, description="options specific to {} {}".format(key, name))
|
||||
self._build_table(rows, title=name, description="options specific to {} {}".format(key, name)),
|
||||
)
|
||||
return content
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,10 @@ build-backend = 'setuptools.build_meta'
|
|||
line-length = 120
|
||||
|
||||
[tool.towncrier]
|
||||
package = "virtualenv"
|
||||
package_dir = "" # we purposfully do not set this as src, forcing import from site-package that has version.py
|
||||
filename = "docs/changelog.rst"
|
||||
directory = "docs/changelog"
|
||||
title_format = false
|
||||
issue_format = "`#{issue} <https://github.com/pypa/virtualenv/issues/{issue}>`_"
|
||||
template = "docs/changelog/template.jinja2"
|
||||
# possible types, all default: feature, bugfix, doc, removal, misc
|
||||
package = "virtualenv"
|
||||
package_dir = "" # we purposfully do not set this as src, forcing import from site-package that has version.py
|
||||
filename = "docs/changelog.rst"
|
||||
directory = "docs/changelog"
|
||||
title_format = false
|
||||
issue_format = "`#{issue} <https://github.com/pypa/virtualenv/issues/{issue}>`_"
|
||||
template = "docs/changelog/template.jinja2"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class LogSession(object):
|
|||
" creator {}".format(ensure_text(str(self.session.creator))),
|
||||
]
|
||||
if self.session.seeder.enabled:
|
||||
lines += (" seeder {}".format(ensure_text(str(self.session.seeder)),),)
|
||||
lines += (" seeder {}".format(ensure_text(str(self.session.seeder))),)
|
||||
if self.session.activators:
|
||||
lines.append(" activators {}".format(",".join(i.__class__.__name__ for i in self.session.activators)))
|
||||
return os.linesep.join(lines)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class PythonActivator(ViaTemplateActivator):
|
|||
{
|
||||
"__LIB_FOLDERS__": ensure_text(os.pathsep.join(lib_folders.keys())),
|
||||
"__DECODE_PATH__": ("yes" if win_py2 else ""),
|
||||
}
|
||||
},
|
||||
)
|
||||
return replacements
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ class VirtualEnvOptions(Namespace):
|
|||
|
||||
def __repr__(self):
|
||||
return "{}({})".format(
|
||||
type(self).__name__, ", ".join("{}={}".format(k, v) for k, v in vars(self).items() if not k.startswith("_"))
|
||||
type(self).__name__,
|
||||
", ".join("{}={}".format(k, v) for k, v in vars(self).items() if not k.startswith("_")),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class Creator(object):
|
|||
def non_write_able(dest, value):
|
||||
common = Path(*os.path.commonprefix([value.parts, dest.parts]))
|
||||
raise ArgumentTypeError(
|
||||
"the destination {} is not write-able at {}".format(dest.relative_to(common), common)
|
||||
"the destination {} is not write-able at {}".format(dest.relative_to(common), common),
|
||||
)
|
||||
|
||||
# the file system must be able to encode
|
||||
|
|
@ -118,13 +118,13 @@ class Creator(object):
|
|||
if refused:
|
||||
raise ArgumentTypeError(
|
||||
"the file system codec ({}) cannot handle characters {!r} within {!r}".format(
|
||||
encoding, "".join(refused.keys()), raw_value
|
||||
)
|
||||
encoding, "".join(refused.keys()), raw_value,
|
||||
),
|
||||
)
|
||||
if os.pathsep in raw_value:
|
||||
raise ArgumentTypeError(
|
||||
"destination {!r} must not contain the path separator ({}) as this would break "
|
||||
"the activation scripts".format(raw_value, os.pathsep)
|
||||
"the activation scripts".format(raw_value, os.pathsep),
|
||||
)
|
||||
|
||||
value = Path(raw_value)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class CPython3Posix(CPythonPosix, CPython3):
|
|||
import os
|
||||
if "__PYVENV_LAUNCHER__" in os.environ:
|
||||
del os.environ["__PYVENV_LAUNCHER__"]
|
||||
"""
|
||||
""",
|
||||
)
|
||||
return text
|
||||
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ class CPython2macOsFramework(CPythonmacOsFramework, CPython2PosixBase):
|
|||
finally:
|
||||
config["PYTHONFRAMEWORK"] = before
|
||||
""".format(
|
||||
result
|
||||
)
|
||||
result,
|
||||
),
|
||||
)
|
||||
return result
|
||||
|
||||
|
|
@ -124,8 +124,8 @@ class CPython3macOsFramework(CPythonmacOsFramework, CPython3, CPythonPosix):
|
|||
finally:
|
||||
sys._framework = before
|
||||
""".format(
|
||||
result
|
||||
)
|
||||
result,
|
||||
),
|
||||
)
|
||||
return result
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class Python2(ViaGlobalRefVirtualenvBuiltin, Python2Supports):
|
|||
def mappings(cls, interpreter):
|
||||
mappings = [(Path(interpreter.system_stdlib_platform), cls.to_stdlib_platform)]
|
||||
if interpreter.system_stdlib_platform != interpreter.system_stdlib:
|
||||
mappings.append((Path(interpreter.system_stdlib), cls.to_stdlib),)
|
||||
mappings.append((Path(interpreter.system_stdlib), cls.to_stdlib))
|
||||
return mappings
|
||||
|
||||
def to_stdlib(self, src):
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ class ViaGlobalRefVirtualenvBuiltin(ViaGlobalRefApi, VirtualenvBuiltin):
|
|||
if meta.can_symlink and not src.can_symlink:
|
||||
meta.symlink_error = "cannot symlink {}".format(src)
|
||||
if not meta.can_copy and not meta.can_symlink:
|
||||
meta.error = "neither copy or symlink supported: {}".format(
|
||||
meta.copy_error, meta.symlink_error
|
||||
meta.error = "neither copy or symlink supported, copy: {} symlink: {}".format(
|
||||
meta.copy_error, meta.symlink_error,
|
||||
)
|
||||
else:
|
||||
meta.error = "missing required file {}".format(src)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ def _run_subprocess(cls, exe, app_data):
|
|||
result.executable = exe # keep original executable as this may contain initialization code
|
||||
else:
|
||||
msg = "failed to query {} with code {}{}{}".format(
|
||||
exe, code, " out: {!r}".format(out) if out else "", " err: {!r}".format(err) if err else ""
|
||||
exe, code, " out: {!r}".format(out) if out else "", " err: {!r}".format(err) if err else "",
|
||||
)
|
||||
failure = RuntimeError(msg)
|
||||
return failure, result
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ class PythonInfo(object):
|
|||
|
||||
def __repr__(self):
|
||||
return "{}({!r})".format(
|
||||
self.__class__.__name__, {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
|
||||
self.__class__.__name__, {k: v for k, v in self.__dict__.items() if not k.startswith("_")},
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
|
@ -207,7 +207,7 @@ class PythonInfo(object):
|
|||
", ".join(
|
||||
"{}={}".format(k, v)
|
||||
for k, v in (
|
||||
("spec", self.spec,),
|
||||
("spec", self.spec),
|
||||
(
|
||||
"system"
|
||||
if self.system_executable is not None and self.system_executable != self.executable
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ def load_exe(hive_name, company, company_key, tag):
|
|||
args = get_value(ip_key, "ExecutableArguments")
|
||||
return exe, args
|
||||
else:
|
||||
msg(key_path, "exe does not exists {}".format(key_path, exe))
|
||||
msg(key_path, "could not load exe with value {}".format(exe))
|
||||
except OSError:
|
||||
msg("{}/{}".format(key_path, "InstallPath"), "missing")
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ def _do_report_setup(parser, args):
|
|||
level_map = ", ".join("{}={}".format(logging.getLevelName(l), c) for c, l in sorted(list(LEVELS.items())))
|
||||
msg = "verbosity = verbose - quiet, default {}, mapping => {}"
|
||||
verbosity_group = parser.add_argument_group(
|
||||
title="verbosity", description=msg.format(logging.getLevelName(LEVELS[3]), level_map)
|
||||
title="verbosity", description=msg.format(logging.getLevelName(LEVELS[3]), level_map),
|
||||
)
|
||||
verbosity = verbosity_group.add_mutually_exclusive_group()
|
||||
verbosity.add_argument("-v", "--verbose", action="count", dest="verbose", help="increase verbosity", default=2)
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ class CreatorSelector(ComponentBuilder):
|
|||
raise RuntimeError(
|
||||
"\n".join(
|
||||
"{} for creators {}".format(k, ", ".join(i.__name__ for i in v)) for k, v in errored.items()
|
||||
)
|
||||
),
|
||||
)
|
||||
else:
|
||||
raise RuntimeError("No virtualenv implementation for {}".format(interpreter))
|
||||
return CreatorInfo(
|
||||
key_to_class=key_to_class, key_to_meta=key_to_meta, describe=describe, builtin_key=builtin_key
|
||||
key_to_class=key_to_class, key_to_meta=key_to_meta, describe=describe, builtin_key=builtin_key,
|
||||
)
|
||||
|
||||
def add_selector_arg_parse(self, name, choices):
|
||||
|
|
@ -58,7 +58,7 @@ class CreatorSelector(ComponentBuilder):
|
|||
default=default_value,
|
||||
required=False,
|
||||
help="create environment via{}".format(
|
||||
"" if self.builtin_key is None else " (builtin = {})".format(self.builtin_key)
|
||||
"" if self.builtin_key is None else " (builtin = {})".format(self.builtin_key),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Discovery(PluginLoader):
|
|||
def get_discover(parser, args):
|
||||
discover_types = Discovery.entry_points_for("virtualenv.discovery")
|
||||
discovery_parser = parser.add_argument_group(
|
||||
title="discovery", description="discover and provide a target interpreter"
|
||||
title="discovery", description="discover and provide a target interpreter",
|
||||
)
|
||||
discovery_parser.add_argument(
|
||||
"--discovery",
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class BaseEmbed(Seeder):
|
|||
if getattr(self, "no_{}".format(package)):
|
||||
continue
|
||||
result += " {}{},".format(
|
||||
package, "={}".format(getattr(self, "{}_version".format(package), None) or "latest")
|
||||
package, "={}".format(getattr(self, "{}_version".format(package), None) or "latest"),
|
||||
)
|
||||
return result[:-1] + ")"
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ def pip_wheel_env_run(version, app_data):
|
|||
{
|
||||
ensure_str(k): str(v) # python 2 requires these to be string only (non-unicode)
|
||||
for k, v in {"PIP_USE_WHEEL": "1", "PIP_USER": "0", "PIP_NO_INPUT": "1"}.items()
|
||||
}
|
||||
},
|
||||
)
|
||||
with ensure_file_on_disk(get_bundled_wheel("pip", version), app_data) as pip_wheel_path:
|
||||
# put the bundled wheel onto the path, and use it to do the bootstrap operation
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class FromAppData(BaseEmbed):
|
|||
dest="symlink_app_data",
|
||||
action="store_true" if can_symlink else "store_false",
|
||||
help="{} symlink the python packages from the app-data folder (requires seed pip>=19.3)".format(
|
||||
"" if can_symlink else "not supported - "
|
||||
"" if can_symlink else "not supported - ",
|
||||
),
|
||||
default=False,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Session(object):
|
|||
def _activate(self):
|
||||
if self.activators:
|
||||
logging.info(
|
||||
"add activators for %s", ", ".join(type(i).__name__.replace("Activator", "") for i in self.activators)
|
||||
"add activators for %s", ", ".join(type(i).__name__.replace("Activator", "") for i in self.activators),
|
||||
)
|
||||
for activator in self.activators:
|
||||
activator.generate(self.creator)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@ from virtualenv.info import IS_CPYTHON, IS_WIN
|
|||
from virtualenv.util.six import ensure_text
|
||||
|
||||
if PY2 and IS_CPYTHON and IS_WIN: # CPython2 on Windows supports unicode paths if passed as unicode
|
||||
norm = lambda src: ensure_text(str(src)) # noqa
|
||||
|
||||
def norm(src):
|
||||
return ensure_text(str(src))
|
||||
|
||||
|
||||
else:
|
||||
norm = str
|
||||
|
||||
|
|
@ -78,7 +82,7 @@ class _Debug(object):
|
|||
|
||||
def __str__(self):
|
||||
return "{}{} to {}".format(
|
||||
"directory " if self.src.is_dir() else "", ensure_text(str(self.src)), ensure_text(str(self.dest))
|
||||
"directory " if self.src.is_dir() else "", ensure_text(str(self.src)), ensure_text(str(self.dest)),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ else:
|
|||
def run_cmd(cmd):
|
||||
try:
|
||||
process = Popen(
|
||||
cmd, universal_newlines=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE
|
||||
cmd, universal_newlines=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
)
|
||||
out, err = process.communicate() # input disabled
|
||||
code = process.returncode
|
||||
|
|
|
|||
|
|
@ -74,9 +74,11 @@ CreateProcessW.restype = BOOL
|
|||
## Patched functions/classes
|
||||
##
|
||||
|
||||
def CreateProcess(executable, args, _p_attr, _t_attr,
|
||||
inherit_handles, creation_flags, env, cwd,
|
||||
startup_info):
|
||||
def CreateProcess(
|
||||
executable, args, _p_attr, _t_attr,
|
||||
inherit_handles, creation_flags, env, cwd,
|
||||
startup_info,
|
||||
):
|
||||
"""Create a process supporting unicode executable and args for win32
|
||||
|
||||
Python implementation of CreateProcess using CreateProcessW for Win32
|
||||
|
|
@ -96,32 +98,41 @@ def CreateProcess(executable, args, _p_attr, _t_attr,
|
|||
wenv = None
|
||||
if env is not None:
|
||||
## LPCWSTR seems to be c_wchar_p, so let's say CWSTR is c_wchar
|
||||
env = (unicode("").join([
|
||||
env = (
|
||||
unicode("").join([
|
||||
unicode("%s=%s\0") % (k, v)
|
||||
for k, v in env.items()])) + unicode("\0")
|
||||
for k, v in env.items()
|
||||
])
|
||||
) + unicode("\0")
|
||||
wenv = (c_wchar * len(env))()
|
||||
wenv.value = env
|
||||
|
||||
pi = PROCESS_INFORMATION()
|
||||
creation_flags |= CREATE_UNICODE_ENVIRONMENT
|
||||
|
||||
if CreateProcessW(executable, args, None, None,
|
||||
inherit_handles, creation_flags,
|
||||
wenv, cwd, byref(si), byref(pi)):
|
||||
return (DUMMY_HANDLE(pi.hProcess), DUMMY_HANDLE(pi.hThread),
|
||||
pi.dwProcessId, pi.dwThreadId)
|
||||
if CreateProcessW(
|
||||
executable, args, None, None,
|
||||
inherit_handles, creation_flags,
|
||||
wenv, cwd, byref(si), byref(pi),
|
||||
):
|
||||
return (
|
||||
DUMMY_HANDLE(pi.hProcess), DUMMY_HANDLE(pi.hThread),
|
||||
pi.dwProcessId, pi.dwThreadId,
|
||||
)
|
||||
raise WinError()
|
||||
|
||||
|
||||
class Popen(subprocess.Popen):
|
||||
"""This superseeds Popen and corrects a bug in cPython 2.7 implem"""
|
||||
|
||||
def _execute_child(self, args, executable, preexec_fn, close_fds,
|
||||
cwd, env, universal_newlines,
|
||||
startupinfo, creationflags, shell, to_close,
|
||||
p2cread, p2cwrite,
|
||||
c2pread, c2pwrite,
|
||||
errread, errwrite):
|
||||
def _execute_child(
|
||||
self, args, executable, preexec_fn, close_fds,
|
||||
cwd, env, universal_newlines,
|
||||
startupinfo, creationflags, shell, to_close,
|
||||
p2cread, p2cwrite,
|
||||
c2pread, c2pwrite,
|
||||
errread, errwrite,
|
||||
):
|
||||
"""Code from part of _execute_child from Python 2.7 (9fbb65e)
|
||||
|
||||
There are only 2 little changes concerning the construction of
|
||||
|
|
@ -141,16 +152,20 @@ class Popen(subprocess.Popen):
|
|||
startupinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW
|
||||
startupinfo.wShowWindow = _subprocess.SW_HIDE
|
||||
comspec = os.environ.get("COMSPEC", unicode("cmd.exe"))
|
||||
if (_subprocess.GetVersion() >= 0x80000000 or
|
||||
os.path.basename(comspec).lower() == "command.com"):
|
||||
if (
|
||||
_subprocess.GetVersion() >= 0x80000000 or
|
||||
os.path.basename(comspec).lower() == "command.com"
|
||||
):
|
||||
w9xpopen = self._find_w9xpopen()
|
||||
args = unicode('"%s" %s') % (w9xpopen, args)
|
||||
creationflags |= _subprocess.CREATE_NEW_CONSOLE
|
||||
|
||||
super(Popen, self)._execute_child(args, executable,
|
||||
super(Popen, self)._execute_child(
|
||||
args, executable,
|
||||
preexec_fn, close_fds, cwd, env, universal_newlines,
|
||||
startupinfo, creationflags, False, to_close, p2cread,
|
||||
p2cwrite, c2pread, c2pwrite, errread, errwrite)
|
||||
p2cwrite, c2pread, c2pwrite, errread, errwrite,
|
||||
)
|
||||
|
||||
_subprocess.CreateProcess = CreateProcess
|
||||
# fmt: on
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class WheelDownloader(object):
|
|||
def run(self, target, versions):
|
||||
whl = self.build_sdist(target)
|
||||
todo = deque((version, None, whl) for version in versions)
|
||||
wheel_store = dict()
|
||||
wheel_store = {}
|
||||
while todo:
|
||||
version, platform, dep = todo.popleft()
|
||||
dep_str = dep.name.split("-")[0] if isinstance(dep, Path) else dep.name
|
||||
|
|
@ -147,7 +147,7 @@ class WheelDownloader(object):
|
|||
return
|
||||
for dep in deps:
|
||||
req = Requirement(dep)
|
||||
markers = getattr(req.marker, "_markers", tuple()) or tuple()
|
||||
markers = getattr(req.marker, "_markers", tuple()) or ()
|
||||
if any(m for m in markers if isinstance(m, tuple) and len(m) == 3 and m[0].value == "extra"):
|
||||
continue
|
||||
py_versions = WheelDownloader._marker_at(markers, "python_version")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ DEST = Path(__file__).resolve().parents[1] / "src" / "virtualenv" / "seed" / "em
|
|||
|
||||
def download(ver, dest, package):
|
||||
subprocess.call(
|
||||
[sys.executable, "-m", "pip", "download", "--only-binary=:all:", "--python-version", ver, "-d", dest, package]
|
||||
[sys.executable, "-m", "pip", "download", "--only-binary=:all:", "--python-version", ver, "-d", dest, package],
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ def zipapp_build_env(tmp_path_factory):
|
|||
"",
|
||||
str(create_env_path),
|
||||
"--no-download",
|
||||
]
|
||||
],
|
||||
)
|
||||
exe = str(session.creator.exe)
|
||||
found = True
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class ActivationTester(object):
|
|||
# locally we disable, so that contributors don't need to have everything setup
|
||||
try:
|
||||
process = Popen(
|
||||
self._version_cmd, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
self._version_cmd, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
)
|
||||
out, err = process.communicate()
|
||||
result = out if out else err
|
||||
|
|
@ -144,16 +144,16 @@ class ActivationTester(object):
|
|||
def print_python_exe(self):
|
||||
return self.python_cmd(
|
||||
"import sys; print(sys.executable{})".format(
|
||||
"" if six.PY3 or IS_PYPY else ".decode(sys.getfilesystemencoding())"
|
||||
)
|
||||
"" if six.PY3 or IS_PYPY else ".decode(sys.getfilesystemencoding())",
|
||||
),
|
||||
)
|
||||
|
||||
def print_os_env_var(self, var):
|
||||
val = '"{}"'.format(var)
|
||||
return self.python_cmd(
|
||||
"import os; import sys; v = os.environ.get({}); print({})".format(
|
||||
val, "v" if six.PY3 or IS_PYPY else "None if v is None else v.decode(sys.getfilesystemencoding())"
|
||||
)
|
||||
val, "v" if six.PY3 or IS_PYPY else "None if v is None else v.decode(sys.getfilesystemencoding())",
|
||||
),
|
||||
)
|
||||
|
||||
def activate_call(self, script):
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ from virtualenv.discovery.py_info import PythonInfo
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"activator_class", [BatchActivator, PowerShellActivator, PythonActivator, BashActivator, FishActivator]
|
||||
"activator_class", [BatchActivator, PowerShellActivator, PythonActivator, BashActivator, FishActivator],
|
||||
)
|
||||
def test_activator_support_windows(mocker, activator_class):
|
||||
activator = activator_class(Namespace(prompt=None))
|
||||
|
|
@ -36,7 +36,7 @@ def test_activator_no_support_windows(mocker, activator_class):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"activator_class", [BashActivator, CShellActivator, FishActivator, PowerShellActivator, PythonActivator]
|
||||
"activator_class", [BashActivator, CShellActivator, FishActivator, PowerShellActivator, PythonActivator],
|
||||
)
|
||||
def test_activator_support_posix(mocker, activator_class):
|
||||
activator = activator_class(Namespace(prompt=None))
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ def test_bash(raise_on_non_source_class, activation_tester):
|
|||
class Bash(raise_on_non_source_class):
|
||||
def __init__(self, session):
|
||||
super(Bash, self).__init__(
|
||||
BashActivator, session, "bash", "activate", "sh", "You must source this script: $ source "
|
||||
BashActivator, session, "bash", "activate", "sh", "You must source this script: $ source ",
|
||||
)
|
||||
|
||||
activation_tester(Bash)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ def test_python(raise_on_non_source_class, activation_tester):
|
|||
import pydoc_test
|
||||
print_r(pydoc_test.__file__)
|
||||
""".format(
|
||||
str(activate_script), ".decode('utf-8')" if WIN_CPYTHON_2 else ""
|
||||
str(activate_script), ".decode('utf-8')" if WIN_CPYTHON_2 else "",
|
||||
)
|
||||
result = dedent(raw).splitlines()
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ def test_xonsh(activation_tester_class, activation_tester):
|
|||
class Xonsh(activation_tester_class):
|
||||
def __init__(self, session):
|
||||
super(Xonsh, self).__init__(
|
||||
XonshActivator, session, "xonsh.exe" if sys.platform == "win32" else "xonsh", "activate.xsh", "xsh"
|
||||
XonshActivator, session, "xonsh.exe" if sys.platform == "win32" else "xonsh", "activate.xsh", "xsh",
|
||||
)
|
||||
self._invoke_script = [sys.executable, "-m", "xonsh"]
|
||||
self._version_cmd = [sys.executable, "-m", "xonsh", "--version"]
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ def test_ini_can_be_overwritten_by_flag(tmp_path, monkeypatch):
|
|||
"""
|
||||
[virtualenv]
|
||||
copies = True
|
||||
"""
|
||||
)
|
||||
""",
|
||||
),
|
||||
)
|
||||
monkeypatch.setenv(ensure_str("VIRTUALENV_CONFIG_FILE"), str(custom_ini))
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ def old_virtualenv(tmp_path_factory, session_app_data):
|
|||
exe_path = CURRENT.discover_exe(session_app_data, prefix=str(old_virtualenv_at)).original_executable
|
||||
return exe_path
|
||||
except Exception as exception:
|
||||
return RuntimeError("failed to create old virtualenv %r".format(exception))
|
||||
return RuntimeError("failed to create old virtualenv {}".format(exception))
|
||||
|
||||
|
||||
PYTHON = {"root": root, "venv": venv, "old_virtualenv": old_virtualenv}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ for k, v in CURRENT.creators().key_to_meta.items():
|
|||
_VENV_BUG_ON = (
|
||||
IS_PYPY
|
||||
and CURRENT.version_info[0:3] == (3, 6, 9)
|
||||
and CURRENT.pypy_version_info[0:2] == [7, 3]
|
||||
and CURRENT.pypy_version_info[0:2] == [7, 3, 0]
|
||||
and CURRENT.platform == "linux"
|
||||
)
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ def test_create_no_seed(python, creator, isolated, system, coverage_env, special
|
|||
global_sys_path = system_sys_path[-1]
|
||||
if isolated == "isolated":
|
||||
msg = "global sys path {} is in virtual environment sys path:\n{}".format(
|
||||
ensure_text(str(global_sys_path)), "\n".join(ensure_text(str(j)) for j in sys_path)
|
||||
ensure_text(str(global_sys_path)), "\n".join(ensure_text(str(j)) for j in sys_path),
|
||||
)
|
||||
assert global_sys_path not in sys_path, msg
|
||||
else:
|
||||
|
|
@ -342,7 +342,7 @@ def test_cross_major(cross_python, coverage_env, tmp_path, session_app_data, cur
|
|||
def test_create_parallel(tmp_path, monkeypatch, temp_app_data):
|
||||
def create(count):
|
||||
subprocess.check_call(
|
||||
[sys.executable, "-m", "virtualenv", "-vvv", str(tmp_path / "venv{}".format(count)), "--without-pip"]
|
||||
[sys.executable, "-m", "virtualenv", "-vvv", str(tmp_path / "venv{}".format(count)), "--without-pip"],
|
||||
)
|
||||
|
||||
threads = [Thread(target=create, args=(i,)) for i in range(1, 4)]
|
||||
|
|
@ -399,8 +399,8 @@ def test_create_distutils_cfg(creator, tmp_path, monkeypatch):
|
|||
install_scripts={0}{1}scripts
|
||||
install_data={0}{1}data
|
||||
""".format(
|
||||
tmp_path, os.sep
|
||||
)
|
||||
tmp_path, os.sep,
|
||||
),
|
||||
)
|
||||
setup_cfg.write_text(setup_cfg.read_text() + conf)
|
||||
|
||||
|
|
@ -501,7 +501,7 @@ def test_python_path(monkeypatch, tmp_path, python_path_on):
|
|||
product(
|
||||
[True, False] if Python2.from_stdlib(Python2.mappings(CURRENT), "os.py")[2] else [False],
|
||||
[True, False] if Python2.from_stdlib(Python2.mappings(CURRENT), "os.pyc")[2] else [False],
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_py_pyc_missing(tmp_path, mocker, session_app_data, py, pyc):
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ SYSTEM = PythonInfo.current_system()
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"of_id", ({sys.executable} if sys.executable != SYSTEM.executable else set()) | {SYSTEM.implementation}
|
||||
"of_id", ({sys.executable} if sys.executable != SYSTEM.executable else set()) | {SYSTEM.implementation},
|
||||
)
|
||||
def test_failed_to_find_implementation(of_id, mocker):
|
||||
mocker.patch("virtualenv.run.plugin.creators.CreatorSelector._OPTIONS", return_value={})
|
||||
with pytest.raises(RuntimeError) as context:
|
||||
cli_run(["-p", of_id])
|
||||
assert repr(context.value) == repr(
|
||||
RuntimeError("No virtualenv implementation for {}".format(PythonInfo.current_system()))
|
||||
RuntimeError("No virtualenv implementation for {}".format(PythonInfo.current_system())),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ def test_satisfy_py_info(spec):
|
|||
|
||||
def test_satisfy_not_arch():
|
||||
parsed_spec = PythonSpec.from_string_spec(
|
||||
"{}-{}".format(CURRENT.implementation, 64 if CURRENT.architecture == 32 else 32)
|
||||
"{}-{}".format(CURRENT.implementation, 64 if CURRENT.architecture == 32 else 32),
|
||||
)
|
||||
matches = CURRENT.satisfies(parsed_spec, True)
|
||||
assert matches is False
|
||||
|
|
@ -261,9 +261,9 @@ def test_py_info_ignores_distutils_config(monkeypatch, tmp_path):
|
|||
install_scripts={0}{1}scripts
|
||||
install_data={0}{1}data
|
||||
""".format(
|
||||
tmp_path, os.sep
|
||||
)
|
||||
)
|
||||
tmp_path, os.sep,
|
||||
),
|
||||
),
|
||||
)
|
||||
monkeypatch.chdir(tmp_path)
|
||||
py_info = PythonInfo.from_exe(sys.executable)
|
||||
|
|
@ -287,7 +287,7 @@ def test_discover_exe_on_path_non_spec_name_not_match(mocker):
|
|||
suffixed_name += Path(CURRENT.original_executable).suffix
|
||||
spec = PythonSpec.from_string_spec(suffixed_name)
|
||||
mocker.patch.object(
|
||||
CURRENT, "original_executable", str(Path(CURRENT.executable).parent / "e{}".format(suffixed_name))
|
||||
CURRENT, "original_executable", str(Path(CURRENT.executable).parent / "e{}".format(suffixed_name)),
|
||||
)
|
||||
assert CURRENT.satisfies(spec, impl_must_match=True) is False
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ def test_discover_ok(tmp_path, monkeypatch, suffix, impl, version, arch, into, c
|
|||
caplog.set_level(logging.DEBUG)
|
||||
folder = tmp_path / into
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
dest = folder / "{}{}".format(impl, version, arch, suffix)
|
||||
name = "{}{}".format(impl, version)
|
||||
if arch:
|
||||
name += "-{}".format(arch)
|
||||
name += suffix
|
||||
dest = folder / name
|
||||
os.symlink(CURRENT.executable, str(dest))
|
||||
pyvenv = Path(CURRENT.executable).parents[1] / "pyvenv.cfg"
|
||||
if pyvenv.exists():
|
||||
|
|
|
|||
|
|
@ -87,14 +87,14 @@ def test_version_satisfies_ok(req, spec):
|
|||
def _version_not_satisfies_pairs():
|
||||
target = set()
|
||||
version = tuple(str(i) for i in sys.version_info[0:3])
|
||||
for i in range(len(version)):
|
||||
req = ".".join(version[0 : i + 1])
|
||||
for j in range(i + 1):
|
||||
sat_ver = list(sys.version_info[0 : j + 1])
|
||||
for l in range(j + 1):
|
||||
for major in range(len(version)):
|
||||
req = ".".join(version[0 : major + 1])
|
||||
for minor in range(major + 1):
|
||||
sat_ver = list(sys.version_info[0 : minor + 1])
|
||||
for patch in range(minor + 1):
|
||||
for o in [1, -1]:
|
||||
temp = copy(sat_ver)
|
||||
temp[l] += o
|
||||
temp[patch] += o
|
||||
sat = ".".join(str(i) for i in temp)
|
||||
target.add((req, sat))
|
||||
return sorted(target)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ def test_pep514_run(_mock_registry, capsys, caplog):
|
|||
('PythonCore', 3, 6, 64, 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36\\python.exe', None)
|
||||
('PythonCore', 3, 7, 32, 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe', None)
|
||||
('PythonCore', 3, 9, 64, 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36\\python.exe', None)
|
||||
"""
|
||||
""",
|
||||
).strip()
|
||||
assert out.strip() == expected
|
||||
assert not err
|
||||
|
|
@ -57,7 +57,7 @@ def test_pep514_run(_mock_registry, capsys, caplog):
|
|||
"{}HKEY_CURRENT_USER/PythonCore/3.1/SysArchitecture error: invalid format magic".format(prefix),
|
||||
"{}HKEY_CURRENT_USER/PythonCore/3.2/SysArchitecture error: arch is not string: 100".format(prefix),
|
||||
"{}HKEY_CURRENT_USER/PythonCore/3.3 error: no ExecutablePath or default for it".format(prefix),
|
||||
"{}HKEY_CURRENT_USER/PythonCore/3.3 error: exe does not exists HKEY_CURRENT_USER/PythonCore/3.3".format(prefix),
|
||||
"{}HKEY_CURRENT_USER/PythonCore/3.3 error: could not load exe with value None".format(prefix),
|
||||
"{}HKEY_CURRENT_USER/PythonCore/3.8/InstallPath error: missing".format(prefix),
|
||||
"{}HKEY_CURRENT_USER/PythonCore/3.9/SysVersion error: invalid format magic".format(prefix),
|
||||
"{}HKEY_CURRENT_USER/PythonCore/3.X/SysVersion error: version is not string: 2778".format(prefix),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ hive_open = {
|
|||
(winreg.HKEY_CURRENT_USER, "Software\\Python", 0, winreg.KEY_READ): 78701856,
|
||||
(winreg.HKEY_LOCAL_MACHINE, "Software\\Python", 0, winreg.KEY_READ | winreg.KEY_WOW64_64KEY): 78701840,
|
||||
(winreg.HKEY_LOCAL_MACHINE, "Software\\Python", 0, winreg.KEY_READ | winreg.KEY_WOW64_32KEY): OSError(
|
||||
2, "The system cannot find the file specified"
|
||||
2, "The system cannot find the file specified",
|
||||
),
|
||||
}
|
||||
key_open = {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ setup(
|
|||
version="1.0", # package version
|
||||
ext_modules=[
|
||||
Extension(
|
||||
"greet", ["greet{}.c".format(sys.version_info[0])] # extension to package
|
||||
) # C code to compile to run as extension
|
||||
"greet", ["greet{}.c".format(sys.version_info[0])], # extension to package
|
||||
), # C code to compile to run as extension
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from virtualenv.run import session_via_cli
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"args, download", [([], False), (["--no-download"], False), (["--never-download"], False), (["--download"], True)]
|
||||
"args, download", [([], False), (["--no-download"], False), (["--never-download"], False), (["--download"], True)],
|
||||
)
|
||||
def test_download_cli_flag(args, download, tmp_path):
|
||||
session = session_via_cli(args + [str(tmp_path)])
|
||||
|
|
|
|||
6
tox.ini
6
tox.ini
|
|
@ -26,6 +26,7 @@ setenv =
|
|||
_COVERAGE_SRC = {envsitepackagesdir}/virtualenv
|
||||
PYTHONIOENCODING=utf-8
|
||||
{py34,py27,pypy}: PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command
|
||||
{pypy,py27}: PYTEST_XDIST = 0
|
||||
passenv = https_proxy http_proxy no_proxy HOME PYTEST_* PIP_* CI_RUN TERM
|
||||
extras = testing
|
||||
install_command = python -m pip install {opts} {packages} --disable-pip-version-check
|
||||
|
|
@ -39,11 +40,6 @@ commands =
|
|||
coverage report
|
||||
coverage html -d {envtmpdir}/htmlcov
|
||||
|
||||
[testenv:pypy]
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
PYTEST_XDIST = 0
|
||||
|
||||
[testenv:coverage]
|
||||
description = [run locally after tests]: combine coverage data and create report;
|
||||
generates a diff coverage against origin/master (can be changed by setting DIFF_AGAINST env var)
|
||||
|
|
|
|||
Loading…
Reference in a new issue