2011-08-31 15:38:32 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import re
|
|
|
|
import sys
|
2012-03-27 18:45:35 +02:00
|
|
|
from distutils import log
|
|
|
|
try:
|
2012-03-27 18:58:19 +02:00
|
|
|
from setuptools import setup, Command
|
2012-03-27 18:45:35 +02:00
|
|
|
except ImportError:
|
2012-03-27 18:58:19 +02:00
|
|
|
from distutils.core import setup, Command
|
2011-08-31 15:38:32 +02:00
|
|
|
from glob import glob
|
|
|
|
|
|
|
|
import os
|
|
|
|
import io
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pym'))
|
|
|
|
|
|
|
|
__version__ = os.getenv('VERSION', default='9999')
|
|
|
|
|
|
|
|
cwd = os.getcwd()
|
|
|
|
|
|
|
|
# Load EPREFIX from Portage, fall back to the empty string if it fails
|
|
|
|
try:
|
2012-03-27 18:58:19 +02:00
|
|
|
from portage.const import EPREFIX
|
2011-08-31 15:38:32 +02:00
|
|
|
except ImportError:
|
2012-03-27 18:58:19 +02:00
|
|
|
EPREFIX = ''
|
2011-08-31 15:38:32 +02:00
|
|
|
|
|
|
|
# Python files that need `__version__ = ""` subbed, relative to this dir:
|
|
|
|
python_scripts = [os.path.join(cwd, path) for path in (
|
2012-03-27 18:58:19 +02:00
|
|
|
'bin/euscan',
|
2011-08-31 15:38:32 +02:00
|
|
|
)]
|
|
|
|
|
2012-03-27 18:45:35 +02:00
|
|
|
|
|
|
|
class set_version(Command):
|
2012-03-27 18:58:19 +02:00
|
|
|
"""Set python __version__ to our __version__."""
|
|
|
|
description = "hardcode scripts' version using VERSION from environment"
|
|
|
|
user_options = [] # [(long_name, short_name, desc),]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
ver = 'git' if __version__ == '9999' else __version__
|
|
|
|
print("Settings version to %s" % ver)
|
|
|
|
|
|
|
|
def sub(files, pattern):
|
|
|
|
for f in files:
|
|
|
|
updated_file = []
|
|
|
|
with io.open(f, 'r', 1, 'utf_8') as s:
|
|
|
|
for line in s:
|
|
|
|
newline = re.sub(pattern, '"%s"' % ver, line, 1)
|
|
|
|
if newline != line:
|
|
|
|
log.info("%s: %s" % (f, newline))
|
|
|
|
updated_file.append(newline)
|
|
|
|
with io.open(f, 'w', 1, 'utf_8') as s:
|
|
|
|
s.writelines(updated_file)
|
|
|
|
quote = r'[\'"]{1}'
|
|
|
|
python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote
|
|
|
|
sub(python_scripts, python_re)
|
2011-09-21 10:09:50 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
packages = [
|
2012-03-27 18:58:19 +02:00
|
|
|
str('.'.join(root.split(os.sep)[1:]))
|
|
|
|
for root, dirs, files in os.walk('pym/euscan')
|
|
|
|
if '__init__.py' in files
|
2011-08-31 15:38:32 +02:00
|
|
|
]
|
|
|
|
|
2012-05-05 16:09:04 +02:00
|
|
|
tests_require = [
|
|
|
|
'factory_boy',
|
|
|
|
]
|
|
|
|
|
2012-03-27 18:45:35 +02:00
|
|
|
setup(
|
2012-03-27 18:58:19 +02:00
|
|
|
name='euscan',
|
|
|
|
version=__version__,
|
|
|
|
description='Ebuild upstream scan utility.',
|
|
|
|
author='Corentin Chary',
|
|
|
|
author_email='corentin.chary@gmail.com',
|
|
|
|
maintainer='Corentin Chary',
|
|
|
|
maintainer_email='corentin.chary@gmail.com',
|
|
|
|
url='http://euscan.iksaif.net',
|
|
|
|
download_url=(
|
|
|
|
'https://github.com/iksaif/euscan/tarball/' +
|
|
|
|
('master' if __version__ == '9999' else ('euscan-%s' % __version__))
|
|
|
|
),
|
2012-04-28 14:56:43 +02:00
|
|
|
install_requires=['Django==1.4', 'django-annoying', 'South',
|
2012-05-06 20:03:49 +02:00
|
|
|
'django-piston', 'BeautifulSoup', "matplotlib"],
|
2012-03-27 18:58:19 +02:00
|
|
|
package_dir={'': 'pym'},
|
|
|
|
packages=packages,
|
|
|
|
package_data={},
|
|
|
|
scripts=python_scripts,
|
|
|
|
data_files=(
|
|
|
|
(os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man1'),
|
|
|
|
glob('man/*')),
|
|
|
|
),
|
|
|
|
cmdclass={
|
|
|
|
'set_version': set_version,
|
|
|
|
},
|
2012-05-05 16:09:04 +02:00
|
|
|
tests_require=tests_require,
|
|
|
|
extras_require={'test': tests_require},
|
|
|
|
test_suite='euscanwww.runtests.runtests',
|
2011-08-31 15:38:32 +02:00
|
|
|
)
|