diff --git a/python-virtualenv-api.spec b/python-virtualenv-api.spec new file mode 100644 index 0000000..df122f9 --- /dev/null +++ b/python-virtualenv-api.spec @@ -0,0 +1,86 @@ +# Created by pyp2rpm-3.0.0 +%global pypi_name virtualenv-api +%global underscore_name virtualenv_api + +Name: python-%{pypi_name} +Version: 2.1.8 +Release: 1%{?dist} +Summary: An API for virtualenv/pip + +License: BSD +URL: https://github.com/sjkingo/virtualenv-api +Source0: %{pypi_name}-%{version}.tar.gz + +# upstream PR https://github.com/sjkingo/virtualenv-api/pull/25 +Patch0: test_suite_fix.patch + +BuildArch: noarch + +BuildRequires: python-setuptools +BuildRequires: python2-devel +BuildRequires: python2-virtualenv +BuildRequires: git-all + +BuildRequires: python3-setuptools +BuildRequires: python3-devel +BuildRequires: python3-virtualenv + +%description +virtualenv-api - an API for virtualenv +Tool to create isolated Python environments. Unfortunately, +it does not expose a native Python API. This package aims to +provide an API in the form of a wrapper around virtualenv. + +%package -n python2-%{pypi_name} +Summary: An API for virtualenv/pip +%{?python_provide:%python_provide python2-%{pypi_name}} + +Requires: python-six +%description -n python2-%{pypi_name} +virtualenv-api - an API for virtualenv +Tool to create isolated Python environments. Unfortunately, +it does not expose a native Python API. This package aims to +provide an API in the form of a wrapper around virtualenv. + +%package -n python3-%{pypi_name} +Summary: An API for virtualenv/pip +%{?python_provide:%python_provide python3-%{pypi_name}} + +Requires: python3-six +%description -n python3-%{pypi_name} +virtualenv-api - an API for virtualenv +Tool to create isolated Python environments. Unfortunately, +it does not expose a native Python API. This package aims to +provide an API in the form of a wrapper around virtualenv. + +%prep +%autosetup -p1 -n %{pypi_name}-%{version} +# Remove bundled egg-info +rm -rf %{pypi_name}.egg-info + +%build +%py2_build +%py3_build + +%install +%py3_install +%py2_install + +%check +%{__python3} setup.py test + +%files -n python2-%{pypi_name} +%license LICENSE +%doc README.rst +%{python2_sitelib}/virtualenvapi +%{python2_sitelib}/%{underscore_name}-%{version}-py?.?.egg-info + +%files -n python3-%{pypi_name} +%license LICENSE +%doc README.rst +%{python3_sitelib}/virtualenvapi +%{python3_sitelib}/%{underscore_name}-%{version}-py?.?.egg-info + +%changelog +* Wed Mar 30 2016 Michal Cyprian - 2.1.8-1 +- Initial package. diff --git a/test_suite_fix.patch b/test_suite_fix.patch new file mode 100644 index 0000000..1bdd11d --- /dev/null +++ b/test_suite_fix.patch @@ -0,0 +1,56 @@ +diff --git a/tests.py b/tests.py +index 253cd6f..add5c06 100644 +--- a/tests.py ++++ b/tests.py +@@ -91,13 +91,13 @@ class BaseTest(TestCase): + self.assertIsInstance(result, dict) + self.assertTrue(bool(result)) + if result: +- self.assertIn(pack, [k.lower() for k in result.keys()]) ++ self.assertIn(pack, [k.split(' (')[0].lower() for k in result.keys()]) + + def test_search_names(self): + pack = packages_for_tests[0].lower() + result = self.virtual_env_obj.search_names(pack) + self.assertIsInstance(result, list) +- self.assertIn(pack, [k.lower() for k in result]) ++ self.assertIn(pack, [k.split(' (')[0].lower() for k in result]) + + def tearDown(self): + if os.path.exists(self.env_path) and self.__class__.env_path is None: +diff --git a/virtualenvapi/manage.py b/virtualenvapi/manage.py +index d834be7..53e00ac 100644 +--- a/virtualenvapi/manage.py ++++ b/virtualenvapi/manage.py +@@ -44,6 +44,16 @@ class VirtualEnvironment(object): + return os.path.join('bin', 'pip') + + @property ++ def pip_version(self): ++ """Version of installed pip.""" ++ if not self._pip_exists: ++ return None ++ if not hasattr(self, '_pip_version'): ++ string_version = self._execute([self._pip_rpath, '-V']).split()[1] ++ self._pip_version = tuple([int(n) for n in string_version.split('.')]) ++ return self._pip_version ++ ++ @property + def root(self): + """The root directory that this virtual environment exists in.""" + return os.path.split(self.path)[0] +@@ -270,10 +280,12 @@ class VirtualEnvironment(object): + def installed_packages(self): + """ + List of all packages that are installed in this environment in +- the format [(name, ver), ..]. ++ the format [(name, ver), ..]. wheel is excluded from freeze output ++ in pip version >= 8.1.0 if --all option is not specified. + """ ++ freeze_options = ['-l', '--all'] if self.pip_version >= (8, 1, 0) else ['-l'] + return list(map(split_package_name, filter(None, self._execute( +- [self._pip_rpath, 'freeze', '-l']).split(linesep)))) ++ [self._pip_rpath, 'freeze'] + freeze_options).split(linesep)))) + + @property + def installed_package_names(self):