From 6d1e9fbca8a1cb22b73bee0ab70837424400052d Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Mon, 30 Jul 2018 18:42:45 +0300 Subject: [PATCH 1/6] Re-write pip tests to catch issue #158. --- test_pip_install.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/test_pip_install.py b/test_pip_install.py index 5ed02c03..dfae2f2a 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -1,7 +1,9 @@ """This test covers 'pip install' issue #155""" import os import sys +import shutil import subprocess +import unittest def read_version(): # Determine the version number by reading it from the file @@ -13,12 +15,32 @@ def read_version(): return value.strip().strip('"').strip("'") raise NotImplementedError("__version__ is not found in __init__.py") -# prepare the same package that is usually uploaded to PyPI -subprocess.check_call([sys.executable, 'setup.py', 'sdist', '--format=zip']) -filename_for_upload = 'comtypes-%s.zip' % read_version() -target_package = os.path.join(os.getcwd(), 'dist', filename_for_upload) +class TestPipInstall(unittest.TestCase): -# run "pip install comtypes-x.y.z.zip" -pip_exe = os.path.join(os.path.dirname(sys.executable), 'Scripts', 'pip.exe') -subprocess.check_call([pip_exe, 'install', target_package]) + @classmethod + def setUpClass(cls): + print("Calling setUpClass...") + # prepare the same package that is usually uploaded to PyPI + subprocess.check_call([sys.executable, 'setup.py', 'sdist', '--format=zip']) + + filename_for_upload = 'comtypes-%s.zip' % read_version() + cls.target_package = os.path.join(os.getcwd(), 'dist', filename_for_upload) + cls.pip_exe = os.path.join(os.path.dirname(sys.executable), 'Scripts', 'pip.exe') + + def test_pip_install(self): + """Test that "pip install comtypes-x.y.z.zip" works""" + subprocess.check_call([self.pip_exe, 'install', self.target_package]) + + def test_no_cache_dir_custom_location(self): + """Test that 'pip install comtypes-x.y.z.zip --no-cache-dir --target="...\custom location"' works""" + custom_dir = os.path.join(os.getcwd(), 'custom location') + if os.path.exists(custom_dir): + shutil.rmtree(custom_dir) + os.makedirs(custom_dir) + # subprocess.check_call([self.pip_exe, 'install', self.target_package, '--no-cache-dir', '--target="{}"'.format(custom_dir)], shell=True) + subprocess.check_call('{} install {} --no-cache-dir --target="{}"'.format(self.pip_exe, self.target_package, custom_dir)) + + +if __name__ == '__main__': + unittest.main() From ac197d2b25c938aca437963568ddb369830ea2cf Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Mon, 30 Jul 2018 18:47:17 +0300 Subject: [PATCH 2/6] Use setUp() method for compatibility with Python 2.6. --- test_pip_install.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test_pip_install.py b/test_pip_install.py index dfae2f2a..af3df8d6 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -18,15 +18,13 @@ def read_version(): class TestPipInstall(unittest.TestCase): - @classmethod - def setUpClass(cls): - print("Calling setUpClass...") - # prepare the same package that is usually uploaded to PyPI + def setUp(self): + """prepare the same package that is usually uploaded to PyPI""" subprocess.check_call([sys.executable, 'setup.py', 'sdist', '--format=zip']) filename_for_upload = 'comtypes-%s.zip' % read_version() - cls.target_package = os.path.join(os.getcwd(), 'dist', filename_for_upload) - cls.pip_exe = os.path.join(os.path.dirname(sys.executable), 'Scripts', 'pip.exe') + self.target_package = os.path.join(os.getcwd(), 'dist', filename_for_upload) + self.pip_exe = os.path.join(os.path.dirname(sys.executable), 'Scripts', 'pip.exe') def test_pip_install(self): """Test that "pip install comtypes-x.y.z.zip" works""" @@ -38,7 +36,7 @@ def test_no_cache_dir_custom_location(self): if os.path.exists(custom_dir): shutil.rmtree(custom_dir) os.makedirs(custom_dir) - # subprocess.check_call([self.pip_exe, 'install', self.target_package, '--no-cache-dir', '--target="{}"'.format(custom_dir)], shell=True) + subprocess.check_call('{} install {} --no-cache-dir --target="{}"'.format(self.pip_exe, self.target_package, custom_dir)) From 9c2a7a1ed8ec8b9539f5e40c120eb3cef47f2bff Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Mon, 30 Jul 2018 18:56:15 +0300 Subject: [PATCH 3/6] Fix path to post install script (fix #158). --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 4d2601db..f29eea0a 100644 --- a/setup.py +++ b/setup.py @@ -114,9 +114,7 @@ def run(self): # Custom script we run at the end of installing - this is the same script # run by bdist_wininst if not self.dry_run and not self.root: - # We must run the script we just installed into Scripts, as it - # may have had 2to3 run over it. - filename = os.path.join(self.prefix, "Scripts", "clear_comtypes_cache.py") + filename = os.path.join(self.install_scripts, "clear_comtypes_cache.py") if not os.path.isfile(filename): raise RuntimeError("Can't find '%s'" % (filename,)) print("Executing post install script...") From 60fedbc2cdde68b2624d4979e7e0d7846be0aa7f Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Mon, 30 Jul 2018 20:40:13 +0300 Subject: [PATCH 4/6] Fix Python 2.6 compatibility. --- test_pip_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_pip_install.py b/test_pip_install.py index af3df8d6..075729c6 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -37,7 +37,7 @@ def test_no_cache_dir_custom_location(self): shutil.rmtree(custom_dir) os.makedirs(custom_dir) - subprocess.check_call('{} install {} --no-cache-dir --target="{}"'.format(self.pip_exe, self.target_package, custom_dir)) + subprocess.check_call('{0} install {1} --no-cache-dir --target="{2}"'.format(self.pip_exe, self.target_package, custom_dir)) if __name__ == '__main__': From ad1759d427b6eae1b63127799bdd32ad4a0a6d42 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Mon, 30 Jul 2018 21:07:21 +0300 Subject: [PATCH 5/6] Bump version, update changes history. --- CHANGES.txt | 9 +++++++++ comtypes/__init__.py | 2 +- test_pip_install.py | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6f45c871..6d8410e4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,15 @@ Comtypes CHANGELOG ================== +Release 1.1.7 +------------- + * Fix command ``pip install comtypes --no-cache-dir --target="C:\tmp"`` (issue #158). + +Release 1.1.6 +------------- + * Fix ``pip install comtypes`` error: "option --single-version-externally-managed + not recognized" (issue #155). + Release 1.1.5 ------------- * Fix using temp directory as a cache folder when it has no write permission. diff --git a/comtypes/__init__.py b/comtypes/__init__.py index 08517c33..995b3d0b 100644 --- a/comtypes/__init__.py +++ b/comtypes/__init__.py @@ -3,7 +3,7 @@ import os # comtypes version numbers follow semver (http://semver.org/) and PEP 440 -__version__ = "1.1.6" +__version__ = "1.1.7" import logging class NullHandler(logging.Handler): diff --git a/test_pip_install.py b/test_pip_install.py index 075729c6..084c368f 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -37,6 +37,7 @@ def test_no_cache_dir_custom_location(self): shutil.rmtree(custom_dir) os.makedirs(custom_dir) + # this test catches issue #158 subprocess.check_call('{0} install {1} --no-cache-dir --target="{2}"'.format(self.pip_exe, self.target_package, custom_dir)) From 2a59544d7b174bd3f90e01776955eb2e33c95583 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Mon, 30 Jul 2018 21:15:01 +0300 Subject: [PATCH 6/6] Fit into 120 symbols. --- test_pip_install.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test_pip_install.py b/test_pip_install.py index 084c368f..27347957 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -38,7 +38,8 @@ def test_no_cache_dir_custom_location(self): os.makedirs(custom_dir) # this test catches issue #158 - subprocess.check_call('{0} install {1} --no-cache-dir --target="{2}"'.format(self.pip_exe, self.target_package, custom_dir)) + subprocess.check_call('{0} install {1} --no-cache-dir --target="{2}"' \ + ''.format(self.pip_exe, self.target_package, custom_dir)) if __name__ == '__main__':