Skip to content

Commit

Permalink
Merge branch 'main' into better-explicit-ux
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Jun 5, 2024
2 parents 5c48ae1 + 841d9d5 commit 07c87b6
Show file tree
Hide file tree
Showing 15 changed files with 6,211 additions and 9,159 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ repos:
# auto format Python codes within docstrings
- id: blacken-docs
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
rev: v0.4.4
hooks:
# lint & attempt to correct failures (e.g. pyupgrade)
- id: ruff
Expand All @@ -90,7 +90,7 @@ repos:
tests/
)
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.2
rev: 0.28.3
hooks:
# verify github syntaxes
- id: check-github-workflows
Expand Down
1 change: 1 addition & 0 deletions conda/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
DEFAULT_CHANNELS = DEFAULT_CHANNELS_WIN if on_win else DEFAULT_CHANNELS_UNIX

ROOT_ENV_NAME = "base"
UNUSED_ENV_NAME = "unused-env-name"

ROOT_NO_RM = (
"python",
Expand Down
2 changes: 1 addition & 1 deletion conda/cli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def add_parser_update_modifiers(solver_mode_options: ArgumentParser):
help="Exit early and do not run the solver if the requested specs are satisfied. "
"Also skips aggressive updates as configured by the "
"'aggressive_update_packages' config setting. Use "
"'conda info --describe aggressive_update_packages' to view your setting. "
"'conda config --describe aggressive_update_packages' to view your setting. "
"--satisfied-skip-solve is similar to the default behavior of 'pip install'.",
)
update_modifiers.add_argument(
Expand Down
19 changes: 15 additions & 4 deletions conda/cli/main_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def configure_parser(sub_parsers: _SubParsersAction, **kwargs) -> ArgumentParser
help="Create a new environment as a copy of an existing local environment.",
metavar="ENV",
)
solver_mode_options, _, channel_options = add_parser_create_install_update(
p, prefix_required=True
)
solver_mode_options, _, channel_options = add_parser_create_install_update(p)
add_parser_default_packages(solver_mode_options)
add_parser_platform(channel_options)
add_parser_solver(solver_mode_options)
Expand Down Expand Up @@ -100,14 +98,27 @@ def configure_parser(sub_parsers: _SubParsersAction, **kwargs) -> ArgumentParser

@notices
def execute(args: Namespace, parser: ArgumentParser) -> int:
import os
from tempfile import mktemp

from ..base.constants import UNUSED_ENV_NAME
from ..base.context import context
from ..common.path import paths_equal
from ..exceptions import CondaValueError
from ..exceptions import ArgumentError, CondaValueError
from ..gateways.disk.delete import rm_rf
from ..gateways.disk.test import is_conda_environment
from .common import confirm_yn
from .install import install

if not args.name and not args.prefix:
if context.dry_run:
args.prefix = os.path.join(mktemp(), UNUSED_ENV_NAME)
context.__init__(argparse_args=args)
else:
raise ArgumentError(
"one of the arguments -n/--name -p/--prefix is required"
)

if is_conda_environment(context.target_prefix):
if paths_equal(context.target_prefix, context.root_prefix):
raise CondaValueError("The target prefix is the base prefix. Aborting.")
Expand Down
10 changes: 9 additions & 1 deletion conda/plugins/subcommands/doctor/health_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,22 @@ def samefile(path1: Path, path2: Path) -> bool:
return False


def excluded_files_check(filename: str) -> bool:
excluded_extensions = (".pyc", ".pyo")
return filename.endswith(excluded_extensions)


def find_packages_with_missing_files(prefix: str | Path) -> dict[str, list[str]]:
"""Finds packages listed in conda-meta which have missing files."""
packages_with_missing_files = {}
prefix = Path(prefix)
for file in (prefix / "conda-meta").glob("*.json"):
for file_name in json.loads(file.read_text()).get("files", []):
# Add warnings if json file has missing "files"
if not (prefix / file_name).exists():
if (
not excluded_files_check(file_name)
and not (prefix / file_name).exists()
):
packages_with_missing_files.setdefault(file.stem, []).append(file_name)
return packages_with_missing_files

Expand Down
11 changes: 11 additions & 0 deletions docs/source/dev-guide/plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ API
For even more detailed information about our plugin system, please the see the
:doc:`Plugin API </dev-guide/api/conda/plugins/index>` section.

Error handling
--------------

Errors in ``conda`` are routed through :class:`conda.exception_handler.ExceptionHandler`, which can
print additional information about the ``conda`` installation when an *unexpected* exception is
found. These automatic reports can be really verbose and can get in the way of communicating
*expected* errors. See `this issue in conda-build`_ as an example.

To mark exceptions as *expected*, plugins should raise :class:`conda.CondaError` or a subclass
thereof. See [`conda_auth.exceptions`](https://github.com/conda-incubator/conda-auth/blob/0.2.1/conda_auth/exceptions.py) for an example.

A note on licensing
-------------------
Expand All @@ -142,3 +152,4 @@ which one to use, we advise communicating with a qualified legal professional.
.. _GPLv3: https://www.gnu.org/licenses/gpl-3.0.en.html
.. _`"Choose an Open Source License"`: https://choosealicense.com/
.. _`conda-plugins-template`: https://github.com/conda/conda-plugin-template
.. _`this issue in conda-build`: https://github.com/conda/conda-build/issues/5263
19 changes: 19 additions & 0 deletions news/13931-no-add-pyc-doctor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* Skip checking for `.pyc` and `.pyo` files in the `conda doctor` "missing files" health check. (#13370 via #13931)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
19 changes: 19 additions & 0 deletions news/13941-dry-run-name
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* Do not require `-n/--name` or `-p/--prefix` if `conda create` is invoked with `--dry-run`. (#13941)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
3 changes: 3 additions & 0 deletions news/13946-doc-help-text
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Docs

* Fixed the help text of the `satisfied-skip-solve` flag. (#13946)
19 changes: 19 additions & 0 deletions news/13950-doc-plugin-errors
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* Add a section explaining how to correctly raise exceptions from a plugin. (#13741 via #13950)

### Other

* <news item>
Loading

0 comments on commit 07c87b6

Please sign in to comment.