-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
113 lines (94 loc) · 3.2 KB
/
Copy pathsetup.py
File metadata and controls
113 lines (94 loc) · 3.2 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
# PYTHON PACKAGING
# using setuptools : http://pythonhosted.org/setuptools/
import os
import sys
import setuptools
with open('pyros_config/_version.py') as vf:
exec(vf.read())
# Best Flow :
# $ gitchangelog >CHANGELOG.rst
# change version in code and changelog
# $ git commit CHANGELOG.rst pyros_config/_version.py -m "v<M.m.p>"
# $ git push
# WAIT FOR TRAVIS CHECKS
# $ python setup.py publish
# $ python setup.py tag
# => 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 PublishCommand(setuptools.Command):
"""Command to release this package to Pypi"""
description = "releases pyros_config to Pypi"
user_options = []
def initialize_options(self):
"""init options"""
pass
def finalize_options(self):
"""finalize options"""
pass
def run(self):
"""runner"""
os.system("pipenv run python setup.py sdist bdist bdist_wheel")
# OLD way:
# os.system("python setup.py sdist bdist_wheel upload")
# NEW way:
# Ref: https://packaging.python.org/distributing/
os.system("pipenv run twine upload dist/*")
print("You probably want to also tag the version now:")
print(" python setup.py tag")
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 TagCommand(setuptools.Command):
"""Command to release this package to Pypi"""
description = "tag a release of pyros_config"
user_options = []
def initialize_options(self):
"""init options"""
pass
def finalize_options(self):
"""finalize options"""
pass
def run(self):
"""runner"""
os.system("git tag -a {0} -m 'version {0}'".format(__version__))
os.system("git push --tags")
sys.exit()
# read the contents of your README file : https://packaging.python.org/guides/making-a-pypi-friendly-readme/
from os import path
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
setuptools.setup(name='pyros_config',
version=__version__,
description='Classes to manage a server configuration. Heavily inspired by flask',
long_description=long_description,
long_description_content_type="text/x-rst",
url='http://github.com/asmodehn/pyros-config',
author='AlexV',
author_email='asmodehn@gmail.com',
license='BSD',
packages=[
'pyros_config',
'pyros_config.tests',
],
entry_points={
'console_scripts': [
'pyros_config = pyros_config.__main__:main'
]
},
include_package_data=True, # use MANIFEST.in during install.
install_requires=[
'six',
'pytest' # since tests are embedded in the package
],
setup_requires=[
'pytest-runner',
],
tests_require=['pytest'],
cmdclass={
'tag': TagCommand,
'publish': PublishCommand,
},
zip_safe=False, # TODO testing...
)