From 2a4b7168f2dc37e2e0b623181ffbe9a875eb272f Mon Sep 17 00:00:00 2001 From: Tadej Janež Date: Jun 19 2019 11:18:30 +0000 Subject: Remove Python version management functionality in Fedora 30+ --- diff --git a/0001-Remove-Python-version-management-on-Fedora.patch b/0001-Remove-Python-version-management-on-Fedora.patch new file mode 100644 index 0000000..bdf24ee --- /dev/null +++ b/0001-Remove-Python-version-management-on-Fedora.patch @@ -0,0 +1,120 @@ +From e43b1f4a04e3b5ce841a0dbb125bc87fc330bc13 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tadej=20Jane=C5=BE?= +Date: Wed, 12 Jun 2019 23:28:13 +0200 +Subject: [PATCH] Remove Python version management on Fedora + +This removes the pythonz-bd dependency which is not available in Fedora +anymore. +Furthermore, there is strong support upstream to either remove Pew's +Python version management or replace it with pyenv: +https://github.com/berdario/pew/issues/195. +--- + pew/pew.py | 22 +++------------------- + pew/shell_config/complete.fish | 9 --------- + pew/shell_config/complete.zsh | 3 --- + tests/test_install.py | 29 ----------------------------- + 4 files changed, 3 insertions(+), 60 deletions(-) + delete mode 100644 tests/test_install.py + +diff --git a/pew/pew.py b/pew/pew.py +index c588a2e..2ffea2f 100644 +--- a/pew/pew.py ++++ b/pew/pew.py +@@ -19,25 +19,9 @@ windows = sys.platform == 'win32' + + from clonevirtualenv import clone_virtualenv + if not windows: +- try: +- # Try importing these packages if avaiable +- from pythonz.commands.install import InstallCommand +- from pythonz.commands.uninstall import UninstallCommand +- from pythonz.installer.pythoninstaller import PythonInstaller, AlreadyInstalledError +- from pythonz.commands.list import ListCommand +- from pythonz.define import PATH_PYTHONS +- from pythonz.commands.locate import LocateCommand as LocatePython +- +- def ListPythons(): +- try: +- Path(PATH_PYTHONS).mkdir(parents=True) +- except OSError: +- pass +- return ListCommand() +- except: +- # create mock commands +- InstallCommand = ListPythons = LocatePython = UninstallCommand = \ +- lambda : sys.exit('You need to install the pythonz extra. pip install pew[pythonz]') ++ # Mock Pythonz commands ++ InstallCommand = ListPythons = LocatePython = UninstallCommand = \ ++ lambda : sys.exit('Python version management is not supported on Fedora.') + else: + # Pythonz does not support windows + InstallCommand = ListPythons = LocatePython = UninstallCommand = \ +diff --git a/pew/shell_config/complete.fish b/pew/shell_config/complete.fish +index af9f6d2..5dd0195 100644 +--- a/pew/shell_config/complete.fish ++++ b/pew/shell_config/complete.fish +@@ -105,12 +105,3 @@ complete -f -c $pew -n '__pew_using_command workon' -a '(__pew_list_envs)' -d 'V + + #### rename + complete -f -c $pew -n '__pew_needs_command' -a rename -d 'Rename a virtualenv' +- +-#### install +-complete -f -c $pew -n '__pew_needs_command' -a install -d 'Use Pythonz to download and build a Python vm' +- +-#### list_pythons +-complete -f -c $pew -n '__pew_needs_command' -a list_pythons -d 'List the pythons installed by Pythonz' +- +-#### locate_python +-complete -f -c $pew -n '__pew_needs_command' -a locate_python -d 'Locate the path for the python version installed by Pythonz' +diff --git a/pew/shell_config/complete.zsh b/pew/shell_config/complete.zsh +index 623fbff..e3a9aa5 100644 +--- a/pew/shell_config/complete.zsh ++++ b/pew/shell_config/complete.zsh +@@ -23,9 +23,6 @@ case $state in + 'add:Add directories to python path of active virtualenv' + 'cp:Duplicate the named virtualenv to make a new one' + 'inall:Run a command in each virtualenv:command' +- 'install:Use Pythonz to download and build the specified Python version' +- 'list_pythons:List the pythons installed by Pythonz (or all the installable ones)' +- 'locate_python:Locate the path for the python version installed by Pythonz' + 'ls:List all existing virtual environments' + 'lssitepackages:List currently active site-packages' + 'mkproject:Create environment with an associated project directory' +diff --git a/tests/test_install.py b/tests/test_install.py +deleted file mode 100644 +index 478ccbb..0000000 +--- a/tests/test_install.py ++++ /dev/null +@@ -1,29 +0,0 @@ +-import sys +-import os +-from subprocess import check_call +-from pew._utils import invoke_pew as invoke +-from utils import skip_windows, connection_required +-import pytest +- +-def skip_marker(f): +- return skip_windows(reason='Pythonz unavailable in Windows')( +- pytest.mark.skipif( +- sys.platform == 'cygwin', +- reason='Pythonz unavailable in Cygwin')( +- pytest.mark.skipif(os.environ.get('NIX'), +- reason='Pythonz unavailable in Nix')( +- connection_required(f)))) +- +-@skip_marker +-def test_install(): +- py_version = ['2.6.1', '--type', 'pypy'] +- assert invoke('install', *py_version).returncode == 0 +- py = invoke('locate_python', *py_version).out +- check_call([py, '-V']) +- +-@skip_marker +-def test_uninstall(): +- py_version = ['2.6.1', '--type', 'pypy'] +- invoke('install', *py_version) +- assert invoke('uninstall', *py_version).returncode == 0 +- assert invoke('locate_python', *py_version).returncode != 0 +-- +2.21.0 + diff --git a/README.md b/README.md index e73dd0a..c1193ff 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,25 @@ -# pew +# Pew Python Env Wrapper is a set of commands to manage multiple virtual environments. Pew can create, delete and copy your environments, using a single command to switch to them wherever you are, while keeping them in a single (configurable) location. +## Python version management functionality is removed in Fedora 30+ + +Fedora provides excellent native means for using multiple different Python +versions. One can install a non-default Python version, e.g. Python 3.6, by +using: + +``` +sudo dnf install python36 +``` + +For more information, refer to: +https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html. + +Hence, removing the Python versions management from Pew itself should really +be a non-issue. +In addition, there is strong support upstream to either remove Pew's Python +version management or replace it with pyenv: +https://github.com/berdario/pew/issues/195. diff --git a/pew.spec b/pew.spec index 42308af..c0f7184 100644 --- a/pew.spec +++ b/pew.spec @@ -1,5 +1,13 @@ %bcond_without check +%if 0%{?fedora} >= 30 +# NOTE: Since pythonz-bd dependency is not available in Fedora 30+, the Python +# version management functionality must be removed. +%bcond_with py_ver_management +%else +%bcond_without py_ver_management +%endif + Name: pew Version: 1.2.0 Release: 1%{?dist} @@ -8,13 +16,27 @@ Summary: Tool to manage multiple virtualenvs written in pure Python License: MIT URL: https://github.com/berdario/pew Source0: https://github.com/berdario/%{name}/archive/%{version}/%{name}-%{version}.tar.gz +Source1: README.md + +# This patch removes Python version management on Fedora. +# +# NOTE: This removes the pythonz-bd dependency which is not available in Fedora +# anymore. +# Furthermore, there is strong support upstream to either remove Pew's +# Python version management or replace it with pyenv: +# https://github.com/berdario/pew/issues/195. +Patch0: 0001-Remove-Python-version-management-on-Fedora.patch BuildArch: noarch BuildRequires: python3-devel BuildRequires: python3dist(setuptools) BuildRequires: python3dist(virtualenv) >= 1.11 BuildRequires: python3dist(virtualenv-clone) >= 0.2.5 +%if %{with py_ver_management} BuildRequires: python3dist(pythonz-bd) >= 1.10.2 +%endif +# Required for %%autosetup. +BuildRequires: git-core %if %{with check} BuildRequires: python3dist(pytest) @@ -25,7 +47,9 @@ BuildRequires: python3dist(pip) Requires: python3dist(setuptools) >= 17.1 Requires: python3dist(virtualenv) >= 1.11 Requires: python3dist(virtualenv-clone) >= 0.2.5 +%if %{with py_ver_management} Requires: python3dist(pythonz-bd) >= 1.10.2 +%endif %description Python Env Wrapper is a set of commands to manage multiple virtual @@ -34,7 +58,16 @@ single command to switch to them wherever you are, while keeping them in a single (configurable) location. %prep -%autosetup -n %{name}-%{version} +%autosetup -n %{name}-%{version} -N -S git +%if %{without py_ver_management} +%autopatch +%endif + +# Rename the Fedora-specific README.md to avoid conflict with the upstream +# README.md. +# NOTE: The source file should stay named README.md so that Pagure renders it +# when one visits https://src.fedoraproject.org/rpms/pew. +mv %{SOURCE1} README.Fedora.md # This script for shell completion can't be used for Fedora package rm -rf %{name}/shell_config/complete_deploy @@ -54,7 +87,7 @@ py.test-3 -vv tests %files %license LICENSE -%doc README.md +%doc README.md README.Fedora.md %{_bindir}/pew %{python3_sitelib}/%{name} %{python3_sitelib}/%{name}-%{version}-py?.?.egg-info @@ -63,6 +96,7 @@ py.test-3 -vv tests * Wed Jun 12 2019 Tadej Janež 1.2.0-1 - Update to 1.2.0 release - Drop the tests-connection-marker-fix patch since it has been upstreamed +- Remove Python version management functionality in Fedora 30+ * Fri Jul 13 2018 Fedora Release Engineering - 1.1.2-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild