Skip to content

Commit

Permalink
Issue pyinstaller#521: Add compatible fucntion for site.getsitepackages.
Browse files Browse the repository at this point in the history
  • Loading branch information
matysek committed Jan 1, 2015
1 parent 96f65c6 commit 031bd23
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions PyInstaller/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import dircache # Module removed in Python 3
import os
import platform
import site
import subprocess
import sys

Expand Down Expand Up @@ -333,3 +334,23 @@ def __add_obsolete_options(parser):
**{'action': 'callback',
'callback': __obsolete_option,
'help': 'These options do not exist anymore.'})


# Site-packages functions - use native function if available.
if hasattr(site, 'getsitepackages'):
getsitepackages = site.getsitepackages
# Backported For Python 2.6.
else:
def getsitepackages():
"""
Return only one item as list with one item.
"""
# For now used only on Windows. Raise Exception for other platforms.
if is_win:
pths = [os.path.join(sys.prefix, 'Lib', 'site-packages')]
# Include Real sys.prefix for virtualenv.
if is_virtualenv:
pths.append[os.path.join(venv_real_prefix, 'Lib', 'site-packages')]
else:
# TODO Implement for Python 2.6 on other platforms.
raise NotImplementedError()

0 comments on commit 031bd23

Please sign in to comment.