Skip to content

Commit

Permalink
Merge branch 'main' into remove-click-style-from-exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius authored Sep 23, 2024
2 parents e8a932f + fbecd8e commit 25c5d36
Show file tree
Hide file tree
Showing 77 changed files with 2,350 additions and 1,597 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
python-version: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13]
os: [MacOS, Ubuntu, Windows]

steps:
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: '^(pipenv/patched/|pipenv/vendor/|tests/|pipenv/pipenv.1)'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
Expand All @@ -18,13 +18,13 @@ repos:
exclude: .patch

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
rev: v0.6.7
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.8.0
hooks:
- id: black

Expand Down Expand Up @@ -53,11 +53,11 @@ repos:
stages: [manual]

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.2.0"
rev: "2.2.4"
hooks:
- id: pyproject-fmt

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.14
rev: v0.19
hooks:
- id: validate-pyproject
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
2024.0.2 (2024-09-13)
=====================
Pipenv 2024.0.2 (2024-09-13)
============================


Features & Improvements
-----------------------

- Initial support for python3.13 `#6240 <https://github.com/pypa/pipenv/issues/6240>`_

Bug Fixes
---------

- Fix bump version in CI/CD pipeline `#6177 <https://github.com/pypa/pipenv/issues/6177>`_
- Swap old_version and new_version in pipenv update --outdated output. `#6179 <https://github.com/pypa/pipenv/issues/6179>`_
- Update shell detection to only check the end of the command used. `#6197 <https://github.com/pypa/pipenv/issues/6197>`_
- Fix loading dot env twice #6198 `#6202 <https://github.com/pypa/pipenv/issues/6202>`_
- Solve issue with quiet lock not writing the lock file #6207. `#6207 <https://github.com/pypa/pipenv/issues/6207>`_
- Fix regression introduced with the "smarter uninstall" PR. Uninstall ``--all`` should not clear the Pipfile entries. `#6209 <https://github.com/pypa/pipenv/issues/6209>`_
- Fixed regression where all local file installations were incorrectly treated as editable. Ensure that local file installations are explicitly marked as editable in both Pipfile and Pipfile.lock entries if editable installation is desired. `#6222 <https://github.com/pypa/pipenv/issues/6222>`_
- Corrected behavior of ``pipenv install --skip-lock`` after behavioral install refactor introduced regression. No Pipfile.lock is generated with this fix and installation of vcs no longer fails with revision missing error. `#6225 <https://github.com/pypa/pipenv/issues/6225>`_
- Fix for Windows on ARM missing distlib binaries in pyproject.toml `#6240 <https://github.com/pypa/pipenv/issues/6240>`_

Vendored Libraries
------------------

- Clean up usage of click styling from exceptions, shell and virtualenv `#6178 <https://github.com/pypa/pipenv/issues/6178>`_
- Remove click.echo from pipenv/cli `#6182 <https://github.com/pypa/pipenv/issues/6182>`_
- Remove click.echo from exceptions.py `#6216 <https://github.com/pypa/pipenv/issues/6216>`_
- Update importlib-metadata to 8.4.0 `#6235 <https://github.com/pypa/pipenv/issues/6235>`_
2024.0.1 (2024-06-11)
=====================
Pipenv 2024.0.1 (2024-06-11)
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sphinx = "*"
sphinx-click = "==4.*"
sphinxcontrib-spelling = "==7.*"
click = "==8.0.3"
pypiserver = "==1.*"
stdeb = {version="*", sys_platform = "== 'linux'"}
zipp = {version = "==3.6.0", markers = "python_version < '3.10'"}
pre-commit = "==2.*"
Expand All @@ -29,6 +28,7 @@ pyyaml = "==6.0.1"
build = "*"
twine = "*"
semver = "*"
pypiserver = {ref = "pipenv-313", git = "https://github.com/matteius/pypiserver.git"}

[packages]
pytz = "*"
Expand Down
820 changes: 492 additions & 328 deletions Pipfile.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Security contact information

To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
1 change: 1 addition & 0 deletions news/6151.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable ``ResourceWarning`` warning for temporary files that are cleaned on program exit.
1 change: 1 addition & 0 deletions news/6171.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed package sorting when installing a package with extras.
1 change: 0 additions & 1 deletion news/6177.bugfix.rst

This file was deleted.

1 change: 0 additions & 1 deletion news/6178.vendor.rst

This file was deleted.

1 change: 0 additions & 1 deletion news/6182.vendor.rst

This file was deleted.

1 change: 1 addition & 0 deletions news/6185.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed ``pipenv uninstall --all`` failing when the virtual environment no longer exists.
1 change: 0 additions & 1 deletion news/6199.trivial.rst

This file was deleted.

1 change: 0 additions & 1 deletion news/6202.bugfix.rst

