Skip to content
This repository
Browse code

Merge pull request #67 from reinout/reinout-33-cornercase

Fix for #64: __pycache__ dir inside distutils scripts metadata directory
  • Loading branch information...
commit 3bf9b96ce6550b46c7504d799bf2c3ca0f26c529 2 parents a31ae81 + 7c397c5
Jim Fulton jimfulton authored
7 CHANGES.rst
Source Rendered
... ... @@ -1,6 +1,13 @@
1 1 Change History
2 2 **************
3 3
  4 +Next version
  5 +============
  6 +
  7 +- Fix for distutils scripts installation on Python 3, related to
  8 + ``__pycache__`` directories.
  9 +
  10 +
4 11 2.0.0 (2013-02-10)
5 12 ==================
6 13
3  src/zc/buildout/easy_install.py
@@ -915,6 +915,9 @@ def scripts(reqs, working_set, executable, dest=None,
915 915 # /EGG-INFO/scripts/.
916 916 if dist.metadata_isdir('scripts'):
917 917 for name in dist.metadata_listdir('scripts'):
  918 + if dist.metadata_isdir('scripts/' + name):
  919 + # Probably Python 3 __pycache__ directory.
  920 + continue
918 921 contents = dist.get_metadata('scripts/' + name)
919 922 distutils_scripts.append((name, contents))
920 923 else:
14 src/zc/buildout/easy_install.txt
@@ -957,6 +957,20 @@ contain a source encoding hint; buildout retains it.
957 957 Due to the nature of distutils scripts, buildout cannot pass arguments as
958 958 there's no specific method to pass them to.
959 959
  960 +In some cases, a python 3 ``__pycache__`` directory can end up in an internal
  961 +``EGG-INFO`` metadata directory, next to the script information we're looking
  962 +for. Buildout doesn't crash on that:
  963 +
  964 + >>> eggname = [name for name in os.listdir(distdir2)
  965 + ... if name.endswith('egg')][0]
  966 + >>> scripts_metadata_dir = os.path.join(
  967 + ... distdir2, eggname, 'EGG-INFO', 'scripts')
  968 + >>> os.mkdir(os.path.join(scripts_metadata_dir, '__dummy__'))
  969 + >>> scripts = zc.buildout.easy_install.scripts(
  970 + ... ['du_zipped'], ws, sys.executable, distbin2)
  971 + >>> ls(distbin2)
  972 + - distutilsscript
  973 +
960 974
961 975 Handling custom build options for extensions provided in source distributions
962 976 -----------------------------------------------------------------------------

4 comments on commit 3bf9b96

Lennart Regebro

Wouldn't it be better to simply just skip __pycache__ instead of skipping all directories, because they "probably" are the __pycache__ directory?

Reinout van Rees

Scripts cannot be directories. So omitting directories safeguards us against any possible future weirdness.

Lennart Regebro

That makes sense. The comment ought to be specific about that, though.

Marius Gedminas
Collaborator

dist.get_metadata('scripts/' + name) will raise an error when 'scripts/' + name points to a directory, even when that directory is not __pycache__.

Please sign in to comment.
Something went wrong with that request. Please try again.