Blob Blame History Raw
%bcond_without tests

Name:           conda
Version:        24.4.0
Release:        %autorelease
Summary:        Cross-platform, Python-agnostic binary package manager

License:        BSD-3-Clause AND Apache-2.0 
# The conda code is BSD-3-Clause
# adapters/ is Apache-2.0

# bash completion script moved to a separate project
Patch0:         conda_sys_prefix.patch
# Use main entry point for conda and re-add conda-env entry point, no need to run conda init
Patch1:         0001-Use-main-entry-point-for-conda-and-re-add-conda-env-.patch
# Use system cpuinfo
Patch3:         conda-cpuinfo.patch
# Fix tests on 32bit
#Patch4:         conda-32bit.patch

Patch10004:     0004-Do-not-try-to-run-usr-bin-python.patch
Patch10006:     0006-shell-assume-shell-plugins-are-in-etc.patch

BuildArch:      noarch

BuildRequires:  pkgconfig(bash-completion)
%global bash_completionsdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null || echo '/etc/bash_completion.d')
BuildRequires:  sed

Requires:       python%{python3_pkgversion}-conda = %{version}-%{release}
# Removed upstream in favour of calling "conda activate" in version 4.4.0
Obsoletes:      conda-activate < 4.4


%global _description %{expand:
Conda is a cross-platform, Python-agnostic binary package manager. It
is the package manager used by Anaconda installations, but it may be
used for other systems as well. Conda makes environments first-class
citizens, making it easy to create independent environments even for
C libraries. Conda is written entirely in Python.

The Fedora conda base environment is special.  Unlike a standard
anaconda install base environment it is essentially read-only.  You
can only use conda to create and manage new environments.}

%description %_description

%package tests
Summary:        conda tests

%description tests
Data for conda tests.  Set CONDA_TEST_DATA_DIR to

%package -n python%{python3_pkgversion}-conda
Summary:        %{summary}

BuildRequires:  python%{python3_pkgversion}-devel
# For tests
BuildRequires:  python-unversioned-command
BuildRequires:  python%{python3_pkgversion}-boto3
BuildRequires:  python%{python3_pkgversion}-flask
BuildRequires:  python%{python3_pkgversion}-jsonpatch
BuildRequires:  python%{python3_pkgversion}-pytest-mock
BuildRequires:  python%{python3_pkgversion}-pytest-rerunfailures
BuildRequires:  python%{python3_pkgversion}-pytest-timeout
BuildRequires:  python%{python3_pkgversion}-pytest-xprocess
BuildRequires:  python%{python3_pkgversion}-responses

# Some versions in conda/_vendor/vendor.txt
Provides:       bundled(python%{python3_pkgversion}-appdirs) = 1.2.0
Provides:       bundled(python%{python3_pkgversion}-auxlib) = 0.0.43
Provides:       bundled(python%{python3_pkgversion}-boltons) = 21.0.0

%{?python_provide:%python_provide python%{python3_pkgversion}-conda}

%description -n python%{python3_pkgversion}-conda %_description

%autosetup -p1

# Do not restrict upper bound of ruamel-yaml
sed -i -e '/ruamel.yaml/s/,<[0-9.]*//' pyproject.toml

# pytest-split/xdoctest not packaged, store-duration not needed
sed -i -e '/splitting-algorithm/d' -e '/store-durations/d' -e '/xdoctest/d' pyproject.toml

# delete interpreter line, the user can always call the file
# explicitly as python3 /usr/lib/python3.6/site-packages/conda/_vendor/
# or so.
sed -r -i '1 {/#![/]usr[/]bin[/]env/d}' conda/_vendor/

# Use Fedora's cpuinfo since it supports more arches
rm -r conda/_vendor/cpuinfo
sed -i -e '/^dependencies = /a\ \ "py-cpuinfo",' pyproject.toml

# Use system versions
rm -r conda/_vendor/{,frozendict}
find conda -name \*.py | xargs sed -i -e 's/^\( *\)from .*_vendor\.\(\(distro\|frozendict\).*\) import/\1from \2 import/'
sed -i -e '/^dependencies = /a\ \ "distro",' pyproject.toml
sed -i -e '/^dependencies = /a\ \ "frozendict",' pyproject.toml

# Unpackaged - use vendored version
sed -i -e '/"boltons *>/d' pyproject.toml

# Unpackaged - really only applicable for macOS/Windows?
sed -i -e '/"truststore *>/d' pyproject.toml

%ifnarch x86_64
# Tests on 32-bit
cp -a tests/data/conda_format_repo/linux-{64,32}
sed -i -e s/linux-64/linux-32/ tests/data/conda_format_repo/linux-32/*json
# Tests on non-x86_64
cp -a tests/data/conda_format_repo/{linux-64,%{python3_platform}}
sed -i -e s/linux-64/%{python3_platform}/ tests/data/conda_format_repo/%{python3_platform}/*json

# Do not run coverage in pytest
sed -i -e '/"--cov/d' pyproject.toml

# When not testing, we don't need runtime dependencies.
# Normally, we would still BuildRequire them to not accidentally build an uninstallable package,
# but there is a runtime dependency loop with python3-conda-libmamba-solver.
%pyproject_buildrequires %{!?with_tests:-R}


%py3_shebang_fix %{buildroot}%{python3_sitelib}/conda/shell/bin/conda
%pyproject_save_files conda*

mkdir -p %{buildroot}%{_sysconfdir}/conda/condarc.d
mkdir -p %{buildroot}%{_datadir}/conda/condarc.d
cat >%{buildroot}%{_datadir}/conda/condarc.d/defaults.yaml <<EOF
 - /var/cache/conda/pkgs
 - ~/.conda/pkgs

mv %{buildroot}%{python3_sitelib}/tests %{buildroot}%{_datadir}/conda/
cp -rp tests/data %{buildroot}%{_datadir}/conda/tests/

mkdir -p %{buildroot}%{_localstatedir}/cache/conda/pkgs/cache

# install does not create the directory on EL7
install -m 0644 -Dt %{buildroot}/etc/profile.d/ conda/shell/etc/profile.d/conda.{sh,csh}
sed -r -i -e '1i [ -z "$CONDA_EXE" ] && CONDA_EXE=%{_bindir}/conda' \
          -e '/PATH=.*condabin/s|PATH=|[ -d $(dirname "$CONDA_EXE")/condabin ] \&\& PATH=|' %{buildroot}/etc/profile.d/
sed -r -i -e '1i set _CONDA_EXE=%{_bindir}/conda\nset _CONDA_ROOT=' \
          -e 's/CONDA_PFX=.*/CONDA_PFX=/' %{buildroot}/etc/profile.d/conda.csh
