%bcond bootstrap 1
%bcond tests %{without bootstrap}
Name: python-virtualenv
Version: 20.21.1
Release: %autorelease
Summary: Tool to create isolated Python environments
License: MIT
URL: http://pypi.python.org/pypi/virtualenv
Source0: %{pypi_source virtualenv}
# Add /usr/share/python-wheels to extra_search_dir
Patch1: rpm-wheels.patch
## Backports from virtualenv 20.22+
## We cannot update yet as we want to preserve support for Python 2.7 and 3.6 environments
## Patches in https://github.com/fedora-python/virtualenv/commits/20.21.x
# (20.23.0) prevent PermissionError when using venv creator on some systems
# https://github.com/pypa/virtualenv/pull/2543
Patch2: prevent-PermissionError-when-using-venv-creator-on-s.patch
# (20.23.0) 3.12 support and no setuptools/wheel on 3.12+
# freezgun and typing changes stripped
# files missing in sdist removed from the path file
# https://github.com/pypa/virtualenv/pull/2558
Patch3: 3.12-support-and-no-setuptools-wheel-on-3.12-2558.patch
# (20.24.0) Fix tests with pluggy 1.2.0+
# Manually cherry-picked from https://github.com/pypa/virtualenv/pull/2593
Patch4: Fix-tests-with-pluggy-1.2.0.patch
# Fix compatibility with Python 3.13
# https://github.com/pypa/virtualenv/pull/2673
# https://github.com/pypa/virtualenv/pull/2702
Patch5: py3.13.patch
# Allow builtin interpreter discovery to find specific Python versions given a
# general spec
# https://github.com/pypa/virtualenv/pull/2709
# which contains regressions (mostly but perhaps not exclusively on Windows)
# that are fixed by:
# Fix PATH-based Python discovery on Windows
# https://github.com/pypa/virtualenv/pull/2712
#
# Backported to 20.21.1.
Patch6: prs-2709-and-2712.patch
# Quote template strings in activation scripts
# to prevent possible command injection.
# https://github.com/pypa/virtualenv/issues/2768
# Backported from 20.26.6
Patch7: prevent_command_injection.patch
BuildArch: noarch
BuildRequires: python3-devel
%if %{with tests}
BuildRequires: fish
BuildRequires: tcsh
BuildRequires: gcc
BuildRequires: python3-flaky
BuildRequires: python3-packaging
BuildRequires: python3-pytest
BuildRequires: python3-pytest-mock
BuildRequires: python3-pytest-randomly
BuildRequires: python3-pytest-timeout
# The .dist-info folder generated by
# %%pyproject_buildrequires confuses
# importlib.metadata entry points and
# that leads to failed tests where
# virtualenv is run via subprocess.
# The .dist-info is removed since:
BuildRequires: pyproject-rpm-macros >= 1.6.3
%endif
# RPM installed wheels
BuildRequires: %{python_wheel_pkg_prefix}-pip-wheel
BuildRequires: %{python_wheel_pkg_prefix}-setuptools-wheel
BuildRequires: %{python_wheel_pkg_prefix}-wheel-wheel
%description
virtualenv is a tool to create isolated Python environments. virtualenv
is a successor to workingenv, and an extension of virtual-python. It is
written by Ian Bicking, and sponsored by the Open Planning Project. It is
licensed under an MIT-style permissive license.
%package -n python3-virtualenv
Summary: Tool to create isolated Python environments
# This virtualenv requires the "venv" install scheme on Pythons
# where we patch "posix_prefix".
# Explicitly conflict with Pythons where we don't have it yet.
Conflicts: python3.11 < 3.11.0~a2
%if 0%{?fedora} >= 36
Conflicts: python3.10 < 3.10.0-3
%endif
Obsoletes: python3-virtualenv-python26 < 16.6
%{?python_provide:%python_provide python3-virtualenv}
# Provide "virtualenv" for convenience
Provides: virtualenv = %{version}-%{release}
# RPM installed wheels
Requires: %{python_wheel_pkg_prefix}-pip-wheel
Requires: %{python_wheel_pkg_prefix}-setuptools-wheel
Requires: %{python_wheel_pkg_prefix}-wheel-wheel
# Pythons < 3.7 need an older version of wheel:
Requires: (%{python_wheel_pkg_prefix}-wheel0.37-wheel if python2.7)
Requires: (%{python_wheel_pkg_prefix}-wheel0.37-wheel if pypy2.7)
Requires: (%{python_wheel_pkg_prefix}-wheel0.37-wheel if python3.6)
%description -n python3-virtualenv
virtualenv is a tool to create isolated Python environments. virtualenv
is a successor to workingenv, and an extension of virtual-python. It is
written by Ian Bicking, and sponsored by the Open Planning Project. It is
licensed under an MIT-style permissive license
%prep
%autosetup -p1 -n virtualenv-%{version}
# Remove the wheels provided by RPM packages
rm src/virtualenv/seed/wheels/embed/pip-*
rm src/virtualenv/seed/wheels/embed/setuptools-*
rm src/virtualenv/seed/wheels/embed/wheel-*
test ! -f src/virtualenv/seed/embed/wheels/*.whl
# Replace hardcoded path from rpm-wheels.patch by %%{python_wheel_dir}
# On Fedora, this should change nothing, but when building for RHEL9+, it will
sed -i "s|/usr/share/python-wheels|%{python_wheel_dir}|" src/virtualenv/util/path/_system_wheels.py
# Allow platformdirs version 4
# Backported from release 20.24.7
# https://github.com/pypa/virtualenv/commit/55650340d9c9415bf035596266f245a8d59c6993
sed -i "s/platformdirs<4/platformdirs<5/" pyproject.toml
# Fix compatibility with pytest 8
# Fixed upstream in: https://github.com/pypa/virtualenv/commit/16a6af7760c0806c2071956435b1822bb8424595
sed -i "/pytest.skip/s/msg=/reason=/" tests/unit/activation/conftest.py tests/conftest.py
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files virtualenv
%if %{with tests}
%check
# Skip tests which requires internet or some extra dependencies
# Requires internet:
# - test_download_*
# - test_can_build_c_extensions (on Python 3.12+)
# Uses disabled functionalities around bundled wheels:
# - test_wheel_*
# - test_seed_link_via_app_data
# - test_base_bootstrap_via_pip_invoke
# - test_acquire.py (whole file)
# - test_bundle.py (whole file)
# Uses disabled functionalities around automatic updates:
# - test_periodic_update.py (whole file)
# Requires Python 2:
# - test_py_pyc_missing
PIP_CERT=/etc/pki/tls/certs/ca-bundle.crt \
%pytest -vv -k "not test_bundle and \
not test_acquire and \
not test_periodic_update and \
not test_wheel_ and \
not test_download_ and \
%if v"%{python3_version}" >= v"3.12"
not test_can_build_c_extensions and \
%endif
not test_base_bootstrap_via_pip_invoke and \
not test_seed_link_via_app_data and \
not test_py_pyc_missing"
%endif
%files -n python3-virtualenv -f %{pyproject_files}
%doc README.md
%{_bindir}/virtualenv
%changelog
%autochangelog