setup.py :  » Template-Engines » Clearsilver » clearsilver-0.10.5 » python » 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 » Template Engines » Clearsilver 
Clearsilver » clearsilver 0.10.5 » python » setup.py

import os, string, re, sys

# Check to see if the Egg system is installed (ie, setuptools)
# See http://peak.telecommunity.com/DevCenter/PythonEggs
USE_EGGS=1
try:
  from setuptools import setup
except ImportError:
  from distutils.core import setup
  USE_EGGS=0

from distutils.core import Extension
from distutils import sysconfig

VERSION = "0.10.5"
INC_DIRS = ["../"]
LIBRARIES = ["neo_cgi", "neo_cs", "neo_utl"]
LIB_DIRS = ["../libs"]
CC = "gcc"
LDSHARED = "gcc -shared"

## ARGGH!!  It looks like you can only specify a single item on the
## command-line or in the setup.cfg file for options which take multiple
## lists... and it overrides what is defined here.  So I have to do all
## the work of the configure file AGAIN here.  At least its in python,
## which is easier...
## Actually, forget that, I'm just going to load and parse the rules.mk
## file and build what I need

if not os.path.exists("../rules.mk"):
  raise "You need to run configure first to generate the rules.mk file!"

make_vars = { 'NEOTONIC_ROOT' : '..' }
rules = open("../rules.mk").read()
for line in string.split(rules, "\n"):
  parts = string.split(line, '=', 1)
  if len(parts) != 2: continue
  var, val = parts
  var = string.strip(var)
  make_vars[var] = val
  if var == "CFLAGS":
    matches = re.findall("-I(\S+)", val)
    inserted = []
    for inc_path in matches:
      # inc_path = match.group(1)
      if inc_path not in INC_DIRS:
        inserted.append(inc_path)
  sys.stderr.write("adding inc_path %s\n" % inc_path)
    INC_DIRS = inserted + INC_DIRS
  elif var == "LIBS":
    matches = re.findall("-l(\S+)", val)
    inserted = []
    for lib in matches:
      # lib = match.group(1)
      if lib not in LIBRARIES:
        inserted.append(lib)
  sys.stderr.write("adding lib %s\n" % lib)
    LIBRARIES = inserted + LIBRARIES
  elif var == "LDFLAGS":
    matches = re.findall("-L(\S+)", val)
    inserted = []
    for lib_path in matches:
      # lib_path = match.group(1)
      if lib_path not in LIB_DIRS:
        inserted.append(lib_path)
  sys.stderr.write("adding lib_path %s\n" % lib_path)
    LIB_DIRS = inserted + LIB_DIRS
  elif var == "CC":
    CC = val
  elif var == "LDSHARED":
    LDSHARED = val


def expand_var(var, vars):
  def replace_var(m, variables=vars):
    var = m.group(1)
    if var[:2] == "$(" and var[-1] == ")":
      var = variables.get(var[2:-1], "")
    return var
  while 1:
    new_var = re.sub('(\$\([^\)]*\))', replace_var, var)
    if new_var == var: break
    var = new_var
  return var.strip()

def expand_vars(vlist, vars):
  nlist = []
  for val in vlist:
    val = expand_var(val, vars)
    if val: nlist.append(val)
  return nlist

INC_DIRS = expand_vars(INC_DIRS, make_vars)
LIB_DIRS = expand_vars(LIB_DIRS, make_vars)
LIBRARIES = expand_vars(LIBRARIES, make_vars)

CC = os.environ.get('CC', expand_var(CC, make_vars))
LDSHARED = os.environ.get('LDSHARED', expand_var(CC, make_vars))

# HACK!  The setup/Makefile may not have the hermetic/cross-compiler entries
# for the compiler that we need, so override them here!
given_cc = sysconfig.get_config_var('CC')
if given_cc != CC and given_cc[0] != '/':
  sys.stderr.write("Overriding setup's CC from %s to %s\n" % (given_cc, CC))
  try:
    sysconfig._config_vars['CC'] = CC
    sysconfig._config_vars['LDSHARED'] = LDSHARED
  except AttributeError:
    pass

setup_args = {
    'name': "clearsilver",
    'version': VERSION,
    'description': "Python ClearSilver Wrapper",
    'author': "Brandon Long",
    'author_email': "blong@fiction.net",
    'url': "http://www.clearsilver.net/",
    'ext_modules': [Extension(
      name="neo_cgi",
      sources=["neo_cgi.c", "neo_cs.c", "neo_util.c"],
      include_dirs=INC_DIRS,
      library_dirs=LIB_DIRS,
      libraries=LIBRARIES,
      )]
  }

if USE_EGGS:
  setup_args['zip_safe'] = 0

apply(setup, [], setup_args)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.