Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
155 lines (128 loc) · 4.91 KB
/
Copy pathsetup.py
File metadata and controls
155 lines (128 loc) · 4.91 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Mathmaker Lib offers lualatex-printable mathematical objects.
# Copyright 2006-2019 Nicolas Hainaux <nh.techn@gmail.com>
# This file is part of Mathmaker Lib.
# Mathmaker Lib is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
# Mathmaker Lib is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Mathmaker Lib; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import sys
import os
import subprocess
from setuptools import setup, find_packages, Command
from setuptools.command.test import test as TestCommand
from mathmakerlib import __version__, __lib_name__, __licence__
from mathmakerlib import __author__, __author_email__, __url__
def read(*filenames, **kwargs):
encoding = kwargs.get('encoding', 'utf-8')
sep = kwargs.get('sep', '\n')
buf = []
for filename in filenames:
with open(filename, encoding=encoding) as f:
buf.append(f.read())
return sep.join(buf)
class CleanCommand(Command):
"""
Custom clean command to tidy up the project root.
Taken from http://stackoverflow.com/questions/3779915/why-does-python-
setup-py-sdist-create-unwanted-project-egg-info-in-project-r
"""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('rm -vrf ./build ./dist ./*.pyc ./*.tgz ./*.egg-info '
'./*.egg')
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
errcode = pytest.main(self.test_args)
sys.exit(errcode)
class Tox(TestCommand):
# user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.tox_args = None
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import tox
import shlex
args = self.tox_args
if args:
args = shlex.split(self.tox_args)
errno = tox.cmdline(args=args)
sys.exit(errno)
def create_mo_files(force=False):
if force:
return []
data_files = []
localedir = 'mathmaker/locale/'
po_dirs = [localedir + loc + '/LC_MESSAGES/'
for loc in next(os.walk(localedir))[1]]
for d in po_dirs:
mo_files = []
po_files = [f
for f in next(os.walk(d))[2]
if os.path.splitext(f)[1] == '.po']
for po_file in po_files:
filename, extension = os.path.splitext(po_file)
mo_file = filename + '.mo'
msgfmt_cmd = 'msgfmt {} -o {}'.format(d + po_file, d + mo_file)
subprocess.call(msgfmt_cmd, shell=True)
sys.stdout.write('Compiled {}\n as {}\n'.format(d + po_file,
d + mo_file))
mo_files.append(d + mo_file)
data_files.append((d, mo_files))
return data_files
setup(
name=__lib_name__,
version=__version__,
url=__url__,
license=__licence__,
author=__author__,
tests_require=['tox'],
install_requires=['microlib>=1.7'],
cmdclass={'test': PyTest,
'tox': Tox,
'clean': CleanCommand},
author_email=__author_email__,
description='Collection of lualatex-printable mathematical objects, '
'including geometric shapes.',
long_description=read('README.rst', 'CHANGELOG.rst', 'CONTRIBUTORS.rst'),
packages=find_packages(exclude=['tests', 'docs']),
data_files=create_mo_files(force='--force' in sys.argv),
include_package_data=True,
platforms='any',
test_suite='tests',
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3.8',
'Development Status :: 3 - Alpha',
'Natural Language :: English',
'License :: OSI Approved :: ' + __licence__,
'Topic :: Education :: Computer Aided Instruction (CAI)',
'Environment :: Console',
'Intended Audience :: Education',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Operating System :: POSIX :: BSD :: FreeBSD'],
extras_require={'testing': ['pytest']}
)