-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
115 lines (99 loc) · 3.76 KB
/
setup.py
File metadata and controls
115 lines (99 loc) · 3.76 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Installation:
pip install git+https://github.com/Erotemic/futures_actors.git
Developing:
git clone https://github.com/Erotemic/futures_actors.git
pip install -e futures_actors
Pypi:
pip install twine
# First tag the source-code
VERSION=$(python -c "import setup; print(setup.version)")
echo $VERSION
git tag $VERSION -m "tarball tag $VERSION"
git push --tags origin master
# Build wheel for distribution
python setup.py bdist_wheel --universal
# Use twine to upload. This will prompt for username and password
twine upload --username erotemic --skip-existing dist/*
# Check the url to make sure everything worked
https://pypi.org/project/futures_actors/
"""
from setuptools import setup
import sys
def parse_version():
""" Statically parse the version number from __init__.py """
from os.path import dirname, join
import ast
init_fpath = join(dirname(__file__), 'futures_actors', '__init__.py')
with open(init_fpath) as file_:
sourcecode = file_.read()
pt = ast.parse(sourcecode)
class VersionVisitor(ast.NodeVisitor):
def visit_Assign(self, node):
for target in node.targets:
if target.id == '__version__':
self.version = node.value.s
visitor = VersionVisitor()
visitor.visit(pt)
return visitor.version
def parse_description():
"""
python -c "import setup; print(setup.parse_description())"
"""
from os.path import dirname, join, exists
readme_fpath = join(dirname(__file__), 'README.md')
print('readme_fpath = %r' % (readme_fpath,))
# This breaks on pip install, so check that it exists.
if exists(readme_fpath):
# try:
# # convert markdown to rst for pypi
# import pypandoc
# return pypandoc.convert(readme_fpath, 'rst')
# except Exception as ex:
# strip out markdown to make a clean readme for pypi
textlines = []
with open(readme_fpath, 'r') as f:
capture = False
for line in f.readlines():
if '# Purpose' in line:
capture = True
elif line.startswith('##'):
break
elif capture:
textlines += [line]
text = ''.join(textlines).strip()
text = text.replace('\n\n', '_NLHACK_')
text = text.replace('\n', ' ')
text = text.replace('_NLHACK_', '\n\n')
return text
version = parse_version()
install_requires = ['ubelt']
if sys.version_info.major == 2:
install_requires += ['futures']
if __name__ == '__main__':
setup(
name='futures_actors',
version=version,
author='Jon Crall',
install_requires=install_requires,
description='An extension of the concurrent.futures module to support stateful computations.',
long_description=parse_description(),
author_email='erotemic@gmail.com',
url='https://github.com/Erotemic/futures_actors',
license='Apache 2',
packages=['futures_actors'],
classifiers=[
# List of classifiers available at:
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
# This should be interpreted as Apache License v2.0
'License :: OSI Approved :: Apache Software License',
# Supported Python versions
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
],
)