You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
3.9 KiB

#!/usr/bin/env python
# setup.py --- Setup script for calculate-client
#Copyright 2008 Calculate Pack, http://www.calculate-linux.ru
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import glob
import sys
import re
from distutils.core import setup, Extension
module1 = Extension('calculate-client.pym._cl_keys',
library_dirs = ['/usr/lib'],
libraries = ['keyutils'],
sources = ['./lib/cl_keys.i','./lib/cl_keys.c'])
data_files = []
var_data_files = []
data_dirs_local = ['profile']
share_calculate_dir = "/usr/share/calculate/"
data_dirs_share = ['i18n']
data_files += var_data_files
def scanDirs(profilesDirs):
"""Recursive scanning directories"""
dirs = []
class dirProf:
def __init__(self):
self.baseDir = False
self.dirs = []
self.files = []
def getFilesDir(dirP, dirname,names):
if '/.svn' in dirname:
return False
for nameFile in names:
absNameFile = dirname + "/" + nameFile
if '/.svn' in absNameFile:
continue
if os.path.isfile(absNameFile):
dirP.files.append(absNameFile)
elif os.path.isdir(absNameFile):
dirP.dirs.append(absNameFile)
return True
for profileDir in profilesDirs:
if profileDir:
dirP = dirProf()
dirP.baseDir = profileDir
dirs.append(dirP)
os.path.walk(profileDir,getFilesDir, dirP)
return dirs
def create_data_files (data_dirs, prefix=""):
test1_files = []
data_files = []
dirs = scanDirs(data_dirs)
i = 0
for obj in dirs:
if not obj.dirs:
obj.dirs.append(data_dirs[i])
i += 1
for obj in dirs:
files_obj_dirs = []
for dir_name in obj.dirs:
for file_name in obj.files:
if re.match(dir_name,file_name):
files_obj_dirs.append(dir_name)
break
for files_obj_dir in files_obj_dirs:
obj.dirs.remove(files_obj_dir)
files_obj_dirs.sort(lambda x, y: cmp(len(y), len(x)))
for dir_name in files_obj_dirs:
wr_sp = (prefix+dir_name,[])
file_dirs = []
for file_name in obj.files:
if re.match(dir_name,file_name):
file_dirs.append(file_name)
for file_name in file_dirs:
wr_sp[1].append(file_name)
obj.files.remove(file_name)
test1_files.append(wr_sp)
test1_files.reverse()
test2_files = []
for obj in dirs:
for dir_name in obj.dirs:
wr_sp = (prefix+dir_name,[])
test2_files.append(wr_sp)
test1_files = test2_files + test1_files
return test1_files
data_files += create_data_files (data_dirs_local)
data_files += create_data_files (data_dirs_share, share_calculate_dir)
setup(
name = 'calculate-client',
version = "0.0.1",
description = "Client for the calculate-server",
author = "Calculate Pack",
author_email = "support@calculate.ru",
url = "http://calculate-linux.ru",
license = "http://www.apache.org/licenses/LICENSE-2.0",
package_dir = {'calculate-client': "."},
packages = ['calculate-client.pym'],
data_files = data_files,
scripts=["./scripts/cl-client",],
ext_modules = [module1],
)