install -m 0644 -Dt %{buildroot}%{_datadir}/fish/vendor_conf.d/ conda/shell/etc/fish/conf.d/
sed -r -i -e '1i set -gx CONDA_EXE "/usr/bin/conda"\nset _CONDA_ROOT "/usr"\nset _CONDA_EXE "/usr/bin/conda"\nset -gx CONDA_PYTHON_EXE "/usr/bin/python3"' \

# Install bash completion script
install -m 0644 -Dt %{buildroot}%{bash_completionsdir}/ %SOURCE1

%if %{with tests}
export PATH=%{buildroot}%{_bindir}:$PATH
PYTHONPATH=%{buildroot}%{python3_sitelib} conda info

# Integration tests generally require network, so skip them.

# TestJson.test_list does not recognize /usr as a conda environment
# These fail on koji with PackageNotFound errors likely due to network issues

# test_ProgressiveFetchExtract_prefers_conda_v2_format, test_subdir_data_prefers_conda_to_tar_bz2,
# test_use_only_tar_bz2 fail in F31 koji, but not with mock --enablerepo=local. Let's disable
# them for now.
# tests/env/ requires network access
# tests/cli/ does not recognize /usr as a conda environment
# tests/cli/test_main_{clean,info,list,list_reverse,rename}.py tests require network access
# tests/cli/ needs a conda_build fixture that we remove
# tests/cli/ - TypeError: '<' not supported between instances of 'MagicMock' and 'int'
# tests/cli/ require /usr/bin/conda to be installed
# tests/cli/ tests require network access
# tests/cli/ seems to need an active environment
# tests/ requires network access
# tests/core/ tries to unlink /usr/bin/python3 and fails when python is a release candidate
# tests/core/ fails on non-x86_64
# tests/core/ libmamba - some depsolving differences - TODO
# tests/core/ libmamba - some depsolving differences - TODO
# tests/core/ libmamba - some depsolving differences - TODO
# tests/trust/ requires conda_content_trust - not yet packaged
py.test-%{python3_version} -vv -m "not integration" \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/ \
    --ignore=tests/env/specs/ \
    --deselect=tests/env/ \
    --deselect='tests/cli/[active_prefix-True]' \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/[libmamba] \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/[remove] \
    --deselect=tests/cli/[uninstall] \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/ \
    --deselect=tests/cli/[libmamba-update] \
    --deselect=tests/cli/[libmamba-upgrade] \
    --deselect=tests/cli/[update] \
    --deselect=tests/cli/[upgrade] \
    --deselect=tests/core/ \
    --deselect=tests/core/ \
    --deselect=tests/core/ \
    --deselect=tests/core/ \
    --deselect=tests/core/ \
    --deselect=tests/core/[libmamba] \
    --deselect=tests/core/[libmamba] \
    --deselect=tests/core/[libmamba] \
    --deselect=tests/core/[libmamba] \
    --deselect=tests/core/[libmamba] \
    --deselect=tests/core/[libmamba] \
    --deselect=tests/gateways/ \
    --deselect=tests/gateways/[True] \
    --deselect=tests/gateways/[False] \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/ \
    --deselect=tests/cli/[libmamba] \
    --deselect=tests/cli/[libmamba] \
    --deselect=tests/cli/[libmamba-remove] \
    --deselect=tests/cli/[libmamba-uninstall] \
    --deselect=tests/cli/[libmamba-remove] \
    --deselect=tests/cli/[libmamba-uninstall] \
    --deselect=tests/cli/[classic-remove] \
    --deselect=tests/cli/[classic-uninstall] \
    --deselect=tests/cli/[classic-update] \
    --deselect=tests/cli/[classic-upgrade] \
    --deselect=tests/cli/[libmamba] \
    --deselect=tests/cli/[libmamba] \
    --deselect=tests/core/ \
    --deselect=tests/models/[libmamba] \
    --deselect=tests/models/[libmamba] \
    --deselect=tests/models/[libmamba] \
    --deselect=tests/models/[libmamba] \
    --deselect=tests/plugins/ \
    --deselect=tests/plugins/ \
    --deselect=tests/plugins/ \
    --deselect=tests/plugins/subcommands/doctor/ \
    --deselect=tests/core/ \
    --deselect=tests/core/ \
    --deselect=tests/core/ \
    --ignore=tests/trust \
    conda tests

# TODO - better ownership for fish/vendor_conf.d
%dir %{_datadir}/fish/vendor_conf.d

%files tests

%files -n python%{python3_pkgversion}-conda -f %pyproject_files
%dir %{_datadir}/conda/