Skip to content
Open
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
19 changes: 10 additions & 9 deletions conda_build/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@

from __future__ import annotations

import inspect

# imports are done locally to keep the api clean and limited strictly
# to conda-build's functionality.
import os
import sys
from collections.abc import Iterable
from importlib import import_module
from os.path import dirname, expanduser, join
from pathlib import Path
from typing import TYPE_CHECKING

# make the Config class available in the api namespace
from .config import DEFAULT_PREFIX_LENGTH as _prefix_length
from .config import Config, get_channel_urls, get_or_merge_config
from .deprecations import deprecated
from .metadata import MetaData, MetaDataTuple
from .utils import (
CONDA_PACKAGE_EXTENSIONS,
Expand Down Expand Up @@ -259,6 +263,7 @@ def test(
)


@deprecated("27.3", "27.9", addendum="Use `grayskull` instead.")
def list_skeletons() -> list[str]:
"""List available skeletons for generating conda recipes from external sources.

Expand All @@ -274,6 +279,7 @@ def list_skeletons() -> list[str]:
return files


@deprecated("27.3", "27.9", addendum="Use `grayskull` instead.")
def skeletonize(
packages: str | Iterable[str],
repo: Literal["cpan", "cran", "luarocks", "pypi", "rpm"],
Expand Down Expand Up @@ -306,18 +312,13 @@ def skeletonize(
# off of the config object, and pass it as a keyword argument. This is sort of the
# inverse of what we do in the CLI code - there we take CLI arguments and dangle them
# all on the config object as attributes.
module = getattr(
__import__(
"conda_build.skeletons", globals=globals(), locals=locals(), fromlist=[repo]
),
repo,
)

func_args = module.skeletonize.__code__.co_varnames
module = import_module(f"conda_build.skeletons.{repo}")
argspec = inspect.signature(module.skeletonize)
func_args = list(argspec.parameters)
kwargs = {name: getattr(config, name) for name in dir(config) if name in func_args}
kwargs.update({name: value for name, value in kwargs.items() if name in func_args})
# strip out local arguments that we pass directly
for arg in skeletonize.__code__.co_varnames:
for arg in list(inspect.signature(skeletonize).parameters):
if arg in kwargs:
del kwargs[arg]
with config:
Expand Down
5 changes: 5 additions & 0 deletions conda_build/cli/main_skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from .. import api
from ..config import Config
from ..deprecations import deprecated

if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
Expand All @@ -21,6 +22,8 @@
thisdir = os.path.dirname(os.path.abspath(__file__))
logging.basicConfig(level=logging.INFO)

deprecated.module("27.3", "27.9", addendum="Use the `grayskull` tool instead.")


def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]:
from conda.cli.conda_argparse import ArgumentParser
Expand All @@ -30,6 +33,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]:
description="""
Generates a boilerplate/skeleton recipe, which you can then edit to create a
full recipe. Some simple skeleton recipes may not even need edits.
Pending deprecation. Please use the `grayskull` tool instead: https://conda.github.io/grayskull
""",
epilog="""
Run --help on the subcommands like 'conda skeleton pypi --help' to see the
Expand All @@ -52,6 +56,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]:
return parser, parser.parse_args(args)


@deprecated("27.3", "27.9", addendum="Use `grayskull` instead.")
def execute(args: Sequence[str] | None = None) -> int:
parser, parsed = parse_args(args)
context.__init__(argparse_args=parsed)
Expand Down
2 changes: 2 additions & 0 deletions conda_build/skeletons/cpan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from .. import environ
from ..config import Config, get_or_merge_config
from ..deprecations import deprecated
from ..utils import check_call_env, on_linux, on_win
from ..variants import get_default_variant
from ..version import _parse as parse_version
Expand Down Expand Up @@ -384,6 +385,7 @@ def get_core_modules_for_this_perl_version(version, cache_dir):
)


