diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 80caa4cdea..cfa10453e6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -69,7 +69,7 @@ jobs: fail-fast: false matrix: # test all lower versions (w/ stable conda) and upper version (w/ canary conda) - python-version: ['3.9', '3.10'] + python-version: ['3.9', '3.10', '3.11'] conda-version: [release] test-type: [serial, parallel] include: @@ -81,10 +81,10 @@ jobs: conda-version: 22.11.0 test-type: parallel # maximum Python/conda combo - - python-version: '3.11' + - python-version: '3.12' conda-version: canary test-type: serial - - python-version: '3.11' + - python-version: '3.12' conda-version: canary test-type: parallel env: @@ -173,10 +173,10 @@ jobs: conda-version: [release] test-type: [serial, parallel] include: - - python-version: '3.11' + - python-version: '3.12' conda-version: canary test-type: serial - - python-version: '3.11' + - python-version: '3.12' conda-version: canary test-type: parallel env: @@ -270,10 +270,10 @@ jobs: conda-version: [release] test-type: [serial, parallel] include: - - python-version: '3.11' + - python-version: '3.12' conda-version: canary test-type: serial - - python-version: '3.11' + - python-version: '3.12' conda-version: canary test-type: parallel env: @@ -426,10 +426,10 @@ jobs: clean: true fetch-depth: 0 - # Explicitly use Python 3.11 since each of the OSes has a different default Python + # Explicitly use Python 3.12 since each of the OSes has a different default Python - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.12' - name: Detect label shell: python diff --git a/conda_build/_load_setup_py_data.py b/conda_build/_load_setup_py_data.py index efeb14c69d..9180c404fc 100644 --- a/conda_build/_load_setup_py_data.py +++ b/conda_build/_load_setup_py_data.py @@ -90,6 +90,8 @@ def setup(**kw): del sys.modules["versioneer"] try: + # numpy.distutils deprecated in Python 3.12+ + # see https://numpy.org/doc/stable/reference/distutils_status_migration.html import numpy.distutils.core numpy_setup = numpy.distutils.core.setup diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index fe69e09d23..fbe59199b3 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -558,7 +558,7 @@ def add_parser(repos): action="store", default=default_python, help="""Version of Python to use to run setup.py. Default is %(default)s.""", - choices=["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"], + choices=["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"], ) pypi.add_argument( @@ -1371,39 +1371,40 @@ def run_setuppy(src_dir, temp_dir, python_version, extra_specs, config, setup_op with open(patch, "wb") as f: f.write(DISTUTILS_PATCH.format(temp_dir.replace("\\", "\\\\")).encode("utf-8")) - if exists(join(stdlib_dir, "distutils", "core.py-copy")): - rm_rf(join(stdlib_dir, "distutils", "core.py")) - copy2( - join(stdlib_dir, "distutils", "core.py-copy"), - join(stdlib_dir, "distutils", "core.py"), - ) - # Avoid race conditions. Invalidate the cache. - rm_rf( - join( - stdlib_dir, - "distutils", - "__pycache__", - f"core.cpython-{sys.version_info[0]}{sys.version_info[1]}.pyc", + # distutils deprecated in Python 3.10+, removed in Python 3.12+ + distutils = join(stdlib_dir, "distutils") + if isdir(distutils): + if exists(join(distutils, "core.py-copy")): + rm_rf(join(distutils, "core.py")) + copy2( + join(distutils, "core.py-copy"), + join(distutils, "core.py"), ) - ) - rm_rf( - join( - stdlib_dir, - "distutils", - "__pycache__", - f"core.cpython-{sys.version_info[0]}{sys.version_info[1]}.pyo", + # Avoid race conditions. Invalidate the cache. + rm_rf( + join( + distutils, + "__pycache__", + f"core.cpython-{sys.version_info[0]}{sys.version_info[1]}.pyc", + ) ) - ) - else: - copy2( - join(stdlib_dir, "distutils", "core.py"), - join(stdlib_dir, "distutils", "core.py-copy"), - ) - apply_patch(join(stdlib_dir, "distutils"), patch, config=config) + rm_rf( + join( + distutils, + "__pycache__", + f"core.cpython-{sys.version_info[0]}{sys.version_info[1]}.pyo", + ) + ) + else: + copy2( + join(distutils, "core.py"), + join(distutils, "core.py-copy"), + ) + apply_patch(distutils, patch, config=config) - vendored = join(stdlib_dir, "site-packages", "setuptools", "_distutils") - if os.path.isdir(vendored): - apply_patch(vendored, patch, config=config) + setuptools = join(stdlib_dir, "site-packages", "setuptools", "_distutils") + if isdir(setuptools): + apply_patch(setuptools, patch, config=config) # Save PYTHONPATH for later env = os.environ.copy() diff --git a/conda_build/variants.py b/conda_build/variants.py index 8cf2c007cc..d798a6e79a 100644 --- a/conda_build/variants.py +++ b/conda_build/variants.py @@ -18,14 +18,24 @@ DEFAULT_VARIANTS = { "python": f"{sys.version_info.major}.{sys.version_info.minor}", - "numpy": "1.22", + "numpy": { + # (python): numpy_version, # range of versions built for given python + (3, 8): "1.22", # 1.19-1.24 + (3, 9): "1.22", # 1.19-1.26 + (3, 10): "1.22", # 1.21-1.26 + (3, 11): "1.23", # 1.23-1.26 + (3, 12): "1.26", # 1.26- + }.get(sys.version_info[:2], "1.26"), # this one actually needs to be pretty specific. The reason is that cpan skeleton uses the # version to say what's in their standard library. "perl": "5.26.2", "lua": "5", "r_base": "3.4" if on_win else "3.5", "cpu_optimization_target": "nocona", - "pin_run_as_build": OrderedDict(python=OrderedDict(min_pin="x.x", max_pin="x.x")), + "pin_run_as_build": { + "python": {"min_pin": "x.x", "max_pin": "x.x"}, + "r-base": {"min_pin": "x.x", "max_pin": "x.x"}, + }, "ignore_version": [], "ignore_build_only_deps": ["python", "numpy"], "extend_keys": [ @@ -37,11 +47,6 @@ "cran_mirror": "https://cran.r-project.org", } -# set this outside the initialization because of the dash in the key -DEFAULT_VARIANTS["pin_run_as_build"]["r-base"] = OrderedDict( - min_pin="x.x", max_pin="x.x" -) - # map python version to default compiler on windows, to match upstream python # This mapping only sets the "native" compiler, and can be overridden by specifying a compiler # in the conda-build variant configuration diff --git a/pyproject.toml b/pyproject.toml index 8b55ee4168..5fc2f3eac5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ] diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml index a75aff37d1..42847d7ead 100644 --- a/recipe/conda_build_config.yaml +++ b/recipe/conda_build_config.yaml @@ -1,5 +1,6 @@ python: - - 3.8 - - 3.9 - - 3.10 - - 3.11 + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" diff --git a/tests/cli/test_main_build.py b/tests/cli/test_main_build.py index 59a080eace..90d1c4a629 100644 --- a/tests/cli/test_main_build.py +++ b/tests/cli/test_main_build.py @@ -1,33 +1,29 @@ # Copyright (C) 2014 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause +from __future__ import annotations + import os import re from pathlib import Path import pytest +from pytest import FixtureRequest, MonkeyPatch +from pytest_mock import MockerFixture -import conda_build from conda_build import api from conda_build.cli import main_build, main_render -from conda_build.conda_interface import ( - TemporaryDirectory, - cc_conda_build, - context, - reset_context, +from conda_build.conda_interface import TemporaryDirectory +from conda_build.config import ( + Config, + zstd_compression_level_default, ) -from conda_build.config import Config, zstd_compression_level_default from conda_build.exceptions import DependencyNeedsBuildingError +from conda_build.metadata import MetaData +from conda_build.os_utils.external import find_executable from conda_build.utils import get_build_folders, on_win, package_has_file from ..utils import metadata_dir - - -def _reset_config(search_path=None): - reset_context(search_path) - cc_conda_build.clear() - cc_conda_build.update( - context.conda_build if hasattr(context, "conda_build") else {} - ) +from ..utils import reset_config as _reset_config @pytest.mark.sanity @@ -266,25 +262,42 @@ def test_purge_all(testing_workdir, testing_metadata): @pytest.mark.serial -def test_no_force_upload(mocker, testing_workdir, testing_metadata, request): - with open(os.path.join(testing_workdir, ".condarc"), "w") as f: - f.write("anaconda_upload: True\n") - f.write("conda_build:\n") - f.write(" force_upload: False\n") - del testing_metadata.meta["test"] - api.output_yaml(testing_metadata, "meta.yaml") - args = ["--no-force-upload", testing_workdir] - call = mocker.patch.object(conda_build.build.subprocess, "call") +def test_no_force_upload( + mocker: MockerFixture, + monkeypatch: MonkeyPatch, + testing_workdir: str | os.PathLike | Path, + testing_metadata: MetaData, + request: FixtureRequest, +): + # this is nearly identical to tests/test_api_build.py::test_no_force_upload + # only difference is this tests `conda_build.cli.main_build.execute` request.addfinalizer(_reset_config) - _reset_config([os.path.join(testing_workdir, ".condarc")]) - main_build.execute(args) + call = mocker.patch("subprocess.call") + anaconda = find_executable("anaconda") + + # render recipe + api.output_yaml(testing_metadata, "meta.yaml") pkg = api.get_output_file_path(testing_metadata) - assert call.called_once_with(["anaconda", "upload", pkg]) - args = [testing_workdir] - with open(os.path.join(testing_workdir, ".condarc"), "w") as f: - f.write("anaconda_upload: True\n") - main_build.execute(args) - assert call.called_once_with(["anaconda", "upload", "--force", pkg]) + + # mock Config.set_keys to always set anaconda_upload to True + # conda's Context + conda_build's MetaData & Config objects interact in such an + # awful way that mocking these configurations is ugly and confusing, all of it + # needs major refactoring + set_keys = Config.set_keys # store original method + monkeypatch.setattr( + Config, + "set_keys", + lambda self, **kwargs: set_keys(self, **{**kwargs, "anaconda_upload": True}), + ) + + # check for normal upload + main_build.execute(["--no-force-upload", testing_workdir]) + call.assert_called_once_with([anaconda, "upload", *pkg]) + call.reset_mock() + + # check for force upload + main_build.execute([testing_workdir]) + call.assert_called_once_with([anaconda, "upload", "--force", *pkg]) @pytest.mark.slow diff --git a/tests/cli/test_main_skeleton.py b/tests/cli/test_main_skeleton.py index 64eb300878..0333d77c1f 100644 --- a/tests/cli/test_main_skeleton.py +++ b/tests/cli/test_main_skeleton.py @@ -34,20 +34,26 @@ def test_skeleton_pypi_arguments_work(testing_workdir): https://github.com/conda/conda-build/pull/1384 """ - args = ["pypi", "msumastro", "--version=1.1.6", "--pin-numpy"] + args = ["pypi", "fasttext", "--version=0.9.2", "--pin-numpy"] main_skeleton.execute(args) - assert os.path.isdir("msumastro") + assert os.path.isdir("fasttext") # Deliberately bypass metadata reading in conda build to get as # close to the "ground truth" as possible. - with open(os.path.join("msumastro", "meta.yaml")) as f: + with open(os.path.join("fasttext", "meta.yaml")) as f: assert f.read().count("numpy x.x") == 2 - args = ["pypi", "photutils", "--version=0.2.2", "--setup-options=--offline"] + args = [ + "pypi", + "photutils", + "--version=1.10.0", + "--setup-options=--offline", + "--extra-specs=extension-helpers", + ] main_skeleton.execute(args) assert os.path.isdir("photutils") # Check that the setup option occurs in bld.bat and build.sh. m = api.render("photutils")[0][0] assert "--offline" in m.meta["build"]["script"] - assert m.version() == "0.2.2" + assert m.version() == "1.10.0" diff --git a/tests/requirements.txt b/tests/requirements.txt index a7140e8673..a4ecdd07a8 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,7 +1,7 @@ -anaconda-client beautifulsoup4 chardet conda >=22.11.0 +conda-forge::anaconda-client conda-index conda-package-handling >=1.3 conda-verify diff --git a/tests/test-recipes/metadata/source_setup_py_data/bld.bat b/tests/test-recipes/metadata/source_setup_py_data/bld.bat index 4168d5d6f0..3399daa92d 100644 --- a/tests/test-recipes/metadata/source_setup_py_data/bld.bat +++ b/tests/test-recipes/metadata/source_setup_py_data/bld.bat @@ -6,6 +6,6 @@ if errorlevel 1 exit 1 for /f "delims=" %%i in ('git describe') do set gitdesc=%%i if errorlevel 1 exit 1 echo "%gitdesc%" -if not "%gitdesc%"=="1.21.0" exit 1 +if not "%gitdesc%"=="1.22.0" exit 1 echo "%PKG_VERSION%" -if not "%PKG_VERSION%"=="1.21.0" exit 1 +if not "%PKG_VERSION%"=="1.22.0" exit 1 diff --git a/tests/test-recipes/metadata/source_setup_py_data/build.sh b/tests/test-recipes/metadata/source_setup_py_data/build.sh index ecde5ca3c3..3c8cd9361a 100644 --- a/tests/test-recipes/metadata/source_setup_py_data/build.sh +++ b/tests/test-recipes/metadata/source_setup_py_data/build.sh @@ -3,6 +3,6 @@ # Ensure we are in a git repo [ -d .git ] git describe -[ "$(git describe)" = 1.21.0 ] +[ "$(git describe)" = 1.22.0 ] echo "\$PKG_VERSION = $PKG_VERSION" -[ "${PKG_VERSION}" = 1.21.0 ] +[ "${PKG_VERSION}" = 1.22.0 ] diff --git a/tests/test-recipes/metadata/source_setup_py_data/meta.yaml b/tests/test-recipes/metadata/source_setup_py_data/meta.yaml index d4a3b21e7b..459c19ba74 100644 --- a/tests/test-recipes/metadata/source_setup_py_data/meta.yaml +++ b/tests/test-recipes/metadata/source_setup_py_data/meta.yaml @@ -12,7 +12,7 @@ package: source: git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }} - git_tag: 1.21.0 + git_tag: 1.22.0 build: entry_points: diff --git a/tests/test-recipes/published_code/building_jinja2_setup_py_data/meta.yaml b/tests/test-recipes/published_code/building_jinja2_setup_py_data/meta.yaml index 8596e5c574..9d7b9dd2df 100644 --- a/tests/test-recipes/published_code/building_jinja2_setup_py_data/meta.yaml +++ b/tests/test-recipes/published_code/building_jinja2_setup_py_data/meta.yaml @@ -8,7 +8,7 @@ package: # Example assumes that this folder has setup.py in it source: git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }} - git_tag: 1.21.0 + git_tag: 1.22.0 requirements: build: diff --git a/tests/test_api_build.py b/tests/test_api_build.py index 856cc4fa1c..1ac2ca06d2 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -3,6 +3,8 @@ """ This module tests the build API. These are high-level integration tests. """ +from __future__ import annotations + import json import logging import os @@ -25,15 +27,15 @@ from binstar_client.errors import NotFound from conda.common.compat import on_linux, on_mac, on_win from conda.exceptions import ClobberError, CondaMultiError +from pytest import FixtureRequest, MonkeyPatch +from pytest_mock import MockerFixture -import conda_build from conda_build import __version__, api, exceptions from conda_build.conda_interface import ( CONDA_VERSION, CondaError, LinkError, VersionOrder, - cc_conda_build, context, reset_context, url_path, @@ -45,6 +47,7 @@ OverDependingError, OverLinkingError, ) +from conda_build.metadata import MetaData from conda_build.os_utils.external import find_executable from conda_build.render import finalize_metadata from conda_build.utils import ( @@ -66,6 +69,7 @@ get_valid_recipes, metadata_dir, metadata_path, + reset_config, ) @@ -437,7 +441,7 @@ def test_checkout_tool_as_dependency(testing_workdir, testing_config, monkeypatc platforms = ["64" if sys.maxsize > 2**32 else "32"] if sys.platform == "win32": platforms = sorted({"32", *platforms}) - compilers = ["3.10", "3.11"] + compilers = ["3.10", "3.11", "3.12"] msvc_vers = ["14.0"] else: msvc_vers = [] @@ -599,6 +603,10 @@ def test_build_metadata_object(testing_metadata): @pytest.mark.serial +@pytest.mark.skipif( + sys.version_info >= (3, 12), + reason="numpy.distutils deprecated in Python 3.12+", +) def test_numpy_setup_py_data(testing_config): recipe_path = os.path.join(metadata_dir, "_numpy_setup_py_data") # this shows an error that is OK to ignore: @@ -1486,17 +1494,44 @@ def test_runtime_dependencies(testing_config): @pytest.mark.sanity -def test_no_force_upload_condarc_setting(mocker, testing_workdir, testing_metadata): - testing_metadata.config.anaconda_upload = True - del testing_metadata.meta["test"] +def test_no_force_upload( + mocker: MockerFixture, + monkeypatch: MonkeyPatch, + testing_workdir: str | os.PathLike | Path, + testing_metadata: MetaData, + request: FixtureRequest, +): + # this is nearly identical to tests/cli/test_main_build.py::test_no_force_upload + # only difference is this tests `conda_build.api.build` + request.addfinalizer(reset_config) + call = mocker.patch("subprocess.call") + anaconda = find_executable("anaconda") + + # render recipe api.output_yaml(testing_metadata, "meta.yaml") - call = mocker.patch.object(conda_build.build.subprocess, "call") - cc_conda_build["force_upload"] = False + + # mock Config.set_keys to always set anaconda_upload to True + # conda's Context + conda_build's MetaData & Config objects interact in such an + # awful way that mocking these configurations is ugly and confusing, all of it + # needs major refactoring + set_keys = Config.set_keys # store original method + override = {"anaconda_upload": True} + monkeypatch.setattr( + Config, + "set_keys", + lambda self, **kwargs: set_keys(self, **{**kwargs, **override}), + ) + + # check for normal upload + override["force_upload"] = False pkg = api.build(testing_workdir) - assert call.called_once_with(["anaconda", "upload", pkg]) - del cc_conda_build["force_upload"] + call.assert_called_once_with([anaconda, "upload", *pkg]) + call.reset_mock() + + # check for force upload + override["force_upload"] = True pkg = api.build(testing_workdir) - assert call.called_once_with(["anaconda", "upload", "--force", pkg]) + call.assert_called_once_with([anaconda, "upload", "--force", *pkg]) @pytest.mark.sanity diff --git a/tests/test_api_skeleton.py b/tests/test_api_skeleton.py index 514d469c56..52039b9ed4 100644 --- a/tests/test_api_skeleton.py +++ b/tests/test_api_skeleton.py @@ -11,7 +11,7 @@ import ruamel.yaml from conda_build import api -from conda_build.exceptions import DependencyNeedsBuildingError +from conda_build.config import Config from conda_build.skeletons.pypi import ( clean_license_name, convert_to_flat_list, @@ -321,10 +321,11 @@ def test_pypi_with_setup_options(tmp_path: Path, testing_config): api.skeletonize( packages="photutils", repo="pypi", - version="0.2.2", + version="1.10.0", setup_options="--offline", config=testing_config, output_dir=tmp_path, + extra_specs=["extension-helpers"], ) # Check that the setup option occurs in bld.bat and build.sh. @@ -332,30 +333,31 @@ def test_pypi_with_setup_options(tmp_path: Path, testing_config): assert "--offline" in m.meta["build"]["script"] -def test_pypi_pin_numpy(tmp_path: Path, testing_config): +def test_pypi_pin_numpy(tmp_path: Path, testing_config: Config): # The package used here must have a numpy dependence for pin-numpy to have # any effect. api.skeletonize( - packages="msumastro", + packages="fasttext", repo="pypi", - version="0.9.0", + version="0.9.2", config=testing_config, pin_numpy=True, output_dir=tmp_path, ) - assert (tmp_path / "msumastro" / "meta.yaml").read_text().count("numpy x.x") == 2 - with pytest.raises(DependencyNeedsBuildingError): - api.build("msumastro") + assert (tmp_path / "fasttext" / "meta.yaml").read_text().count("numpy x.x") == 2 -def test_pypi_version_sorting(tmp_path: Path, testing_config): +def test_pypi_version_sorting(tmp_path: Path, testing_config: Config): # The package used here must have a numpy dependence for pin-numpy to have # any effect. api.skeletonize( - packages="impyla", repo="pypi", config=testing_config, output_dir=tmp_path + packages="fasttext", + repo="pypi", + config=testing_config, + output_dir=tmp_path, ) - m = api.render(str(tmp_path / "impyla"))[0][0] - assert parse_version(m.version()) >= parse_version("0.13.8") + m = api.render(str(tmp_path / "fasttext"))[0][0] + assert parse_version(m.version()) >= parse_version("0.9.2") def test_list_skeletons(): diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 7ac5bbdf01..05e67b540b 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -24,6 +24,7 @@ yamlize, ) from conda_build.utils import DEFAULT_SUBDIRS +from conda_build.variants import DEFAULT_VARIANTS from .utils import metadata_dir, metadata_path, thisdir @@ -189,10 +190,11 @@ def test_build_bootstrap_env_by_path(testing_metadata): ("win", "x86_64", "3.9", {"vs2017_win-x86_64"}), ("win", "x86_64", "3.10", {"vs2017_win-x86_64"}), ("win", "x86_64", "3.11", {"vs2017_win-x86_64"}), - ("linux", "32", "3.11", {"gcc_linux-32", "gxx_linux-32"}), - ("linux", "64", "3.11", {"gcc_linux-64", "gxx_linux-64"}), - ("osx", "32", "3.11", {"clang_osx-32", "clangxx_osx-32"}), - ("osx", "64", "3.11", {"clang_osx-64", "clangxx_osx-64"}), + ("win", "x86_64", "3.12", {"vs2017_win-x86_64"}), + ("linux", "32", "3.12", {"gcc_linux-32", "gxx_linux-32"}), + ("linux", "64", "3.12", {"gcc_linux-64", "gxx_linux-64"}), + ("osx", "32", "3.12", {"clang_osx-32", "clangxx_osx-32"}), + ("osx", "64", "3.12", {"clang_osx-64", "clangxx_osx-64"}), ], ) def test_native_compiler_metadata( @@ -438,19 +440,19 @@ def test_get_selectors( assert get_selectors(config) == { # defaults "build_platform": context.subdir, - "lua": "5", # see conda_build.variants.DEFAULT_VARIANTS["lua"] - "luajit": False, # lua[0] == 2 - "np": 122, # see conda_build.variants.DEFAULT_VARIANTS["numpy"] + "lua": DEFAULT_VARIANTS["lua"], + "luajit": DEFAULT_VARIANTS["lua"] == 2, + "np": int(float(DEFAULT_VARIANTS["numpy"]) * 100), "os": os, - "pl": "5.26.2", # see conda_build.variants.DEFAULT_VARIANTS["perl"] + "pl": DEFAULT_VARIANTS["perl"], "py": int(f"{sys.version_info.major}{sys.version_info.minor}"), - "py26": sys.version_info.major == 2 and sys.version_info.minor == 6, - "py27": sys.version_info.major == 2 and sys.version_info.minor == 7, + "py26": sys.version_info[:2] == (2, 6), + "py27": sys.version_info[:2] == (2, 7), "py2k": sys.version_info.major == 2, - "py33": sys.version_info.major == 3 and sys.version_info.minor == 3, - "py34": sys.version_info.major == 3 and sys.version_info.minor == 4, - "py35": sys.version_info.major == 3 and sys.version_info.minor == 5, - "py36": sys.version_info.major == 3 and sys.version_info.minor == 6, + "py33": sys.version_info[:2] == (3, 3), + "py34": sys.version_info[:2] == (3, 4), + "py35": sys.version_info[:2] == (3, 5), + "py36": sys.version_info[:2] == (3, 6), "py3k": sys.version_info.major == 3, "nomkl": bool(nomkl), # default OS/arch values diff --git a/tests/test_subpackages.py b/tests/test_subpackages.py index ca6004eefd..d89b888758 100644 --- a/tests/test_subpackages.py +++ b/tests/test_subpackages.py @@ -125,7 +125,7 @@ def test_git_in_output_version(testing_config, conda_build_test_recipe_envvar: s recipe, config=testing_config, finalize=False, bypass_env_check=True ) assert len(outputs) == 1 - assert outputs[0][0].version() == "1.21.11" + assert outputs[0][0].version() == "1.22.0" def test_intradep_with_templated_output_name(testing_config): diff --git a/tests/test_variants.py b/tests/test_variants.py index 819f39d793..89ebb67999 100644 --- a/tests/test_variants.py +++ b/tests/test_variants.py @@ -60,7 +60,7 @@ def test_python_variants(testing_workdir, testing_config, as_yaml): python 3.5 -> python >=3.5,<3.6.0a0 otherPackages 3.5 -> otherPackages 3.5 """ - variants = {"python": ["3.10", "3.11"]} + variants = {"python": ["3.11", "3.12"]} testing_config.ignore_system_config = True # write variants to disk @@ -87,7 +87,7 @@ def test_python_variants(testing_workdir, testing_config, as_yaml): assert { *metadata[0][0].meta["requirements"]["run"], *metadata[1][0].meta["requirements"]["run"], - } == {"python >=3.10,<3.11.0a0", "python >=3.11,<3.12.0a0"} + } == {"python >=3.11,<3.12.0a0", "python >=3.12,<3.13.0a0"} def test_use_selectors_in_variants(testing_workdir, testing_config): diff --git a/tests/utils.py b/tests/utils.py index d7bd5b479d..692f852fff 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -8,8 +8,10 @@ from pathlib import Path from typing import Generator +from conda.base.context import context, reset_context from conda.common.compat import on_mac +from conda_build.conda_interface import cc_conda_build from conda_build.metadata import MetaData tests_path = Path(__file__).parent @@ -144,3 +146,11 @@ def get_noarch_python_meta(meta): d = meta.meta d["build"]["noarch"] = "python" return MetaData.fromdict(d, config=meta.config) + + +def reset_config(search_path=None): + reset_context(search_path) + cc_conda_build.clear() + cc_conda_build.update( + context.conda_build if hasattr(context, "conda_build") else {} + )