Skip to content

Commit

Permalink
Update deprecations (#5014)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard authored Sep 29, 2023
1 parent b471197 commit bb0ca2a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 50 deletions.
17 changes: 9 additions & 8 deletions conda_build/conda_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import configparser # noqa: F401
import os
import warnings
from functools import partial
from importlib import import_module # noqa: F401

Expand Down Expand Up @@ -78,6 +77,8 @@
from conda.models.channel import get_conda_build_local_url # noqa: F401
from conda.models.dist import Dist, IndexRecord # noqa: F401

from .deprecations import deprecated

# TODO: Go to references of all properties below and import them from `context` instead
binstar_upload = context.binstar_upload
default_python = context.default_python
Expand All @@ -104,21 +105,19 @@ class CrossPlatformStLink:
def __call__(self, path: str | os.PathLike) -> int:
return self.st_nlink(path)

@classmethod
def st_nlink(cls, path: str | os.PathLike) -> int:
warnings.warn(
"`conda_build.conda_interface.CrossPlatformStLink` is pending deprecation and will be removed in a "
"future release. Please use `os.stat().st_nlink` instead.",
PendingDeprecationWarning,
)
@staticmethod
@deprecated("3.24.0", "4.0.0", addendum="Use `os.stat().st_nlink` instead.")
def st_nlink(path: str | os.PathLike) -> int:
return os.stat(path).st_nlink


@deprecated("3.28.0", "4.0.0")
class SignatureError(Exception):
# TODO: What is this? 🤔
pass


@deprecated("3.28.0", "4.0.0")
def which_package(path):
"""
Given the path (of a (presumably) conda installed file) iterate over
Expand All @@ -137,6 +136,7 @@ def which_package(path):
yield dist


@deprecated("3.28.0", "4.0.0")
def which_prefix(path):
"""
Given the path (to a (presumably) conda installed file) return the
Expand All @@ -159,6 +159,7 @@ def which_prefix(path):
return prefix


@deprecated("3.28.0", "4.0.0")
def get_installed_version(prefix, pkgs):
"""
Primarily used by conda-forge, but may be useful in general for checking when
Expand Down
62 changes: 20 additions & 42 deletions conda_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
"""
Module to store conda build settings.
"""

import copy
import math
import os
import re
import shutil
import sys
import time
import warnings
from collections import namedtuple
from os.path import abspath, expanduser, expandvars, join

Expand All @@ -24,6 +22,7 @@
subdir,
url_path,
)
from .deprecations import deprecated
from .utils import get_build_folders, get_conda_operation_locks, get_logger, rm_rf
from .variants import get_default_variant

Expand Down Expand Up @@ -58,28 +57,20 @@ def set_invocation_time():
zstd_compression_level_default = 19


@deprecated("3.25.0", "4.0.0")
def python2_fs_encode(strin):
warnings.warn(
"`conda_build.config.python2_fs_encode` is pending deprecation and will be removed in a future release.",
PendingDeprecationWarning,
)
return strin


@deprecated(
"3.25.0",
"4.0.0",
addendum=(
"Use `pathlib.Path.mkdir(exist_ok=True)` or `os.makedirs(exist_ok=True)` "
"instead."
),
)
def _ensure_dir(path: os.PathLike):
"""Try to ensure a directory exists
Args:
path (os.PathLike): Path to directory
"""
# this can fail in parallel operation, depending on timing. Just try to make the dir,
# but don't bail if fail.
warnings.warn(
"`conda_build.config._ensure_dir` is pending deprecation and will be removed "
"in a future release. Please use `pathlib.Path.mkdir(exist_ok=True)` or "
"`os.makedirs(exist_ok=True)` instead",
PendingDeprecationWarning,
)
os.makedirs(path, exist_ok=True)


Expand Down Expand Up @@ -262,19 +253,6 @@ def _get_default_settings():
]


def print_function_deprecation_warning(func):
def func_wrapper(*args, **kw):
log = get_logger(__name__)
log.warn(
"WARNING: attribute {} is deprecated and will be removed in conda-build 4.0. "
"Please update your code - file issues on the conda-build issue tracker "
"if you need help.".format(func.__name__)
)
return func(*args, **kw)

return func_wrapper


class Config:
__file__ = __path__ = __file__
__package__ = __package__
Expand Down Expand Up @@ -516,56 +494,56 @@ def build_folder(self):

# back compat for conda-build-all - expects CONDA_* vars to be attributes of the config object
@property
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_LUA(self):
return self.variant.get("lua", get_default_variant(self)["lua"])

@CONDA_LUA.setter
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_LUA(self, value):
self.variant["lua"] = value

@property
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_PY(self):
value = self.variant.get("python", get_default_variant(self)["python"])
return int("".join(value.split(".")))

@CONDA_PY.setter
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_PY(self, value):
value = str(value)
self.variant["python"] = ".".join((value[0], value[1:]))

@property
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_NPY(self):
value = self.variant.get("numpy", get_default_variant(self)["numpy"])
return int("".join(value.split(".")))

@CONDA_NPY.setter
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_NPY(self, value):
value = str(value)
self.variant["numpy"] = ".".join((value[0], value[1:]))

@property
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_PERL(self):
return self.variant.get("perl", get_default_variant(self)["perl"])

@CONDA_PERL.setter
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_PERL(self, value):
self.variant["perl"] = value

@property
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_R(self):
return self.variant.get("r_base", get_default_variant(self)["r_base"])

@CONDA_R.setter
@print_function_deprecation_warning
@deprecated("3.0.28", "4.0.0")
def CONDA_R(self, value):
self.variant["r_base"] = value

Expand Down

0 comments on commit bb0ca2a

Please sign in to comment.