This file was deleted.

1 change: 1 addition & 0 deletions news/6242.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue where installing a vcs dependency using pipenv CLI yielded the wrong Pipfile entry such that it could not lock.
1 change: 1 addition & 0 deletions news/6243.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix report that pipenv requires ``packaging>=22`` on some systems by setting it as a dependency.
2 changes: 1 addition & 1 deletion pipenv/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# // ) ) / / // ) ) //___) ) // ) ) || / /
# //___/ / / / //___/ / // // / / || / /
# // / / // ((____ // / / ||/ /
__version__ = "2024.0.1"
__version__ = "2024.0.2"
3 changes: 2 additions & 1 deletion pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ def lock(ctx, state, **kwargs):
clear=state.clear,
pre=pre,
pypi_mirror=state.pypi_mirror,
write=not state.quiet,
write=True,
quiet=state.quiet,
categories=state.installstate.categories,
)

Expand Down
36 changes: 26 additions & 10 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from pipenv.patched.pip._vendor.packaging.specifiers import SpecifierSet
from pipenv.patched.pip._vendor.packaging.utils import canonicalize_name
from pipenv.patched.pip._vendor.packaging.version import parse as parse_version
from pipenv.patched.pip._vendor.typing_extensions import Iterable
from pipenv.utils import console
from pipenv.utils.fileutils import normalize_path, temp_path
from pipenv.utils.funktools import chunked, unnest
Expand Down Expand Up @@ -72,8 +73,9 @@ def __init__(
pipfile = project.parsed_pipfile
self.pipfile = pipfile
self.extra_dists = []
prefix = prefix if prefix else sys.prefix
self.prefix = Path(prefix)
if self.is_venv and prefix is not None and not Path(prefix).exists():
return
self.prefix = Path(prefix if prefix else sys.prefix)
self._base_paths = {}
if self.is_venv:
self._base_paths = self.get_paths()
Expand All @@ -96,11 +98,14 @@ def safe_import(self, name: str) -> ModuleType:
return module

@cached_property
def python_version(self) -> str:
with self.activated():
sysconfig = self.safe_import("sysconfig")
py_version = sysconfig.get_python_version()
return py_version
def python_version(self) -> str | None:
with self.activated() as active:
if active:
sysconfig = self.safe_import("sysconfig")
py_version = sysconfig.get_python_version()
return py_version
else:
return None

@property
def python_info(self) -> dict[str, str]:
Expand Down Expand Up @@ -703,9 +708,10 @@ def reverse_dependencies(self):
}
return rdeps

def get_working_set(self):
def get_working_set(self) -> Iterable:
"""Retrieve the working set of installed packages for the environment."""

if not hasattr(self, "sys_path"):
return []
return importlib_metadata.distributions(path=self.sys_path)

def is_installed(self, pkgname):
Expand Down Expand Up @@ -781,6 +787,16 @@ def activated(self):
to `os.environ["PATH"]` to ensure that calls to `~Environment.run()` use the
environment's path preferentially.
"""

# Fail if the virtualenv is needed but cannot be found
if self.is_venv and (
hasattr(self, "prefix")
and not self.prefix.exists()
or not hasattr(self, "prefix")
):
yield False
return

original_path = sys.path
original_prefix = sys.prefix
prefix = self.prefix.as_posix()
Expand All @@ -806,7 +822,7 @@ def activated(self):
sys.path = self.sys_path
sys.prefix = self.sys_prefix
try:
yield
yield True
finally:
sys.path = original_path
sys.prefix = original_prefix
2 changes: 1 addition & 1 deletion pipenv/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(self) -> None:
"""

