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