Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
# From pytest-split
.test_durations

# Translations
*.mo
Expand Down
28 changes: 7 additions & 21 deletions constructor/conda_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
import sys
from copy import deepcopy
from itertools import chain
from os.path import join

from conda.gateways.disk import mkdir_p_sudo_safe
Expand Down Expand Up @@ -37,7 +36,7 @@
]

try:
from conda import __version__ as CONDA_INTERFACE_VERSION
from conda import __version__ as CONDA_INTERFACE_VERSION # noqa

conda_interface_type = "conda"
except ImportError:
Expand All @@ -47,11 +46,6 @@

if conda_interface_type == "conda":
# This import path has been stable since 2016
from conda.models.version import VersionOrder

_conda_version = VersionOrder(CONDA_INTERFACE_VERSION).version
# Flatten VersionOrder.version, skip epoch, and keep only major and minor
CONDA_MAJOR_MINOR = tuple(chain.from_iterable(_conda_version))[1:3]

from conda.api import SubdirData # noqa
from conda.base.context import context as _conda_context
Expand All @@ -61,14 +55,15 @@
from conda.core.package_cache_data import PackageCacheData as _PackageCacheData
from conda.core.package_cache_data import ProgressiveFetchExtract as _ProgressiveFetchExtract
from conda.core.prefix_data import PrefixData as _PrefixData
from conda.core.subdir_data import SubdirData as _SubdirData
from conda.exports import MatchSpec as _MatchSpec
from conda.exports import default_prefix as _default_prefix
from conda.exports import download as _download
from conda.gateways.disk.read import read_paths_json as _read_paths_json
from conda.models.channel import all_channel_urls as _all_channel_urls
from conda.models.channel import all_channel_urls as _all_channel_urls, Channel
from conda.models.dist import Dist as _Dist
from conda.models.prefix_graph import PrefixGraph as _PrefixGraph
from conda.models.version import VersionOrder
from conda.models.version import VersionOrder # noqa

try:
from conda.models.records import PackageCacheRecord as _PackageCacheRecord
Expand Down Expand Up @@ -102,22 +97,13 @@
distro = None
if sys.platform.startswith("linux"):
try:
from conda._vendor import distro # noqa
import distro # noqa: F401 # re-exported for use in preconda.py
except ImportError:
pass

def get_repodata(url):
if CONDA_MAJOR_MINOR >= (23, 5):
from conda.core.subdir_data import SubdirData as _SubdirData
from conda.models.channel import Channel

subdir_data = _SubdirData(Channel(url))
raw_repodata_str, _ = subdir_data.repo_fetch.fetch_latest()
else:
# Backwards compatibility: for conda 4.6+
from conda.core.subdir_data import fetch_repodata_remote_request

raw_repodata_str = fetch_repodata_remote_request(url, None, None)
subdir_data = _SubdirData(Channel(url))
raw_repodata_str, _ = subdir_data.repo_fetch.fetch_latest()

# noarch-only repos are valid. if the native subdir is not present,
# we might get an empty repodata back. In that case, we need to add the minimal
Expand Down
2 changes: 1 addition & 1 deletion constructor/preconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def system_info():
out["extra"] = platform.mac_ver()
elif sys.platform.startswith("linux"):
if conda_distro is not None:
out["extra"] = conda_distro.linux_distribution(full_distribution_name=False)
out["extra"] = (conda_distro.id(), conda_distro.version(), conda_distro.codename())
elif hasattr(platform, "dist"):
out["extra"] = platform.dist()
elif sys.platform.startswith("win"):
Expand Down
2 changes: 1 addition & 1 deletion dev/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- python
- pip
- conda >=4.6
- conda >=24.1
- ruamel.yaml >=0.11.14,<0.19
- conda-standalone # >=23.11.0
- pillow >=3.1 # [osx or win]
Expand Down
19 changes: 19 additions & 0 deletions news/1316-fix-distro-vendor-deprecation
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Replace deprecated use of `conda._vendor.distro`, which also restores the Linux distribution info in `info.json`. (#1315 via #1316)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* Raise the minimum supported `conda` version to 24.1. (#1315 via #1316)
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ dynamic = [
"version",
]
dependencies = [
"conda >=4.6",
"conda >=24.1",
"distro ; platform_system=='Linux'",
"ruamel.yaml >=0.11.14,<0.19",
"pillow >=3.1 ; platform_system=='Windows' or platform_system=='Darwin'",
"jinja2",
Expand Down
3 changes: 2 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ requirements:
- setuptools >=70.1
- setuptools_scm >=6.2
run:
- conda >=4.6
- conda >=24.1
- python # >=3.10
- distro # [linux]
- ruamel.yaml >=0.11.14,<0.19
- conda-standalone >=24.11.0
- jinja2
Expand Down
18 changes: 17 additions & 1 deletion tests/test_preconda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from constructor.preconda import write_condarc
import sys

import pytest

from constructor.preconda import system_info, write_condarc


def test_write_condarc_with_condarc_dict(tmp_path):
Expand Down Expand Up @@ -56,3 +60,15 @@ def test_write_condarc_write_condarc_without_channels(tmp_path):

condarc_file = tmp_path / ".condarc"
assert not condarc_file.exists()


@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="Linux-only distro info")
def test_system_info_includes_linux_distro():
"""system_info() should report actual distro info on Linux. Previously conda_distro was imported from
the now-removed conda._vendor.distro, so the import silently failed and
'extra' was never set (see GitHub issue 1315)."""
import distro

info = system_info()

assert info["extra"] == (distro.id(), distro.version(), distro.codename())
Loading