114 lines
3.6 KiB
Python
Executable File
114 lines
3.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
import os
|
|
import platform
|
|
try:
|
|
from setuptools import setup
|
|
except ImportError:
|
|
from distutils.core import setup
|
|
from distutils.command.install import INSTALL_SCHEMES
|
|
|
|
|
|
# allow setup.py to be run from any path
|
|
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
|
|
|
|
README = open(os.path.join(os.path.dirname(__file__), 'README.txt')).read()
|
|
|
|
# Tell distutils not to put the data_files in platform-specific installation
|
|
# locations. See here for an explanation:
|
|
# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
|
|
for scheme in INSTALL_SCHEMES.values():
|
|
scheme['data'] = scheme['purelib']
|
|
|
|
rpm_install = ''
|
|
rpm_postinstall = ''
|
|
|
|
def fullsplit(path, result=None):
|
|
"""
|
|
Split a pathname into components (the opposite of os.path.join) in a
|
|
platform-neutral way.
|
|
"""
|
|
if result is None:
|
|
result = []
|
|
head, tail = os.path.split(path)
|
|
if head == '':
|
|
return [tail] + result
|
|
if head == path:
|
|
return result
|
|
return fullsplit(head, [tail] + result)
|
|
|
|
|
|
def is_astra_linux():
|
|
return 'Astra' in platform.dist()[0]
|
|
|
|
|
|
def find_packages(path):
|
|
packages = []
|
|
for dirpath, dirnames, filenames in os.walk(path):
|
|
for i, dirname in enumerate(dirnames):
|
|
if dirname.startswith('.'):
|
|
del dirnames[i]
|
|
if '__init__.py' in filenames:
|
|
packages.append('.'.join(fullsplit(dirpath)))
|
|
return packages
|
|
|
|
|
|
def find_data_files(path):
|
|
global rpm_install, rpm_postinstall
|
|
if is_astra_linux():
|
|
data_files = [
|
|
['/etc/default', ['data/astra/default/enserver']],
|
|
['/etc/logrotate.d', ['data/astra/logrotate.d/enserver']],
|
|
['/etc/systemd/system', ['data/astra/systemd/system/enserver.service']],
|
|
]
|
|
else:
|
|
data_files = [
|
|
['/etc/sysconfig', ['data/zarya/sysconfig/enserver']],
|
|
['/etc/init.d', ['data/zarya/init.d/enserver']],
|
|
['/etc/logrotate.d', ['data/zarya/logrotate.d/enserver']],
|
|
]
|
|
rpm_install = 'data/zarya/scripts/install.spec.inc'
|
|
rpm_postinstall = 'data/zarya/scripts/postinstall.sh'
|
|
for dirpath, dirnames, filenames in os.walk(path):
|
|
for i, dirname in enumerate(dirnames):
|
|
if dirname.startswith('.'):
|
|
del dirnames[i]
|
|
if filenames and '__init__.py' not in filenames:
|
|
data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
|
|
return data_files
|
|
|
|
def gen_options():
|
|
global rpm_install, rpm_postinstall
|
|
bdist_rpm = {}
|
|
if rpm_postinstall:
|
|
bdist_rpm['post_install'] = rpm_postinstall
|
|
if rpm_install:
|
|
bdist_rpm['install_script'] = rpm_install
|
|
return {'bdist_rpm':bdist_rpm} if bdist_rpm else {}
|
|
|
|
def get_version():
|
|
if 'VERSION' in os.environ:
|
|
return os.environ.get('VERSION')
|
|
else:
|
|
return open(os.path.join(os.path.dirname(__file__), 'VERSION')).read().strip()
|
|
|
|
setup(
|
|
name='enserver',
|
|
version=get_version(),
|
|
packages=find_packages('enserver'),
|
|
data_files=find_data_files('enserver'),
|
|
options=gen_options(),
|
|
description='EN-Server',
|
|
long_description=README,
|
|
url='http://www.kronshtadt.ru/',
|
|
author='Alexander Lazarev',
|
|
author_email='alexander.lazarev2@kronshtadt.ru',
|
|
classifiers=[
|
|
'Environment :: Web Environment',
|
|
'Operating System :: OS Independent',
|
|
'Programming Language :: Python',
|
|
'Programming Language :: Python :: 2.6',
|
|
'Programming Language :: Python :: 2.7',
|
|
'Topic :: Internet :: WWW/HTTP',
|
|
],
|
|
)
|