@deprecated("27.3", "27.9", addendum="Use `grayskull` instead.")
# meta_cpan_url="http://api.metacpan.org",
def skeletonize(
packages: list[str],
Expand Down
3 changes: 3 additions & 0 deletions conda_build/skeletons/cran.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import requests
import yaml

from ..deprecations import deprecated

# try to import C dumper
try:
from yaml import CSafeDumper as SafeDumper
Expand Down Expand Up @@ -864,6 +866,7 @@ def remove_comments(template):
return "\n".join(lines_no_comments)


@deprecated("27.3", "27.9", addendum="Use `grayskull` instead.")
def skeletonize(
in_packages: list[str],
output_dir: str = ".",
Expand Down
3 changes: 3 additions & 0 deletions conda_build/skeletons/luarocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from glob import glob
from sys import platform as _platform

from ..deprecations import deprecated

INDENT = "\n - "

rockspec_parser = """
Expand Down Expand Up @@ -226,6 +228,7 @@ def ensure_base_deps(deps):
return deps


@deprecated("27.3", "27.9", addendum="Use `grayskull` instead.")
def skeletonize(
packages: list[str],
output_dir: str = ".",
Expand Down
2 changes: 2 additions & 0 deletions conda_build/skeletons/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from requests.packages.urllib3.util.url import parse_url

from ..config import Config
from ..deprecations import deprecated
from ..environ import create_env
from ..license_family import allowed_license_families, guess_license_family
from ..metadata import MetaData
Expand Down Expand Up @@ -258,6 +259,7 @@ def _formating_value(attribute_name, attribute_value):
return " " + str(attribute_value) + "\n"


@deprecated("27.3", "27.9", addendum="Use `grayskull` instead.")
def skeletonize(
packages: list[str],
output_dir: str = ".",
Expand Down
2 changes: 2 additions & 0 deletions conda_build/skeletons/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from urllib.request import urlopen
from xml.etree import ElementTree as ET

from ..deprecations import deprecated
from ..license_family import guess_license_family
from ..source import download_to_cache
from ..utils import ensure_list
Expand Down Expand Up @@ -714,6 +715,7 @@ def write_conda_recipe(
)


@deprecated("27.3", "27.9", addendum="Use `grayskull` instead.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since grayskull only provides PyPI and CRAN support, maybe we should soften the wording for the other backends?

def skeletonize(
packages: list[str],
output_dir: str = ".",
Expand Down
19 changes: 19 additions & 0 deletions news/6023-conda-skeleton-deprecation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### Deprecations

* Mark `conda skeleton` as pending deprecation, with removal scheduled in 27.9 release. Users are encouraged to use [grayskull](https://conda.github.io/grayskull) instead of `conda skeleton`. (#4460 via #6023)

### Docs

* <news item>

### Other

* <news item>
25 changes: 21 additions & 4 deletions tests/cli/test_main_skeleton.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (C) 2014 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import importlib
import os
import re
from pathlib import Path
Expand All @@ -13,7 +14,8 @@
@pytest.mark.sanity
def test_skeleton_pypi(testing_workdir, testing_config):
args = ["pypi", "peppercorn"]
main_skeleton.execute(args)
with pytest.deprecated_call():
main_skeleton.execute(args)
assert os.path.isdir("peppercorn")

# add setuptools to host dependencies
Expand All @@ -34,7 +36,8 @@ def test_skeleton_pypi(testing_workdir, testing_config):
@pytest.mark.sanity
def test_skeleton_pypi_compatible_versions(testing_workdir, testing_config):
args = ["pypi", "openshift"]
main_skeleton.execute(args)
with pytest.deprecated_call():
main_skeleton.execute(args)
assert os.path.isdir("openshift")


Expand All @@ -48,7 +51,8 @@ def test_skeleton_pypi_arguments_work(testing_workdir):
https://github.com/conda/conda-build/pull/1384
"""
args = ["pypi", "fasttext", "--version=0.9.2", "--pin-numpy"]
main_skeleton.execute(args)
with pytest.deprecated_call():
main_skeleton.execute(args)
assert os.path.isdir("fasttext")

# Deliberately bypass metadata reading in conda build to get as
Expand All @@ -63,10 +67,23 @@ def test_skeleton_pypi_arguments_work(testing_workdir):
"--setup-options=--offline",
"--extra-specs=extension-helpers",
]
main_skeleton.execute(args)
with pytest.deprecated_call():
main_skeleton.execute(args)
assert os.path.isdir("photutils")
# Check that the setup option occurs in bld.bat and build.sh.

metadata = api.render("photutils")[0][0]
assert "--offline" in metadata.meta["build"]["script"]
assert metadata.version() == "1.10.0"


def test_skeleton_deprecation_warning():
"""
Verify that importing conda_build.cli.main_skeleton will raise a deprecation warning.
"""
with pytest.deprecated_call(
match=r"conda_build.cli.main_skeleton is pending deprecation.*grayskull.*",
):
import conda_build.cli.main_skeleton # noqa F401

importlib.reload(conda_build.cli.main_skeleton)
16 changes: 10 additions & 6 deletions tests/test_api_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file makes sure that our API has not changed. Doing so can not be accidental. Whenever it
# happens, we should bump our major build number, because we may have broken someone.
import inspect
import sys
from inspect import getfullargspec as getargspec

Expand Down Expand Up @@ -86,22 +87,25 @@ def test_api_test():


def test_api_list_skeletons():
argspec = getargspec(api.list_skeletons)
assert argspec.args == []
assert argspec.defaults is None
sig = inspect.signature(api.list_skeletons)
assert list(sig.parameters) == []
assert all(p.default is inspect._empty for p in sig.parameters.values())


def test_api_skeletonize():
argspec = getargspec(api.skeletonize)
assert argspec.args == [
sig = inspect.signature(api.skeletonize)
assert list(sig.parameters) == [
"packages",
"repo",
"output_dir",
"version",
"recursive",
"config",
"kwargs",
]
assert argspec.defaults == (".", None, False, None)
assert tuple(
p.default for p in sig.parameters.values() if p.default is not inspect._empty
) == (".", None, False, None)


def test_api_develop():
Expand Down
Loading
Loading