setup.py :  » Language-Interface » PyPanel » PyPanel-2.4 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Language Interface » PyPanel 
PyPanel » PyPanel 2.4 » setup.py
import fileinput, os, sys
from distutils.core import Extension,setup
from distutils import sysconfig

# Full paths to imlib2-config and freetype-config, adjust as needed -
configs = ["/usr/bin/freetype-config", "/usr/bin/imlib2-config"]

# Adjust or add any additional include directories here -
idirs   = ["/usr/X11R6/include"]

# Add any additional library directories here -
ldirs   = []

# Add any additional compile options here -
cargs   = ["-Wall"]

# Full path to libImlib2 shared library
imlib2  = "/usr/lib/libImlib2.so.1"

#------------------------------------------------------------------------------
# The rest of this script should not need to be modified! 
#------------------------------------------------------------------------------
libs  = [] # libraries (listed without -l)
largs = [] # extra link arguments
defs  = [] # define macros
files = ["COPYING", "README", "ppicon.png", "pypanelrc"]
install_dir = sysconfig.get_python_lib() + "/pypanel"

# Check for Python Xlib
try:
    from Xlib import X,display,Xatom,Xutil
except:
    print "\nPyPanel requires the Python X library -"
    print "http://sourceforge.net/projects/python-xlib/"
    sys.exit()
   
# Parse the build options
for config in configs:
    package = os.path.split(config)[1]
    
    if os.path.isfile(config):
        for cflag in os.popen("%s --cflags" % config).read().strip().split(): 
            flag = cflag[:2]
            opt  = cflag[2:]    
            
            if flag == "-I" and opt not in idirs:
                idirs.append(opt)
            else:
                if cflag not in cargs:
                    cargs.append(cflag)    
                
        for lib in os.popen("%s --libs" % config).read().strip().split():
            flag = lib[:2]
            opt  = lib[2:]
            
            if flag == "-L" and opt not in ldirs:
                ldirs.append(opt)
            elif flag == "-l":
                if opt not in libs:
                    libs.append(opt)
            else:
                if lib not in largs:
                    largs.append(lib)
                
        if package == "freetype-config":
            defs.append(("HAVE_XFT", 1))
            if "Xft" not in libs:
                libs.append("Xft")
                
        if package == "imlib2-config":
            # Add the workaround for Imlib2 version 1.2.x and up -
            # Python dlopens libImlib2 with RTLD_LOCAL by default.  To avoid
            # undefined symbols, dlopen it first with the RTLD_GLOBAL flag.
            version = os.popen("%s --version" % config).read().strip()
            if float(version[:3]) >= 1.2:
                defs.append(("IMLIB2_FIX", 1))
            
    else:
        if package == "imlib2-config":
            print "\nPyPanel requires the Imlib2 library -"
            print "http://www.enlightenment.org/pages/imlib2.html"
            sys.exit()

# Fix the shebang and add the Imlib2 workaround if necessary
if len(sys.argv) > 1 and sys.argv[1] != "sdist":
    for line in fileinput.input(["pypanel"], inplace=1):
        if fileinput.isfirstline():
            print "#!%s -OO" % sys.executable
        else:
            print line,  
            
    if ("IMLIB2_FIX", 1) in defs:
        for line in fileinput.input(["ppmodule.c"], inplace=1):
            if "handle = dlopen" in line:
                print '    handle = dlopen("%s", RTLD_NOW|RTLD_GLOBAL);' % imlib2
            else:
                print line,   
                
                   
# Distutils config
module = Extension("ppmodule",
                   sources            = ["ppmodule.c"],
                   include_dirs       = idirs,
                   library_dirs       = ldirs,
                   libraries          = libs,  
                   extra_compile_args = cargs,
                   extra_link_args    = largs,
                   define_macros      = defs,                    
                  )  

setup(name             = "PyPanel",
      author           = "Jon Gelo",
      author_email     = "ziljian@users.sourceforge.net",
      version          = "2.4",
      license          = "GPL",
      platforms        = "POSIX",
      description      = "Lightweight panel/taskbar for X11 Window Managers",
      long_description = "See README for more information",
      url              = "http://pypanel.sourceforge.net",
      data_files       = [(install_dir, files)],
      scripts          = ["pypanel"],
      ext_modules      = [module]
     )
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.