-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
131 lines (109 loc) · 4.39 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
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
#!/usr/bin/env python
import subprocess
import sys
import setuptools
import runpy
# Ref : https://packaging.python.org/single_source_version/#single-sourcing-the-version
# runpy is safer and a better habit than exec
version = runpy.run_path('filefinder2/_version.py')
__version__ = version.get('__version__')
# Best Flow :
# Clean previous build & dist
# $ gitchangelog >CHANGELOG.rst
# change version in code and changelog
# $ python setup.py prepare_release
# WAIT FOR TRAVIS CHECKS
# $ python setup.py publish
# => TODO : try to do a simpler "release" command
# Clean way to add a custom "python setup.py <command>"
# Ref setup.py command extension : https://blog.niteoweb.com/setuptools-run-custom-code-in-setup-py/
class PrepareReleaseCommand(setuptools.Command):
"""Command to release this package to Pypi"""
description = "prepare a release of filefinder2"
user_options = []
def initialize_options(self):
"""init options"""
pass
def finalize_options(self):
"""finalize options"""
pass
def run(self):
"""runner"""
# TODO :
# $ gitchangelog >CHANGELOG.rst
# change version in code and changelog
subprocess.check_call(
"git commit CHANGELOG.rst filefinder2/_version.py -m 'v{0}'".format(__version__), shell=True)
subprocess.check_call("git push", shell=True)
print("You should verify travis checks, and you can publish this release with :")
print(" python setup.py publish")
sys.exit()
# Clean way to add a custom "python setup.py <command>"
# Ref setup.py command extension : https://blog.niteoweb.com/setuptools-run-custom-code-in-setup-py/
class PublishCommand(setuptools.Command):
"""Command to release this package to Pypi"""
description = "releases filefinder2 to Pypi"
user_options = []
def initialize_options(self):
"""init options"""
# TODO : register option
pass
def finalize_options(self):
"""finalize options"""
pass
def run(self):
"""runner"""
# TODO : clean build/ and dist/ before building...
subprocess.check_call("python setup.py sdist", shell=True)
subprocess.check_call("python setup.py bdist_wheel", shell=True)
# OLD way:
# os.system("python setup.py sdist bdist_wheel upload")
# NEW way:
# Ref: https://packaging.python.org/distributing/
subprocess.check_call("twine upload dist/*", shell=True)
subprocess.check_call("git tag -a {0} -m 'version {0}'".format(__version__), shell=True)
subprocess.check_call("git push --tags", shell=True)
sys.exit()
setuptools.setup(name='filefinder2',
version=__version__,
description='PEP420 - implicit namespace packages for python 2.7',
url='http://github.com/asmodehn/filefinder2',
author='AlexV',
author_email='[email protected]',
license='MIT',
packages=[
'filefinder2',
],
# Reference for optional dependencies :
# http://stackoverflow.com/questions/4796936/does-pip-handle-extras-requires-from-setuptools-distribute-based-sources
install_requires=[
'six', # just to not have to redefine our 2/3 compatible types
],
cmdclass={
'prepare_release': PrepareReleaseCommand,
'publish': PublishCommand,
},
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',
# Indicate who your project is intended for
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: MIT License',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy'
],
)