Skip to content

Commit

Permalink
Merge pull request conda#9349 from beckermr/osx-virt
Browse files Browse the repository at this point in the history
ENH add osx version virtual package
  • Loading branch information
jjhelmus authored Oct 25, 2019
2 parents d1c7a5d + 8021f99 commit 87551af
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions conda/common/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

on_win = bool(sys.platform == "win32")
on_mac = bool(sys.platform == "darwin")
on_linux = bool(sys.platform == "linux")

PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
Expand Down
7 changes: 7 additions & 0 deletions conda/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ def _supplement_index_with_system(index):
rec = _make_virtual_package('__cuda', cuda_version)
index[rec] = rec

dist_name, dist_version = context.os_distribution_name_version
if dist_name == 'OSX':
dist_version = os.environ.get('CONDA_OVERRIDE_OSX', dist_version)
if len(dist_version) > 0:
rec = _make_virtual_package('__osx', dist_version)
index[rec] = rec

libc_family, libc_version = context.libc_family_version
if libc_family and libc_version:
libc_version = os.getenv("CONDA_OVERRIDE_{}".format(libc_family.upper()), libc_version)
Expand Down
3 changes: 3 additions & 0 deletions docs/source/user-guide/tasks/manage-virtual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ small bit of code to detect the presence or absence of the system feature that
corresponds to the package. The currently supported list of virtual packages includes:

* ``__cuda``: Maximum version of CUDA supported by the display driver
* ``__osx``: OSX version if applicable
* ``__glibc``: Version of glibc supported by the OS

Other virtual packages will be added in future conda releases. These are denoted
Expand Down Expand Up @@ -69,5 +70,7 @@ using an environment variable. Supported variables include:

* ``CONDA_OVERRIDE_CUDA`` - CUDA version number or set to ``""`` for no CUDA
detected.
* ``CONDA_OVERRIDE_OSX`` - OSX version number or set to ``""`` for no OSX
detected.
* ``CONDA_OVERRIDE_GLIBC`` - GLIBC version number or set to ``""`` for no GLIBC.
This only applies on Linux.
13 changes: 12 additions & 1 deletion tests/core/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from conda.base.constants import DEFAULT_CHANNELS
from conda.base.context import context, Context, conda_tests_ctxt_mgmt_def_pol
from conda.common.compat import iteritems, on_win, on_mac
from conda.common.compat import iteritems, on_win, on_mac, on_linux
from conda.common.io import env_vars
from conda.core.index import check_whitelist, get_index, get_reduced_index, _supplement_index_with_system
from conda.exceptions import ChannelNotAllowed
Expand Down Expand Up @@ -54,6 +54,17 @@ def test_supplement_index_with_system_cuda():
assert cuda_pkg.package_type == PackageType.VIRTUAL_SYSTEM


@pytest.mark.skipif(not on_mac, reason="osx-only test")
def test_supplement_index_with_system_osx():
index = {}
with env_vars({'CONDA_OVERRIDE_OSX': '0.15'}):
_supplement_index_with_system(index)

osx_pkg = next(iter(_ for _ in index if _.name == '__osx'))
assert osx_pkg.version == '0.15'
assert osx_pkg.package_type == PackageType.VIRTUAL_SYSTEM


@pytest.mark.skipif(on_win or on_mac, reason="linux-only test")
def test_supplement_index_with_system_glibc():
index = {}
Expand Down

0 comments on commit 87551af

Please sign in to comment.