diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-10-19 12:03:17 +0100 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-10-19 12:03:17 +0100 |
commit | 91bf71a998da0858a887741fdc6fff742b9c27d9 (patch) | |
tree | 2ddd72ef04c7026088461dd3436dec645db07dc8 | |
parent | b702988e2269595e871816f9180e0b49f612f538 (diff) | |
parent | 67cfcd712d16e2f0736d1b03a0f9e02a8303649a (diff) | |
download | python-setuptools-bitbucket-91bf71a998da0858a887741fdc6fff742b9c27d9.tar.gz |
Merge Pull Request #97
-rw-r--r-- | CHANGES.txt | 12 | ||||
-rw-r--r-- | setuptools/dist.py | 21 | ||||
-rw-r--r-- | setuptools/win32.py | 19 |
3 files changed, 50 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index d7e3369d..b1b7f2e8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,18 @@ CHANGES ======= +---------- +Unreleased +---------- + +* Issue #80, #209: Eggs that are downloaded for ``setup_requires``, + ``test_requires``, etc. are now placed in a ``.eggs`` directory instead of + the package root directory. This is a better place for them as it doesn't + cause later phases of setuptools to think that the package is already + installed and then not install the package permanently in the environment + (See #209). + + --- 6.1 --- diff --git a/setuptools/dist.py b/setuptools/dist.py index 8b36f67c..2d9da8c4 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -14,7 +14,8 @@ from distutils.errors import (DistutilsOptionError, DistutilsPlatformError, DistutilsSetupError) from setuptools.depends import Require -from setuptools.compat import basestring, PY2 +from setuptools.compat import basestring, PY2, unicode +from setuptools import win32 import pkg_resources def _get_unpatched(cls): @@ -305,6 +306,21 @@ class Distribution(_Distribution): else: self.convert_2to3_doctests = [] + def get_egg_cache_dir(self): + egg_cache_dir = os.path.join(os.curdir, '.eggs') + if not os.path.exists(egg_cache_dir): + os.mkdir(egg_cache_dir) + win32.hide_file(unicode(egg_cache_dir)) + readme_txt_filename = os.path.join(egg_cache_dir, 'README.txt') + with open(readme_txt_filename, 'w') as f: + f.write('This directory contains eggs that were downloaded ' + 'by setuptools to build, test, and run plug-ins.\n\n') + f.write('This directory caches those eggs to prevent ' + 'repeated downloads.\n\n') + f.write('However, it is safe to delete this directory.\n\n') + + return egg_cache_dir + def fetch_build_egg(self, req): """Fetch an egg needed for building""" @@ -328,8 +344,9 @@ class Distribution(_Distribution): if 'find_links' in opts: links = opts['find_links'][1].split() + links opts['find_links'] = ('setup', links) + install_dir = self.get_egg_cache_dir() cmd = easy_install( - dist, args=["x"], install_dir=os.curdir, exclude_scripts=True, + dist, args=["x"], install_dir=install_dir, exclude_scripts=True, always_copy=False, build_directory=None, editable=False, upgrade=False, multi_version=True, no_report=True, user=False ) diff --git a/setuptools/win32.py b/setuptools/win32.py new file mode 100644 index 00000000..fd373009 --- /dev/null +++ b/setuptools/win32.py @@ -0,0 +1,19 @@ +# From http://stackoverflow.com/questions/19622133/python-set-hide-attribute-on-folders-in-windows-os + +import ctypes + + +def hide_file(path): + """Sets the hidden attribute on a file or directory + + `path` must be unicode; be careful that you escape backslashes or use raw + string literals - e.g.: `u'G:\\Dir\\folder1'` or `ur'G:\Dir\folder1'`. + """ + + SetFileAttributesW = ctypes.windll.kernel32.SetFileAttributesW + + FILE_ATTRIBUTE_HIDDEN = 0x02 + + ret = SetFileAttributesW(path, FILE_ATTRIBUTE_HIDDEN) + if not ret: + raise ctypes.WinError() |