diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 78ba210f92..e718e1fc11 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -131,6 +131,9 @@ jobs: python=${{ matrix.python-version }} ${{ env.CONDA_CHANNEL_LABEL }}${{ env.CONDA_VERSION }} + - name: Install development conda + run: pip install git+https://github.com/zklaus/conda@lazy-index && python -m conda init --install + # TODO: how can we remove this step? - name: Install Self run: pip install -e . @@ -214,6 +217,9 @@ jobs: - name: Install CodSpeed run: pip install git+https://github.com/kenodegard/pytest-codspeed.git@fix-outerr-redirects#egg=pytest-codspeed + - name: Install development conda + run: pip install git+https://github.com/zklaus/conda@lazy-index && python -m conda init --install + # TODO: how can we remove this step? - name: Install Self run: pip install -e . @@ -234,6 +240,77 @@ jobs: token: ${{ secrets.CODSPEED_TOKEN }} run: $CONDA/envs/test/bin/pytest --codspeed + # linux memray + linux-memray: + # only run test suite if there are code changes + needs: changes + if: needs.changes.outputs.code == 'true' + + runs-on: ubuntu-latest + defaults: + run: + # https://github.com/conda-incubator/setup-miniconda#use-a-default-shell + shell: bash -el {0} # bash exit immediately on error + login shell + strategy: + fail-fast: false + matrix: + python-version: ['3.12'] + + steps: + - name: Checkout Source + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + + - name: Hash + Timestamp + run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-memray-$(date -u "+%Y%m")" >> $GITHUB_ENV + + - name: Cache Conda + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 + with: + path: ~/conda_pkgs_dir + key: cache-${{ env.HASH }} + + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca + with: + condarc-file: .github/condarc + run-post: false # skip post cleanup + + - name: Conda Install + run: > + conda install + --yes + --file tests/requirements.txt + --file tests/requirements-${{ runner.os }}.txt + --file tests/requirements-ci.txt + python=${{ matrix.python-version }} + ${{ env.CONDA_CHANNEL_LABEL }}${{ env.CONDA_VERSION }} + pytest-memray + + - name: Install CodSpeed + run: pip install git+https://github.com/kenodegard/pytest-codspeed.git@fix-outerr-redirects#egg=pytest-codspeed + + - name: Install development conda + run: pip install git+https://github.com/zklaus/conda@lazy-index && python -m conda init --install + + # TODO: how can we remove this step? + - name: Install Self + run: pip install -e . + + - name: Conda Info + # view test env info (not base) + run: python -m conda info --verbose + + - name: Conda Config + run: conda config --show-sources + + - name: Conda List + run: conda list --show-channel-urls + + - name: Run memray + run: python -m pytest -k memray --memray + # windows test suite windows: # only run test suite if there are code changes @@ -295,6 +372,9 @@ jobs: python=${{ matrix.python-version }} ${{ env.CONDA_CHANNEL_LABEL }}::conda + - name: Install development conda + run: pip install git+https://github.com/zklaus/conda@lazy-index && python -m conda init --install + # TODO: how can we remove this step? - name: Install Self run: pip install -e . @@ -414,6 +494,9 @@ jobs: python=${{ matrix.python-version }} ${{ env.CONDA_CHANNEL_LABEL }}::conda + - name: Install development conda + run: pip install git+https://github.com/zklaus/conda@lazy-index && python -m conda init --install + # TODO: how can we remove this step? - name: Install Self run: pip install -e . diff --git a/conda_build/index.py b/conda_build/index.py index bcb9c6a9d0..04e20b47e4 100644 --- a/conda_build/index.py +++ b/conda_build/index.py @@ -6,7 +6,7 @@ from os.path import dirname from conda.base.context import context -from conda.core.index import get_index +from conda.core.index import Index from conda.exceptions import CondaHTTPError from conda.utils import url_path from conda_index.index import update_index as _update_index @@ -102,26 +102,24 @@ def get_build_index( if subdir == "noarch": subdir = context.subdir try: - # get_index() is like conda reading the index, not conda_index + # Index() is like conda reading the index, not conda_index # creating a new index. - cached_index = get_index( - channel_urls=urls, + cached_index = Index( + channels=urls, prepend=not omit_defaults, - use_local=False, - use_cache=context.offline, platform=subdir, + use_local=False, ) # HACK: defaults does not have the many subfolders we support. Omit it and # try again. except CondaHTTPError: if "defaults" in urls: urls.remove("defaults") - cached_index = get_index( - channel_urls=urls, - prepend=omit_defaults, - use_local=False, - use_cache=context.offline, + cached_index = Index( + channels=urls, + prepend=not omit_defaults, platform=subdir, + use_local=False, ) local_index_timestamp = os.path.getmtime(index_file) diff --git a/conda_build/inspect_pkg.py b/conda_build/inspect_pkg.py index 54ec2c6f28..2f2ec97e0a 100644 --- a/conda_build/inspect_pkg.py +++ b/conda_build/inspect_pkg.py @@ -16,7 +16,7 @@ from conda.api import Solver from conda.base.context import context from conda.cli.common import specs_from_args -from conda.core.index import get_index +from conda.core.index import Index from conda.core.prefix_data import PrefixData from conda.models.records import PrefixRecord @@ -173,7 +173,7 @@ def test_installable(channel: str = "defaults") -> bool: success = True for subdir in ["osx-64", "linux-32", "linux-64", "win-32", "win-64"]: log.info("######## Testing subdir %s ########", subdir) - for prec in get_index(channel_urls=[channel], prepend=False, platform=subdir): + for prec in Index(channels=[channel], prepend=False, platform=subdir): name = prec["name"] if name in {"conda", "conda-build"}: # conda can only be installed in the root environment diff --git a/conda_build/skeletons/cpan.py b/conda_build/skeletons/cpan.py index 31213054d1..0ac5395f65 100644 --- a/conda_build/skeletons/cpan.py +++ b/conda_build/skeletons/cpan.py @@ -21,7 +21,7 @@ from os.path import basename, dirname, exists, join import requests -from conda.core.index import get_index +from conda.core.index import Index from conda.exceptions import CondaError, CondaHTTPError from conda.gateways.connection.download import TmpDownload, download from conda.gateways.disk.create import TemporaryDirectory @@ -695,7 +695,7 @@ def latest_pkg_version(pkg): """ :returns: the latest version of the specified conda package available """ - r = Resolve(get_index()) + r = Resolve(Index()) try: pkg_list = sorted(r.get_pkgs(MatchSpec(pkg))) except: diff --git a/pyproject.toml b/pyproject.toml index 12fe4731f6..da1ef47e8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -124,12 +124,15 @@ filterwarnings = [ # elevate conda-build's deprecated warning to an error "error::PendingDeprecationWarning:conda_build", "error::DeprecationWarning:conda_build", + "ignore:Python 3.14 will, by default, filter extracted tar archives:DeprecationWarning:conda_package_streaming", # ignore numpy.distutils error 'ignore:\s+`numpy.distutils` is deprecated:DeprecationWarning:conda_build._load_setup_py_data', # ignore conda-index error "ignore::PendingDeprecationWarning:conda_index", "ignore::DeprecationWarning:conda_index", "ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning", + "ignore:conda.core.index._supplement_index_with_system is pending deprecation:PendingDeprecationWarning:conda", + "ignore:conda.core.index._make_virtual_package is pending deprecation:PendingDeprecationWarning:conda", ] markers = [ "serial: execute test serially (to avoid race conditions)", @@ -137,6 +140,7 @@ markers = [ "sanity: execute the sanity tests", "no_default_testing_config: used internally to disable monkeypatching for testing_config", "benchmark: execute the benchmark tests", + "memray: memory use tests", ] minversion = 3.0 norecursedirs = ["tests/test-recipes/*"] diff --git a/tests/test_api_build.py b/tests/test_api_build.py index efba89d75d..72442f277e 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -1826,7 +1826,7 @@ def test_downstream_tests(testing_config): @pytest.mark.sanity -def test_warning_on_file_clobbering(testing_config, capfd): +def test_warning_on_file_clobbering(testing_config, caplog): recipe_dir = os.path.join(metadata_dir, "_overlapping_files_warning") api.build( @@ -1844,8 +1844,11 @@ def test_warning_on_file_clobbering(testing_config, capfd): config=testing_config, ) # The clobber warning here is raised when creating the test environment for b - out, err = capfd.readouterr() - assert "ClobberWarning" in err + clobber_warning_found = False + for record in caplog.records: + if "ClobberWarning:" in record.message: + clobber_warning_found = True + assert clobber_warning_found with pytest.raises((ClobberError, CondaMultiError)): with env_var("CONDA_PATH_CONFLICT", "prevent", reset_context): api.build(os.path.join(recipe_dir, "b"), config=testing_config)