From c9614cda09a8ade33d1fca5823443678cf81a655 Mon Sep 17 00:00:00 2001 From: Michal Cyprian Date: Jun 06 2016 11:20:32 +0000 Subject: Update to 2.1.9 --- diff --git a/.gitignore b/.gitignore index 4622af3..7f5f8e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /virtualenv-api-2.1.8.tar.gz +/virtualenv-api-2.1.9.tar.gz diff --git a/add_tests_license.patch b/add_tests_license.patch new file mode 100644 index 0000000..c8a2ff5 --- /dev/null +++ b/add_tests_license.patch @@ -0,0 +1,180 @@ +diff --git a/LICENSE b/LICENSE +new file mode 100644 +index 0000000..4c9bdaf +--- /dev/null ++++ b/LICENSE +@@ -0,0 +1,22 @@ ++Copyright (c) 2013-2015 Sam Kingston and AUTHORS. ++All rights reserved. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are met: ++ ++1. Redistributions of source code must retain the above copyright notice, this ++ list of conditions and the following disclaimer. ++2. Redistributions in binary form must reproduce the above copyright notice, ++ this list of conditions and the following disclaimer in the documentation ++ and/or other materials provided with the distribution. ++ ++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ++ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ++ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ++LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ++ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +diff --git a/tests.py b/tests.py +new file mode 100644 +index 0000000..add5c06 +--- /dev/null ++++ b/tests.py +@@ -0,0 +1,146 @@ ++import os ++import random ++import shutil ++import string ++import tempfile ++from unittest import TestCase ++import unittest ++import sys ++import six ++from virtualenvapi.manage import VirtualEnvironment ++ ++ ++packages_for_pre_install = ['pep8', 'wheel'] ++packages_for_tests = ['flask', 'git+git://github.com/sjkingo/django_auth_ldap3.git'] ++ ++ ++def which(program): ++ ++ def is_exe(fpath): ++ return os.path.isfile(fpath) and os.access(fpath, os.X_OK) ++ ++ fpath, fname = os.path.split(program) ++ ++ if fpath: ++ if is_exe(program): ++ return program ++ else: ++ for path in os.environ["PATH"].split(os.pathsep): ++ path = path.strip('"') ++ exe_file = os.path.join(path, program) ++ if is_exe(exe_file): ++ return exe_file ++ return None ++ ++ ++class BaseTest(TestCase): ++ ++ env_path = None ++ ++ def setUp(self): ++ self.env_path = self.setup_env() ++ self.virtual_env_obj = VirtualEnvironment(self.env_path) ++ ++ def setup_env(self): ++ env_path = self.env_path ++ if env_path is None: ++ env_path = tempfile.mkdtemp('test_env') ++ virt_env = VirtualEnvironment(env_path) ++ virt_env._create() ++ for pack in packages_for_pre_install: ++ virt_env.install(pack) ++ ++ return env_path ++ ++ def _install_packages(self, packages): ++ for pack in packages: ++ self.virtual_env_obj.install(pack) ++ ++ def _uninstall_packages(self, packages): ++ for pack in packages: ++ self.virtual_env_obj.uninstall(pack) ++ ++ def test_installed(self): ++ for pack in packages_for_pre_install: ++ self.assertTrue(self.virtual_env_obj.is_installed(pack)) ++ self.assertFalse(self.virtual_env_obj.is_installed(''.join(random.sample(string.ascii_letters, 30)))) ++ ++ def test_install(self): ++ self._uninstall_packages(packages_for_tests) ++ for pack in packages_for_tests: ++ self.virtual_env_obj.install(pack) ++ self.assertTrue(self.virtual_env_obj.is_installed(pack)) ++ ++ def test_uninstall(self): ++ self._install_packages(packages_for_tests) ++ for pack in packages_for_tests: ++ if pack.endswith('.git'): ++ pack = pack.split('/')[-1].replace('.git', '') ++ self.virtual_env_obj.uninstall(pack) ++ self.assertFalse(self.virtual_env_obj.is_installed(pack)) ++ ++ def test_wheel(self): ++ for pack in packages_for_tests: ++ self.virtual_env_obj.wheel(pack, options=['--wheel-dir=/tmp/wheelhouse']) ++ self.virtual_env_obj.install(pack, options=['--no-index', '--find-links=/tmp/wheelhouse', '--use-wheel']) ++ self.assertTrue(self.virtual_env_obj.is_installed(pack)) ++ ++ def test_search(self): ++ pack = packages_for_tests[0].lower() ++ result = self.virtual_env_obj.search(pack) ++ self.assertIsInstance(result, dict) ++ self.assertTrue(bool(result)) ++ if result: ++ 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.split(' (')[0].lower() for k in result]) ++ ++ def tearDown(self): ++ if os.path.exists(self.env_path) and self.__class__.env_path is None: ++ shutil.rmtree(self.env_path) ++ ++ ++class Python3TestCase(BaseTest): ++ ++ def setUp(self): ++ self.env_path = self.setup_env() ++ self.python = which('python') ++ self.assertIsNotNone(self.python) ++ self.virtual_env_obj = VirtualEnvironment(self.env_path, python=self.python) ++ ++ def test_python_version(self): ++ self.assertEqual(self.virtual_env_obj.python, self.python) ++ self.assertEqual( ++ os.path.dirname(self.python), ++ os.path.dirname(which('pip')) ++ ) ++ ++ ++class EnvironmentTest(BaseTest): ++ ++ def setup_env(self): ++ act_filename = 'activate_this.py' ++ env_path = super(EnvironmentTest, self).setup_env() ++ act_path = os.path.join(env_path, 'bin', act_filename) ++ if six.PY2: ++ execfile(act_path, dict(__file__=act_path)) ++ elif six.PY3: ++ with open(act_path, "r") as fh: ++ exec(fh.read()) ++ else: ++ raise EnvironmentError('Unknown version of python') ++ return env_path ++ ++ ++if __name__ == '__main__': ++ # ToDo refactoring ++ if len(sys.argv) == 2 and sys.argv[1].startswith('--env='): ++ env_path = sys.argv[1].split('=', 1)[-1] ++ BaseTest.env_path = env_path ++ sys.argv = sys.argv[:1] ++ ++ unittest.main() diff --git a/python-virtualenv-api.spec b/python-virtualenv-api.spec index cf361a2..33522cd 100644 --- a/python-virtualenv-api.spec +++ b/python-virtualenv-api.spec @@ -3,20 +3,20 @@ %global underscore_name virtualenv_api # test suite is disabled default for koji builds, -# because tests require internet connection. +# because the tests require internet connection. %global run_test_suite 0 Name: python-%{pypi_name} -Version: 2.1.8 -Release: 2%{?dist} +Version: 2.1.9 +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 +# Add tests and LICENSE missing in sources +Patch0: add_tests_license.patch BuildArch: noarch @@ -96,6 +96,9 @@ rm -rf %{pypi_name}.egg-info %{python3_sitelib}/%{underscore_name}-%{version}-py?.?.egg-info %changelog +* Mon Jun 06 2016 Michal Cyprian - 2.1.8-4 +- Update to 2.1.9 + * Wed Apr 13 2016 Michal Cyprian - 2.1.8-2 - Add requires, use test_suite enabling macro diff --git a/sources b/sources index 4d87953..89b1b89 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -245a60b17fde734e292b57bf0447e4bf virtualenv-api-2.1.8.tar.gz +b21bc80e18c73c694948acbd1f659f5c virtualenv-api-2.1.9.tar.gz diff --git a/test_suite_fix.patch b/test_suite_fix.patch deleted file mode 100644 index 1bdd11d..0000000 --- a/test_suite_fix.patch +++ /dev/null @@ -1,56 +0,0 @@ -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):