Skip to content

Commit

Permalink
Merge pull request #160 from vasily-v-ryabov/cache_handling
Browse files Browse the repository at this point in the history
Fix installation to custom location with "--no-cache-dir" option
  • Loading branch information
vasily-v-ryabov authored Jul 31, 2018
2 parents 36e997b + 2a59544 commit 1d3d38b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
9 changes: 9 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion comtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down
36 changes: 29 additions & 7 deletions test_pip_install.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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])
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()
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"""
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)

# 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))


if __name__ == '__main__':
unittest.main()

0 comments on commit 1d3d38b

Please sign in to comment.