From cf1a54942d0e75011bb71994c89377e98b801704 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Fri, 6 Jul 2018 00:00:26 +0300 Subject: [PATCH 1/7] Add test for "pip install comtypes" (reproduce #155). --- appveyor.yml | 2 ++ test_pip_install.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test_pip_install.py diff --git a/appveyor.yml b/appveyor.yml index 27250fd2..2f453181 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,3 +24,5 @@ environment: test_script: - C:\%py%\python.exe setup.py install + - C:\%py%\Scripts\pip.exe uninstall comtypes -y + - C:\%py%\python.exe test_pip_install.py diff --git a/test_pip_install.py b/test_pip_install.py new file mode 100644 index 00000000..25ffdbd1 --- /dev/null +++ b/test_pip_install.py @@ -0,0 +1,24 @@ +import os +import sys +import subprocess + +def read_version(): + # Determine the version number by reading it from the file + # 'comtypes\__init__.py'. We cannot import this file (with py3, + # at least) because it is in py2.x syntax. + ns = {} + for line in open("comtypes/__init__.py"): + if line.startswith("__version__ = "): + var, value = line.split('=') + 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_output([sys.executable, 'setup.py', 'sdist', '--format=zip']) + +filename_for_upload = 'comtypes-{}.zip'.format(read_version()) +target_package = os.path.join(os.getcwd(), 'sdist', filename_for_upload) + +# run "pip install comtypes-x.y.z.zip" +pip_exe = os.path.join(os.path.dirname(sys.executable), 'Scripts', 'pip.exe') +subprocess.check_output([pip_exe, 'install', target_package]) From eb7aed5187cdfb7dcf13110d0b21cb7657338e08 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Fri, 6 Jul 2018 00:13:57 +0300 Subject: [PATCH 2/7] Fix test for pip. --- test_pip_install.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test_pip_install.py b/test_pip_install.py index 25ffdbd1..09b49ac4 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -14,11 +14,11 @@ def read_version(): raise NotImplementedError("__version__ is not found in __init__.py") # prepare the same package that is usually uploaded to PyPI -subprocess.check_output([sys.executable, 'setup.py', 'sdist', '--format=zip']) +subprocess.check_call([sys.executable, 'setup.py', 'sdist', '--format=zip']) filename_for_upload = 'comtypes-{}.zip'.format(read_version()) -target_package = os.path.join(os.getcwd(), 'sdist', filename_for_upload) +target_package = os.path.join(os.getcwd(), 'dist', filename_for_upload) # run "pip install comtypes-x.y.z.zip" pip_exe = os.path.join(os.path.dirname(sys.executable), 'Scripts', 'pip.exe') -subprocess.check_output([pip_exe, 'install', target_package]) +subprocess.check_call([pip_exe, 'install', target_package]) From 60cc65531da6c14044f4c6469bf74d848a25e432 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Fri, 6 Jul 2018 00:16:26 +0300 Subject: [PATCH 3/7] Fix test on Python 2.6. --- 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 09b49ac4..ccc67aa4 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -16,7 +16,7 @@ def read_version(): # prepare the same package that is usually uploaded to PyPI subprocess.check_call([sys.executable, 'setup.py', 'sdist', '--format=zip']) -filename_for_upload = 'comtypes-{}.zip'.format(read_version()) +filename_for_upload = 'comtypes-%s.zip' % read_version() target_package = os.path.join(os.getcwd(), 'dist', filename_for_upload) # run "pip install comtypes-x.y.z.zip" From 5bb6d0ea305669d4be4f34a61e0402370abd1a84 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Fri, 6 Jul 2018 00:19:34 +0300 Subject: [PATCH 4/7] Fix weird error with "pip install comtypes" (fix #155). --- comtypes/__init__.py | 2 +- setup.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/comtypes/__init__.py b/comtypes/__init__.py index a4c41970..08517c33 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.5" +__version__ = "1.1.6" import logging class NullHandler(logging.Handler): diff --git a/setup.py b/setup.py index 3c810698..1b887ea4 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ -"comtypes package install script" - +"""comtypes package install script""" import sys import os import ctypes @@ -94,6 +93,20 @@ def read_version(): class post_install(install): + + # both this static variable and method initialize_options() help to avoid + # weird setuptools error during "pip install comtypes" + user_options = install.user_options + [ + ('old-and-unmanageable', None, "Try not to use this!"), + ('single-version-externally-managed', None, + "used by system package builders to create 'flat' eggs"), + ] + + def initialize_options(self): + install.initialize_options(self) + self.old_and_unmanageable = None + self.single_version_externally_managed = None + def run(self): install.run(self) # Custom script we run at the end of installing - this is the same script From ea988fe2b13841fa11a826757f5dd27e03fe345f Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Fri, 6 Jul 2018 00:46:52 +0300 Subject: [PATCH 5/7] Remove unused line. --- setup.py | 1 - test_pip_install.py | 1 - 2 files changed, 2 deletions(-) diff --git a/setup.py b/setup.py index 1b887ea4..024417b9 100644 --- a/setup.py +++ b/setup.py @@ -84,7 +84,6 @@ def read_version(): # Determine the version number by reading it from the file # 'comtypes\__init__.py'. We cannot import this file (with py3, # at least) because it is in py2.x syntax. - ns = {} for line in open("comtypes/__init__.py"): if line.startswith("__version__ = "): var, value = line.split('=') diff --git a/test_pip_install.py b/test_pip_install.py index ccc67aa4..2e20cd31 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -6,7 +6,6 @@ def read_version(): # Determine the version number by reading it from the file # 'comtypes\__init__.py'. We cannot import this file (with py3, # at least) because it is in py2.x syntax. - ns = {} for line in open("comtypes/__init__.py"): if line.startswith("__version__ = "): var, value = line.split('=') From 7e4724cfbea0c5c54b22d7f7195c64f4b4fca2c4 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Tue, 10 Jul 2018 09:23:04 +0300 Subject: [PATCH 6/7] Add links to issue #155 and the source of the fix. --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 024417b9..4d2601db 100644 --- a/setup.py +++ b/setup.py @@ -94,7 +94,10 @@ def read_version(): class post_install(install): # both this static variable and method initialize_options() help to avoid - # weird setuptools error during "pip install comtypes" + # weird setuptools error with "pip install comtypes", details are here: + # https://github.com/enthought/comtypes/issues/155 + # the working solution was found here: + # https://github.com/pypa/setuptools/blob/3b90be7bb6323eb44d0f28864509c1d47aa098de/setuptools/command/install.py user_options = install.user_options + [ ('old-and-unmanageable', None, "Try not to use this!"), ('single-version-externally-managed', None, From 4bc767f53877876f99ad915c0ffb85d9bf0b0ccd Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Tue, 10 Jul 2018 09:25:48 +0300 Subject: [PATCH 7/7] Add doc string to the pip test. --- test_pip_install.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test_pip_install.py b/test_pip_install.py index 2e20cd31..5ed02c03 100644 --- a/test_pip_install.py +++ b/test_pip_install.py @@ -1,3 +1,4 @@ +"""This test covers 'pip install' issue #155""" import os import sys import subprocess