1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/usr/bin/env python3
VERSION = '5.1.0'
long_description = '''\
ReText is simple text editor that supports Markdown and reStructuredText
markup languages. It is written in Python using PyQt libraries.'''
requires = ['docutils', 'Markdown', 'Markups', 'pyenchant', 'Pygments']
import re
import sys
from os.path import basename, join
from distutils import log
from distutils.core import setup, Command
from distutils.command.build import build
from distutils.command.sdist import sdist
from distutils.command.install_scripts import install_scripts
from distutils.command.upload import upload
from subprocess import check_call
from glob import glob
from warnings import filterwarnings
if sys.version_info[0] < 3:
sys.exit('Error: Python 3.x is required.')
def build_translations():
print('running build_translations')
error = None
for ts_file in glob(join('locale', '*.ts')):
try:
check_call(('lrelease', ts_file))
except Exception as e:
error = e
if error:
print('Failed to build translations:', error)
class retext_build(build):
def run(self):
build.run(self)
if not glob(join('locale', '*.qm')):
build_translations()
class retext_sdist(sdist):
def run(self):
build_translations()
sdist.run(self)
class retext_install_scripts(install_scripts):
def run(self):
import shutil
install_scripts.run(self)
for file in self.get_outputs():
log.info('renaming %s to %s', file, file[:-3])
shutil.move(file, file[:-3])
class retext_test(Command):
user_options = []
def initialize_options(self): pass
def finalize_options(self): pass
def run(self):
from tests import main
testprogram = main(module=None, argv=sys.argv[:1], verbosity=2, exit=False)
if not testprogram.result.wasSuccessful():
sys.exit(1)
class retext_upload(upload):
def run(self):
self.sign = True
self.identity = '0x2f1c8ae0'
upload.run(self)
for command, pyversion, filename in self.distribution.dist_files:
full_version = re.search(r'ReText-([\d\.]+)\.tar\.gz', filename).group(1)
new_path = ('mandriver@frs.sourceforge.net:/home/frs/project/r/re/retext/ReText-%s/%s' %
(full_version[:-2], basename(filename)))
args = ['scp', filename, filename + '.asc', new_path]
print('calling process', args)
check_call(args)
if '--no-rename' in sys.argv:
retext_install_scripts = install_scripts
sys.argv.remove('--no-rename')
filterwarnings('ignore', "Unknown distribution option: 'install_requires'")
setup(name='ReText',
version=VERSION,
description='Simple editor for Markdown and reStructuredText',
long_description=long_description,
author='Dmitry Shachnev',
author_email='mitya57@gmail.com',
url='http://retext.sourceforge.net/',
packages=['ReText'],
scripts=['retext.py'],
data_files=[
('share/retext/locale', glob('locale/*.qm'))
],
requires=requires,
install_requires=requires,
cmdclass={
'build': retext_build,
'sdist': retext_sdist,
'install_scripts': retext_install_scripts,
'test': retext_test,
'upload': retext_upload
},
license='GPL 2+'
)
|