Skip to content

Commit

Permalink
Convert all absolute imports to relative (conda#13281)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard authored Nov 6, 2023
1 parent d08da5a commit b230e5e
Show file tree
Hide file tree
Showing 29 changed files with 87 additions and 101 deletions.
2 changes: 1 addition & 1 deletion conda/_vendor/cpuinfo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import sys
from conda._vendor.cpuinfo.cpuinfo import *
from .cpuinfo import *


2 changes: 1 addition & 1 deletion conda/base/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def os_distribution_name_version(self):
# 'Windows', '10.0.17134'
platform_name = self.platform_system_release[0]
if platform_name == "Linux":
from conda._vendor.distro import id, version
from .._vendor.distro import id, version

try:
distinfo = id(), version(best=True)
Expand Down
2 changes: 1 addition & 1 deletion conda/common/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def env_vars(var_map=None, callback=None, stack_callback=None):
@contextmanager
def env_var(name, value, callback=None, stack_callback=None):
# Maybe, but in env_vars, not here:
# from conda.common.compat import ensure_fs_path_encoding
# from .compat import ensure_fs_path_encoding
# d = dict({name: ensure_fs_path_encoding(value)})
d = {name: value}
with env_vars(d, callback=callback, stack_callback=stack_callback) as es:
Expand Down
3 changes: 1 addition & 2 deletions conda/common/pkg_formats/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
from os.path import basename, dirname, isdir, isfile, join, lexists
from posixpath import normpath as posix_normpath

from conda.common.iterators import groupby_to_dict as groupby

from ... import CondaError
from ..._vendor.frozendict import frozendict
from ...auxlib.decorators import memoizedproperty
from ..compat import open
from ..iterators import groupby_to_dict as groupby
from ..path import (
get_major_minor_version,
get_python_site_packages_short_path,
Expand Down
2 changes: 1 addition & 1 deletion conda/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _supplement_index_with_system(index):


def get_archspec_name():
from conda.base.context import _arch_names, _platform_map, non_x86_machines
from ..base.context import _arch_names, _platform_map, non_x86_machines

target_plat, target_arch = context.subdir.split("-")
# This has to reverse what Context.subdir is doing
Expand Down
3 changes: 1 addition & 2 deletions conda/core/package_cache_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from sys import platform
from tarfile import ReadError

from conda.common.iterators import groupby_to_dict as groupby

from .. import CondaError, CondaMultiError, conda_signal_handler
from ..auxlib.collection import first
from ..auxlib.decorators import memoizemethod
Expand All @@ -31,6 +29,7 @@
from ..base.context import context
from ..common.constants import NULL
from ..common.io import IS_INTERACTIVE, ProgressBar, time_recorder
from ..common.iterators import groupby_to_dict as groupby
from ..common.path import expand, strip_pkg_extension, url_to_path
from ..common.signals import signal_handler
from ..common.url import path_to_url
Expand Down
3 changes: 1 addition & 2 deletions conda/core/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
except ImportError: # pragma: no cover
from .._vendor.boltons.setutils import IndexedSet

from conda.common.iterators import groupby_to_dict as groupby

from .. import CondaError
from .. import __version__ as CONDA_VERSION
from ..auxlib.decorators import memoizedproperty
Expand All @@ -25,6 +23,7 @@
from ..base.context import context
from ..common.constants import NULL
from ..common.io import Spinner, dashlist, time_recorder
from ..common.iterators import groupby_to_dict as groupby
from ..common.path import get_major_minor_version, paths_equal
from ..exceptions import (
PackagesNotFoundError,
Expand Down
25 changes: 12 additions & 13 deletions conda/core/subdir_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@
except ImportError: # pragma: no cover
from .._vendor.boltons.setutils import IndexedSet

from conda.gateways.repodata import (
from ..auxlib.ish import dals
from ..base.constants import CONDA_PACKAGE_EXTENSION_V1, REPODATA_FN
from ..base.context import context
from ..common.io import DummyExecutor, ThreadLimitedThreadPoolExecutor, dashlist
from ..common.iterators import groupby_to_dict as groupby
from ..common.path import url_to_path
from ..common.url import join_url
from ..deprecations import deprecated
from ..exceptions import CondaUpgradeError, UnavailableInvalidChannel
from ..gateways.disk.delete import rm_rf
from ..gateways.repodata import (
CACHE_STATE_SUFFIX,
CondaRepoInterface,
RepodataCache,
Expand All @@ -32,20 +42,9 @@
create_cache_dir,
get_repo_interface,
)
from conda.gateways.repodata import (
from ..gateways.repodata import (
get_cache_control_max_age as _get_cache_control_max_age,
)

from ..auxlib.ish import dals
from ..base.constants import CONDA_PACKAGE_EXTENSION_V1, REPODATA_FN
from ..base.context import context
from ..common.io import DummyExecutor, ThreadLimitedThreadPoolExecutor, dashlist
from ..common.iterators import groupby_to_dict as groupby
from ..common.path import url_to_path
from ..common.url import join_url
from ..deprecations import deprecated
from ..exceptions import CondaUpgradeError, UnavailableInvalidChannel
from ..gateways.disk.delete import rm_rf
from ..models.channel import Channel, all_channel_urls
from ..models.match_spec import MatchSpec
from ..models.records import PackageRecord
Expand Down
3 changes: 1 addition & 2 deletions conda/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
import requests
from requests.exceptions import JSONDecodeError

from conda.common.iterators import groupby_to_dict as groupby

from . import CondaError, CondaExitZero, CondaMultiError
from .auxlib.entity import EntityEncoder
from .auxlib.ish import dals
from .auxlib.logz import stringify
from .base.constants import COMPATIBLE_SHELLS, PathConflict, SafetyChecks
from .common.compat import on_win
from .common.io import dashlist
from .common.iterators import groupby_to_dict as groupby
from .common.signals import get_signal_name
from .common.url import join_url, maybe_unquote
from .deprecations import DeprecatedError # noqa: F401
Expand Down
3 changes: 1 addition & 2 deletions conda/gateways/connection/adapters/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
from io import BytesIO, StringIO
from logging import getLogger

from conda.deprecations import deprecated

from ....common.url import urlparse
from ....deprecations import deprecated
from ....exceptions import AuthenticationError
from .. import BaseAdapter, Response, dispatch_hook

Expand Down
3 changes: 1 addition & 2 deletions conda/gateways/connection/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from os.path import basename, exists, join
from pathlib import Path

from conda.gateways.disk.lock import lock

from ... import CondaError
from ...auxlib.ish import dals
from ...auxlib.logz import stringify
Expand All @@ -29,6 +27,7 @@
maybe_raise,
)
from ..disk.delete import rm_rf
from ..disk.lock import lock
from . import (
ConnectionError,
HTTPError,
Expand Down
6 changes: 3 additions & 3 deletions conda/gateways/disk/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ def compile_multiple_pyc(
command[0:0] = [python_exe_full_path]
# command[0:0] = ['--cwd', prefix, '--dev', '-p', prefix, python_exe_full_path]
log.trace(command)
from conda.gateways.subprocess import any_subprocess
from ..subprocess import any_subprocess

# from conda.common.io import env_vars
# from ...common.io import env_vars
# This stack does not maintain its _argparse_args correctly?
# from conda.base.context import stack_context_default
# from ...base.context import stack_context_default
# with env_vars({}, stack_context_default):
# stdout, stderr, rc = run_command(Commands.RUN, *command)
stdout, stderr, rc = any_subprocess(command, prefix)
Expand Down
4 changes: 2 additions & 2 deletions conda/gateways/disk/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def rmtree(path, *args, **kwargs):
try:
# Try to delete in Unicode
name = None
from conda.auxlib.compat import Utf8NamedTemporaryFile
from conda.utils import quote_for_shell
from ...auxlib.compat import Utf8NamedTemporaryFile
from ...utils import quote_for_shell

with Utf8NamedTemporaryFile(
mode="w", suffix=".bat", delete=False
Expand Down
2 changes: 1 addition & 1 deletion conda/gateways/disk/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import warnings
from contextlib import contextmanager

from conda.base.context import context
from ...base.context import context

LOCK_BYTE = 21 # mamba interop
LOCK_ATTEMPTS = 10
Expand Down
7 changes: 3 additions & 4 deletions conda/gateways/repodata/jlap/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
import zstandard
from requests import HTTPError

from conda.base.context import context
from conda.gateways.connection import Response, Session
from conda.gateways.repodata import (
from ....base.context import context
from ...connection import Response, Session
from .. import (
ETAG_KEY,
LAST_MODIFIED_KEY,
RepodataCache,
RepodataState,
)

from .core import JLAP

log = logging.getLogger(__name__)
Expand Down
7 changes: 3 additions & 4 deletions conda/gateways/repodata/jlap/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
import logging
import os

from conda.base.context import context
from conda.gateways.connection.download import disable_ssl_verify_warning
from conda.gateways.connection.session import get_session

from ....base.context import context
from ...connection.download import disable_ssl_verify_warning
from ...connection.session import get_session
from .. import (
CACHE_CONTROL_KEY,
ETAG_KEY,
Expand Down
2 changes: 1 addition & 1 deletion conda/gateways/repodata/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
Moved to prevent circular imports.
"""
from conda.gateways.disk.lock import lock # noqa
from ..disk.lock import lock # noqa: F401
3 changes: 1 addition & 2 deletions conda/gateways/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
from os.path import abspath
from subprocess import PIPE, CalledProcessError, Popen

from conda.auxlib.compat import shlex_split_unicode

from .. import ACTIVE_SUBPROCESSES
from ..auxlib.compat import shlex_split_unicode
from ..auxlib.ish import dals
from ..base.context import context
from ..common.compat import encode_arguments, encode_environment, isiterable
Expand Down
3 changes: 1 addition & 2 deletions conda/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
from os.path import isdir, isfile, join
from textwrap import dedent

from conda.common.iterators import groupby_to_dict as groupby

from . import __version__ as CONDA_VERSION
from .auxlib.ish import dals
from .base.constants import DEFAULTS_CHANNEL_NAME
from .base.context import context
from .common.compat import ensure_text_type, open
from .common.iterators import groupby_to_dict as groupby
from .common.path import paths_equal
from .core.prefix_data import PrefixData
from .exceptions import CondaHistoryError, NotWritableError
Expand Down
3 changes: 1 addition & 2 deletions conda/models/match_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
from operator import attrgetter
from os.path import basename

from conda.common.iterators import groupby_to_dict as groupby

from ..auxlib.collection import frozendict
from ..auxlib.decorators import memoizedproperty
from ..base.constants import CONDA_PACKAGE_EXTENSION_V1, CONDA_PACKAGE_EXTENSION_V2
from ..base.context import context
from ..common.compat import isiterable
from ..common.io import dashlist
from ..common.iterators import groupby_to_dict as groupby
from ..common.path import expand, is_package_file, strip_pkg_extension, url_to_path
from ..common.url import is_url, path_to_url, unquote
from ..exceptions import CondaValueError, InvalidMatchSpec
Expand Down
6 changes: 3 additions & 3 deletions conda/plugins/subcommands/doctor/health_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from logging import getLogger
from pathlib import Path

from conda.core.envs_manager import get_user_environments_txt_file
from conda.exceptions import CondaError
from conda.gateways.disk.read import compute_sum
from ....core.envs_manager import get_user_environments_txt_file
from ....exceptions import CondaError
from ....gateways.disk.read import compute_sum

logger = getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions conda/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

from tqdm import tqdm

from conda.common.iterators import groupby_to_dict as groupby

from ._vendor.frozendict import FrozenOrderedDict as frozendict
from .auxlib.decorators import memoizemethod
from .base.constants import MAX_CHANNEL_PRIORITY, ChannelPriority, SatSolverChoice
from .base.context import context
from .common.compat import on_win
from .common.io import dashlist, time_recorder
from .common.iterators import groupby_to_dict as groupby
from .common.logic import (
TRUE,
Clauses,
Expand Down
13 changes: 6 additions & 7 deletions conda/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
import pytest
from pytest import CaptureFixture

from conda.base.context import context, reset_context
from conda.cli.main import init_loggers
from conda.common.compat import on_win

from ..base.context import context, reset_context
from ..cli.main import init_loggers
from ..common.compat import on_win
from ..deprecations import deprecated


Expand Down Expand Up @@ -73,7 +72,7 @@ def conda_ensure_sys_python_is_base_env_python():

def conda_move_to_front_of_PATH():
if "CONDA_PREFIX" in os.environ:
from conda.activate import CmdExeActivator, PosixActivator
from ..activate import CmdExeActivator, PosixActivator

if os.name == "nt":
activator_cls = CmdExeActivator
Expand Down Expand Up @@ -147,7 +146,7 @@ def conda_check_versions_aligned():
try:
cmd = join(pe, git_exe) + " describe --tags --long"
version_from_git = check_output(cmd).decode("utf-8").split("\n")[0]
from conda.auxlib.packaging import _get_version_from_git_tag
from ..auxlib.packaging import _get_version_from_git_tag

version_from_git = _get_version_from_git_tag(version_from_git)
break
Expand Down Expand Up @@ -203,7 +202,7 @@ def __call__(self, *argv: str) -> tuple[str, str, int]:

# all other subcommands
else:
from conda.cli.main import main_subshell
from ..cli.main import main_subshell

# run command
code = main_subshell(*argv)
Expand Down
14 changes: 7 additions & 7 deletions conda/testing/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import py
import pytest

from conda.auxlib.ish import dals
from conda.base.context import conda_tests_ctxt_mgmt_def_pol, context, reset_context
from conda.common.configuration import YamlRawParameter
from conda.common.io import env_vars
from conda.common.serialize import yaml_round_trip_load
from conda.core.subdir_data import SubdirData
from conda.gateways.disk.create import TemporaryDirectory
from ..auxlib.ish import dals
from ..base.context import conda_tests_ctxt_mgmt_def_pol, context, reset_context
from ..common.configuration import YamlRawParameter
from ..common.io import env_vars
from ..common.serialize import yaml_round_trip_load
from ..core.subdir_data import SubdirData
from ..gateways.disk.create import TemporaryDirectory


@pytest.fixture(autouse=True)
Expand Down
4 changes: 2 additions & 2 deletions conda/testing/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

import pytest

from conda.auxlib.compat import shlex_split_unicode
from conda.deprecations import deprecated
from conda_env.cli import main as conda_env_cli

from .. import cli
from ..auxlib.compat import shlex_split_unicode
from ..base.context import conda_tests_ctxt_mgmt_def_pol, context, reset_context
from ..common.compat import encode_arguments
from ..common.io import argv, env_var
from ..common.io import captured as common_io_captured
from ..core.prefix_data import PrefixData
from ..core.subdir_data import SubdirData, make_feature_record
from ..deprecations import deprecated
from ..gateways.disk.delete import rm_rf
from ..gateways.disk.read import lexists
from ..gateways.logging import initialize_logging
Expand Down
Loading

0 comments on commit b230e5e

Please sign in to comment.