-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathsetup.py
132 lines (107 loc) · 3.62 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
131
132
from __future__ import print_function
import ftplib
import getpass
import os
import os.path as op
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
import shutil
import subprocess as sp
import sys
import diskcache
if sys.argv[-1] == 'release':
def run(command):
print('setup.py$', command)
sp.check_call(command.split())
version = b'v%s' % diskcache.__version__
shutil.rmtree(op.join('docs', '_build'), ignore_errors=True)
run('git checkout master')
if version in sp.check_output(['git', 'tag']):
print('Error: Version already tagged.')
sys.exit(1)
if sp.check_output(['git', 'status', '--porcelain']):
print('Error: Commit files in working directory before release.')
run('git status')
sys.exit(1)
run('git pull')
run('pylint diskcache')
run('tox')
run('git tag -a %s -m %s' % (version, version))
run('git push')
run('git push --tags')
run('python setup.py sdist')
run('twine upload dist/diskcache-%s.tar.gz' % diskcache.__version__)
root = os.getcwd()
os.chdir(op.join(root, 'docs'))
print('setup.py$ building docs')
run('make clean')
run('make html')
print('setup.py$ uploading docs')
ftps = ftplib.FTP_TLS(
'grantjenks.com',
user='grant',
passwd=getpass.getpass()
)
ftps.prot_p()
base = '/domains/grantjenks.com/docs/diskcache'
try:
ftps.mkd(base)
except ftplib.error_perm:
pass
os.chdir(op.join('_build', 'html'))
for root, dirs, files in os.walk('.'):
for directory in dirs:
print('Creating directory', op.join(root, directory))
try:
ftps.mkd('/'.join([base, root, directory]))
except ftplib.error_perm:
pass
for filename in files:
print('Uploading file', op.join(root, filename))
with open(op.join(root, filename), 'rb') as reader:
command = 'STOR %s/%s/%s' % (base, root, filename)
ftps.storbinary(command, reader)
sys.exit()
class Tox(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import tox
errno = tox.cmdline(self.test_args)
sys.exit(errno)
with open('README.rst') as reader:
readme = reader.read()
with open('LICENSE') as reader:
license = reader.read()
setup(
name='diskcache',
version=diskcache.__version__,
description='Disk and file-based cache',
long_description=readme,
author='Grant Jenks',
author_email='[email protected]',
url='http://www.grantjenks.com/docs/diskcache/',
packages=find_packages(exclude=('tests', 'docs')),
package_data={'': ['LICENSE', 'README.rst']},
tests_require=['tox'],
cmdclass={'test': Tox},
license='Apache 2.0',
install_requires=[],
classifiers=(
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
),
)