-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
63 lines (55 loc) · 2.26 KB
/
setup.py
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
#!/usr/bin/env python
# Copyright (c) 2017 Fabrice Laporte - kray.me
# The MIT License http://www.opensource.org/licenses/mit-license.php
import sys
from setuptools import setup
def coerce_file(fn):
"""Coerce content of given file to something useful for setup(), turn :
.py into mock object with description and version fields,
.md into rst text. Remove images with "nopypi" alt text along the way.
:url: https://github.com/Kraymer/setupgoon
"""
import ast
import os
import re
import subprocess # noqa
text = open(os.path.join(os.path.dirname(__file__), fn)).read()
if fn.endswith('.py'): # extract version, docstring etc out of python file
mock = type('mock', (object,), {})()
for attr in ('version', 'author', 'author_email', 'license'):
regex = r'^__%s__\s*=\s*[\'"]([^\'"]*)[\'"]$' % attr
m = re.search(regex, text, re.MULTILINE)
setattr(mock, attr, m.group(1) if m else None)
mock.docstring = ast.get_docstring(ast.parse(text))
return mock
if fn.endswith('md') and 'upload' in sys.argv: # convert md to rest on pypi package upload
text = '\n'.join([l for l in text.split('\n') if '![nopypi' not in l])
p = subprocess.Popen(['pandoc', '-t', 'rst'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
text, stderr = p.communicate(text)
return text
setup(name='flinck',
version=coerce_file('flinck/__init__.py').version,
description=coerce_file('flinck/__init__.py').docstring,
long_description=coerce_file('README.md'),
author='Fabrice Laporte',
author_email='[email protected]',
url='https://github.com/KraYmer/flinck',
license='MIT',
platforms='ALL',
packages=['flinck', ],
entry_points={
'console_scripts': [
'flinck = flinck:flinck_cli',
],
},
install_requires=coerce_file('requirements.txt').split('\n'),
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Environment :: Console',
'Topic :: System :: Filesystems',
'Topic :: Multimedia :: Video'
],
keywords="movies organization omdb symlinks",
)