# NOTE: +1 because of a temporary bug in Pipenv.
self.PIPENV_MAX_DEPTH = int(get_from_env("MAX_DEPTH", default=3)) + 1
self.PIPENV_MAX_DEPTH = int(get_from_env("MAX_DEPTH", default=10)) + 1
"""Maximum number of directories to recursively search for a Pipfile.
Default is 3. See also ``PIPENV_NO_INHERIT``.
Expand Down
2 changes: 1 addition & 1 deletion pipenv/pipenv.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "PIPENV" "1" "Jun 11, 2024" "2024.0.1" "pipenv"
.TH "PIPENV" "1" "Sep 13, 2024" "2024.0.2" "pipenv"
.sp
\fBNOTE:\fP
.INDENT 0.0
Expand Down
27 changes: 21 additions & 6 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from urllib.parse import unquote, urljoin

from pipenv.utils.constants import VCS_LIST
from pipenv.utils.dependencies import extract_vcs_url
from pipenv.vendor.tomlkit.items import SingleKey, Table

try:
import tomllib as toml
Expand Down Expand Up @@ -1107,12 +1109,23 @@ def get_package_name_in_pipfile(self, package_name, category):
return name
return None

def _sort_category(self, category):
# toml tables won't maintain sorted dictionary order
# so construct the table in the order that we need
def _sort_category(self, category) -> Table:
# copy table or create table from dict-like object
table = tomlkit.table()
for key, value in sorted(category.items()):
table.add(key, value)
if isinstance(category, Table):
table.update(category.value)
else:
table.update(category)

# sort the table internally
table._value._body.sort(key=lambda t: t[0] and t[0].key or "")
for index, (key, _) in enumerate(table._value._body):
assert isinstance(key, SingleKey)
indices = table._value._map[key]
if isinstance(indices, tuple):
table._value._map[key] = (index,) + indices[1:]
else:
table._value._map[key] = index

return table

Expand Down Expand Up @@ -1198,7 +1211,9 @@ def generate_package_pipfile_entry(self, package, pip_line, category=None):
vcs_parts = vcs_part.rsplit("@", 1)
if len(vcs_parts) > 1:
entry["ref"] = vcs_parts[1].split("#", 1)[0].strip()
entry[vcs] = vcs_parts[0].strip()
vcs_url = vcs_parts[0].strip()
vcs_url = extract_vcs_url(vcs_url)
entry[vcs] = vcs_url

# Check and extract subdirectory fragment
if package.link.subdirectory_fragment:
Expand Down
6 changes: 1 addition & 5 deletions pipenv/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import logging
import os
import sys

try:
from functools import cached_property
except ImportError:
cached_property = property
from functools import cached_property


def _ensure_modules():
Expand Down
12 changes: 4 additions & 8 deletions pipenv/routines/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def do_install(
requirements_directory = fileutils.create_tracked_tempdir(
suffix="-requirements", prefix="pipenv-"
)
warnings.filterwarnings("default", category=ResourceWarning)
warnings.filterwarnings("ignore", category=ResourceWarning)
packages = packages if packages else []
editable_packages = editable_packages if editable_packages else []
package_args = [p for p in packages if p] + [p for p in editable_packages if p]
Expand Down Expand Up @@ -630,15 +630,11 @@ def do_init(
packages=packages,
editable_packages=editable_packages,
)
# Write out the lockfile if it doesn't exist.
if not project.lockfile_exists:
# Write out the lockfile if it doesn't exist and skip_lock is False
if not project.lockfile_exists and not skip_lock:
# Unless we're in a virtualenv not managed by pipenv, abort if we're
# using the system's python.
if (
(system or allow_global)
and not (project.s.PIPENV_VIRTUALENV)
and skip_lock is False
):
if (system or allow_global) and not project.s.PIPENV_VIRTUALENV:
raise exceptions.PipenvOptionsError(
"--system",
"--system is intended to be used for Pipfile installation, "
Expand Down
38 changes: 20 additions & 18 deletions pipenv/routines/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def do_lock(
clear=False,
pre=False,
write=True,
quiet=False,
pypi_mirror=None,
categories=None,
extra_pip_args=None,
Expand Down Expand Up @@ -46,15 +47,15 @@ def do_lock(
packages = project.get_pipfile_section(pipfile_category)

if write:
# Alert the user of progress.
click.echo(
"{} {} {}".format(
click.style("Locking"),
click.style(f"[{pipfile_category}]", fg="yellow"),
click.style("dependencies..."),
),
err=True,
)
if not quiet: # Alert the user of progress.
click.echo(
"{} {} {}".format(
click.style("Locking"),
click.style(f"[{pipfile_category}]", fg="yellow"),
click.style("dependencies..."),
),
err=True,
)

# Prune old lockfile category as new one will be created.
with contextlib.suppress(KeyError):
Expand Down Expand Up @@ -89,15 +90,16 @@ def do_lock(
if write:
lockfile.update({"_meta": project.get_lockfile_meta()})
project.write_lockfile(lockfile)
click.echo(
"{}".format(
click.style(
f"Updated Pipfile.lock ({project.get_lockfile_hash()})!",
bold=True,
)
),
err=True,
)
if not quiet:
click.echo(
"{}".format(
click.style(
f"Updated Pipfile.lock ({project.get_lockfile_hash()})!",
bold=True,
)
),
err=True,
)
else:
return lockfile

Expand Down
2 changes: 1 addition & 1 deletion pipenv/routines/outdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def do_outdated(project, pypi_mirror=None, pre=False, clear=False):
if not outdated:
click.echo(click.style("All packages are up to date!", fg="green", bold=True))
sys.exit(0)
for package, new_version, old_version in outdated:
for package, old_version, new_version in outdated:
click.echo(
f"Package {package!r} out-of-date: {old_version!r} installed, {new_version!r} available."
)
Expand Down
Loading

0 comments on commit 25c5d36

Please sign in to comment.