get_python_lib.py
Go to the documentation of this file.
00001 #! /usr/bin/env python 00002 00003 ############################################################################## 00004 # @file get_python_lib.py 00005 # @brief Auxiliary Python script to get installation directory for site packages. 00006 # 00007 # Copyright (c) 2012 University of Pennsylvania. All rights reserved. 00008 # See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file. 00009 # 00010 # Contact: SBIA Group <sbia-software at uphs.upenn.edu> 00011 ############################################################################## 00012 00013 try: 00014 # this uses the same as packages which use easy_install for the installation 00015 # and returns also the proper site-packages directory on Ubuntu 00016 from setuptools.command.easy_install import easy_install 00017 00018 class easy_install_default(easy_install): 00019 def __init__(self): 00020 from distutils.dist import Distribution 00021 dist = Distribution() 00022 self.distribution = dist 00023 self.initialize_options() 00024 self._dry_run = None 00025 self.verbose = dist.verbose 00026 self.force = None 00027 self.help = 0 00028 self.finalized = 0 00029 00030 e = easy_install_default() 00031 import distutils.errors 00032 try: 00033 e.finalize_options() 00034 except distutils.errors.DistutilsError: 00035 pass 00036 00037 print e.install_dir.rstrip('/\\') 00038 except: 00039 # however, if the setuptools are not installed, fall back to the distutils 00040 import distutils.sysconfig 00041 print distutils.sysconfig.get_python_lib().rstrip('/\\')