Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade embeded wheels #2681

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@ repos:
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.1"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.5.3"
rev: "1.6.0"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.11.4"]
additional_dependencies: ["tox>=4.12"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.11"
rev: v0.1.12
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
- repo: meta
hooks:
- id: check-hooks-apply
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog/2681.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Upgrade embedded wheels:

* setuptools to ``69.0.3`` from ``69.0.2``
* pip to ``23.3.2`` from ``23.3.1``
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def setup(app):
sys.path.append(str(here))

# noinspection PyUnresolvedReferences
from render_cli import CliTable, literal_data
from render_cli import CliTable, literal_data # noqa: PLC0415

app.add_css_file("custom.css")
app.add_directive(CliTable.name, CliTable)
Expand Down
10 changes: 6 additions & 4 deletions docs/render_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TableRow(NamedTuple):
names: list[str]
default: str
choices: set[str]
help: str # noqa: A003
help: str


class TextAsDefault(NamedTuple):
Expand Down Expand Up @@ -84,12 +84,14 @@ def a(*args, **kwargs):
return True
if key == "creator":
if name == "venv":
from virtualenv.create.via_global_ref.venv import ViaGlobalRefMeta
from virtualenv.create.via_global_ref.venv import ViaGlobalRefMeta # noqa: PLC0415

meta = ViaGlobalRefMeta()
meta.symlink_error = None
return meta
from virtualenv.create.via_global_ref.builtin.via_global_self_do import BuiltinViaGlobalRefMeta
from virtualenv.create.via_global_ref.builtin.via_global_self_do import ( # noqa: PLC0415
BuiltinViaGlobalRefMeta,
)

meta = BuiltinViaGlobalRefMeta()
meta.symlink_error = None
Expand Down Expand Up @@ -183,7 +185,7 @@ def _get_targeted_names(self, row):
@staticmethod
def _get_help_text(row):
name = row.names[0]
content = row.help[: row.help.index("(") - 1] if name in ("--creator",) else row.help
content = row.help[: row.help.index("(") - 1] if name == "--creator" else row.help
help_body = n.paragraph("", "", n.Text(content))
if row.choices is not None:
help_body += n.Text("; choice of: ")
Expand Down
41 changes: 25 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,34 @@ line-length = 120
select = ["ALL"]
line-length = 120
target-version = "py37"
isort = {known-first-party = ["virtualenv"], required-imports = ["from __future__ import annotations"]}
isort = { known-first-party = ["virtualenv"], required-imports = ["from __future__ import annotations"] }
ignore = [
"ANN", # no type checking added yet
"D10", # no docstrings
"D40", # no imperative mode for docstrings
"PTH", # no pathlib, <=39 has problems on Windows with absolute/resolve, can revisit once we no longer need 39
"INP001", # ignore implicit namespace packages
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
"S104", # Possible binding to all interface
"CPY", # No copyright header
"ANN", # no type checking added yet
"D10", # no docstrings
"D40", # no imperative mode for docstrings
"PTH", # no pathlib, <=39 has problems on Windows with absolute/resolve, can revisit once we no longer need 39
"INP001", # ignore implicit namespace packages
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
"S104", # Possible binding to all interfaces
"S404", # Using subprocess is alright
"PLR0914", # Too many local variables
"PLR0917", # Too many positional arguments
"PLR6301", # Method could be a function, class method, or static method
"COM812", # conflict with formatter
"ISC001", # conflict with formatter
]
format.preview = true
lint.preview = true
[tool.ruff.per-file-ignores]
"tests/**/*.py" = [
"S101", # asserts allowed in tests...
"FBT", # don"t care about booleans as positional arguments in tests
"INP001", # no implicit namespace
"D", # don"t care about documentation in tests
"S603", # `subprocess` call: check for execution of untrusted input
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
"S101", # asserts allowed in tests...
"FBT", # don"t care about booleans as positional arguments in tests
"INP001", # no implicit namespace
"D", # don't care about documentation in tests
"S603", # `subprocess` call: check for execution of untrusted input
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
]

[tool.pytest.ini_options]
Expand All @@ -140,7 +149,7 @@ env = ["PYTHONIOENCODING=utf-8"]
html.show_contexts = true
html.skip_covered = false
report.omit = [
# site.py is ran before the coverage can be enabled, no way to measure coverage on this
# site.py is run before the coverage can be enabled, no way to measure coverage on this
"**/src/virtualenv/create/via_global_ref/builtin/python2/site.py",
"**/src/virtualenv/create/via_global_ref/_virtualenv.py",
"**/src/virtualenv/activation/python/activate_this.py",
Expand Down
6 changes: 3 additions & 3 deletions src/virtualenv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
def run(args=None, options=None, env=None):
env = os.environ if env is None else env
start = default_timer()
from virtualenv.run import cli_run
from virtualenv.util.error import ProcessCallFailedError
from virtualenv.run import cli_run # noqa: PLC0415
from virtualenv.util.error import ProcessCallFailedError # noqa: PLC0415

if args is None:
args = sys.argv[1:]
Expand Down Expand Up @@ -48,7 +48,7 @@ def __str__(self) -> str:


def run_with_catch(args=None, env=None):
from virtualenv.config.cli.parser import VirtualEnvOptions
from virtualenv.config.cli.parser import VirtualEnvOptions # noqa: PLC0415

env = os.environ if env is None else env
options = VirtualEnvOptions()
Expand Down
1 change: 1 addition & 0 deletions src/virtualenv/activation/python/activate_this.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
""" # noqa: D415

from __future__ import annotations

import os
Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/config/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def _validate(self):
def convert(self, value, flatten=True): # noqa: ARG002, FBT002
values = self.split_values(value)
result = []
for value in values:
sub_values = value.split(os.pathsep)
for a_value in values:
sub_values = a_value.split(os.pathsep)
result.extend(sub_values)
return [self.as_type(i) for i in result]

Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/create/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ def get_env_debug_info(env_exe, debug_script, app_data, env):
env = env.copy()
env.pop("PYTHONPATH", None)

with app_data.ensure_extracted(debug_script) as debug_script:
cmd = [str(env_exe), str(debug_script)]
with app_data.ensure_extracted(debug_script) as debug_script_extracted:
cmd = [str(env_exe), str(debug_script_extracted)]
logging.debug("debug via %r", LogCmd(cmd))
code, out, err = run_cmd(cmd)

Expand Down
15 changes: 8 additions & 7 deletions src/virtualenv/create/debug.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Inspect a target Python interpreter virtual environment wise."""

from __future__ import annotations

import sys # built-in
Expand All @@ -21,7 +22,7 @@ def encode_list_path(value):
def run(): # noqa: PLR0912
"""Print debug data about the virtual environment."""
try:
from collections import OrderedDict
from collections import OrderedDict # noqa: PLC0415
except ImportError: # pragma: no cover
# this is possible if the standard library cannot be accessed

Expand All @@ -47,42 +48,42 @@ def run(): # noqa: PLR0912
result["version"] = sys.version

try:
import sysconfig
import sysconfig # noqa: PLC0415

# https://bugs.python.org/issue22199
makefile = getattr(sysconfig, "get_makefile_filename", getattr(sysconfig, "_get_makefile_filename", None))
result["makefile_filename"] = encode_path(makefile())
except ImportError:
pass

import os # landmark
import os # landmark # noqa: PLC0415

result["os"] = repr(os)

try:
import site # site
import site # site # noqa: PLC0415

result["site"] = repr(site)
except ImportError as exception: # pragma: no cover
result["site"] = repr(exception) # pragma: no cover

try:
import datetime # site
import datetime # site # noqa: PLC0415

result["datetime"] = repr(datetime)
except ImportError as exception: # pragma: no cover
result["datetime"] = repr(exception) # pragma: no cover

try:
import math # site
import math # site # noqa: PLC0415

result["math"] = repr(math)
except ImportError as exception: # pragma: no cover
result["math"] = repr(exception) # pragma: no cover

# try to print out, this will validate if other core modules are available (json in this case)
try:
import json
import json # noqa: PLC0415

result["json"] = repr(json)
except ImportError as exception:
Expand Down
6 changes: 3 additions & 3 deletions src/virtualenv/create/via_global_ref/_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def find_spec(self, fullname, path, target=None): # noqa: ARG002
if fullname in _DISTUTILS_PATCH and self.fullname is None:
# initialize lock[0] lazily
if len(self.lock) == 0:
import threading
import threading # noqa: PLC0415

lock = threading.Lock()
# there is possibility that two threads T1 and T2 are simultaneously running into find_spec,
Expand All @@ -64,8 +64,8 @@ def find_spec(self, fullname, path, target=None): # noqa: ARG002
# https://docs.python.org/3/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe
self.lock.append(lock)

from functools import partial
from importlib.util import find_spec
from functools import partial # noqa: PLC0415
from importlib.util import find_spec # noqa: PLC0415

with self.lock[0]:
self.fullname = fullname
Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/create/via_global_ref/builtin/builtin_way.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class VirtualenvBuiltin(Creator, Describe, metaclass=ABCMeta):
"""A creator that does operations itself without delegation, if we can create it we can also describe it."""

def __init__(self, options, interpreter) -> None:
Creator.__init__(self, options, interpreter)
Describe.__init__(self, self.dest, interpreter)
Creator.__init__(self, options, interpreter) # noqa: PLC2801
Describe.__init__(self, self.dest, interpreter) # noqa: PLC2801


__all__ = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def dll_and_pyd(cls, interpreter):

for folder in folders:
for file in folder.iterdir():
if file.suffix in (".pyd", ".dll"):
if file.suffix in {".pyd", ".dll"}:
yield PathRefToDest(file, cls.to_bin)

@classmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The Apple Framework builds require their own customization."""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -207,7 +208,7 @@ def mach_o_change(at_path, what, value): # noqa: C901

def do_macho(file, bits, endian):
# Read Mach-O header (the magic number is assumed read by the caller)
cpu_type, cpu_sub_type, file_type, n_commands, size_of_commands, flags = read_data(file, endian, 6)
_cpu_type, _cpu_sub_type, _file_type, n_commands, _size_of_commands, _flags = read_data(file, endian, 6)
# 64-bits header has one more field.
if bits == 64: # noqa: PLR2004
read_data(file, endian)
Expand Down Expand Up @@ -240,7 +241,7 @@ def do_file(file, offset=0, size=maxint):
n_fat_arch = read_data(file, BIG_ENDIAN)
for _ in range(n_fat_arch):
# Read arch header
cpu_type, cpu_sub_type, offset, size, align = read_data(file, BIG_ENDIAN, 5)
_cpu_type, _cpu_sub_type, offset, size, _align = read_data(file, BIG_ENDIAN, 5)
do_file(file, offset, size)
elif magic == MH_MAGIC:
do_macho(file, 32, BIG_ENDIAN)
Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/create/via_global_ref/builtin/ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class ExePathRefToDest(PathRefToDest, ExePathRef):
"""Link a exe path on the file system."""

def __init__(self, src, targets, dest, must=RefMust.NA, when=RefWhen.ANY) -> None: # noqa: PLR0913
ExePathRef.__init__(self, src, must, when)
PathRefToDest.__init__(self, src, dest, must, when)
ExePathRef.__init__(self, src, must, when) # noqa: PLC2801
PathRefToDest.__init__(self, src, dest, must, when) # noqa: PLC2801
if not self.FS_CASE_SENSITIVE:
targets = list(OrderedDict((i.lower(), None) for i in targets).keys())
self.base = targets[0]
Expand Down
11 changes: 5 additions & 6 deletions src/virtualenv/create/via_global_ref/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def executables_for_win_pypy_less_v37(self):
exe.run(creator, self.symlinks)

def create_inline(self):
from venv import EnvBuilder
from venv import EnvBuilder # noqa: PLC0415

builder = EnvBuilder(
system_site_packages=self.enable_system_site_package,
Expand All @@ -79,8 +79,7 @@ def get_host_create_cmd(self):
cmd = [self.interpreter.system_executable, "-m", "venv", "--without-pip"]
if self.enable_system_site_package:
cmd.append("--system-site-packages")
cmd.append("--symlinks" if self.symlinks else "--copies")
cmd.append(str(self.dest))
cmd.extend(("--symlinks" if self.symlinks else "--copies", str(self.dest)))
return cmd

def set_pyenv_cfg(self):
Expand All @@ -90,12 +89,12 @@ def set_pyenv_cfg(self):
self.pyenv_cfg.update(venv_content)

def __getattribute__(self, item):
describe = object.__getattribute__(self, "describe")
describe = object.__getattribute__(self, "describe") # noqa: PLC2801
if describe is not None and hasattr(describe, item):
element = getattr(describe, item)
if not callable(element) or item in ("script",):
if not callable(element) or item == "script":
return element
return object.__getattribute__(self, item)
return object.__getattribute__(self, item) # noqa: PLC2801


__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/discovery/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def propose_interpreters(spec, try_first_with, app_data, env=None): # noqa: C90

# 3. otherwise fallback to platform default logic
if IS_WIN:
from .windows import propose_interpreters
from .windows import propose_interpreters # noqa: PLC0415

for interpreter in propose_interpreters(spec, app_data, env):
yield interpreter, True
Expand Down
3 changes: 2 additions & 1 deletion src/virtualenv/discovery/cached_py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def _get_via_file_cache(cls, app_data, path, exe, env):

def gen_cookie():
return "".join(
random.choice(f"{ascii_lowercase}{ascii_uppercase}{digits}") for _ in range(COOKIE_LENGTH) # noqa: S311
random.choice(f"{ascii_lowercase}{ascii_uppercase}{digits}") # noqa: S311
for _ in range(COOKIE_LENGTH)
)


Expand Down
Loading
Loading