-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
177 lines (169 loc) · 5.81 KB
/
setup.py
File metadata and controls
177 lines (169 loc) · 5.81 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# -*- coding: utf-8 -*- vim: et ts=8 sw=4 sts=4 si tw=79 cc=+1
"""Installer for the visaplan.js.urlsplit package."""
from setuptools import find_packages
from setuptools import setup
from os.path import isfile
package_name = 'visaplan.js.urlsplit'
# -------------------------------------------- [ get the version ... [
def read_version(fn, sfn):
main = open(fn).read().strip()
if sfn is not None and isfile(sfn):
suffix = valid_suffix(open(sfn).read().strip())
else:
suffix = ''
return main + suffix
# ... get the version ...
def valid_suffix(suffix):
"""
Enforce our suffix convention
"""
suffix = suffix.strip()
if not suffix:
return suffix
allowed = set('.dev0123456789')
disallowed = set(suffix).difference(allowed)
if disallowed:
disallowed = ''.join(sorted(disallowed))
raise ValueError('Version suffix contains disallowed characters'
' (%(disallowed)s)'
% locals())
chunks = suffix.split('.')
chunk = chunks.pop(0)
if chunk:
raise ValueError('Version suffix must start with "."'
' (%(suffix)r)'
% locals())
if not chunks:
raise ValueError('Version suffix is too short'
' (%(suffix)r)'
% locals())
for chunk in chunks:
if not chunk:
raise ValueError('Empty chunk %(chunk)r in '
'version suffix %(suffix)r'
% locals())
char = chunk[0]
if char in '0123456789':
raise ValueError('Chunk %(chunk)r of version suffix %(suffix)r'
' starts with a digit'
% locals())
char = chunk[-1]
if char not in '0123456789':
raise ValueError('Chunk %(chunk)r of version suffix %(suffix)r'
' doesn\'t end with a digit'
% locals())
return suffix # ... valid_suffix
# ... get the version ...
# ... get the version ...
VERSION = read_version('VERSION',
'VERSION_SUFFIX')
# -------------------------------------------- ] ... get the version ]
# ------------------------------------------- [ for setup_kwargs ... [
long_description = '\n\n'.join([
open('README.rst').read(),
open('CONTRIBUTORS.rst').read(),
open('CHANGES.rst').read(),
])
# see as well --> src/visaplan/js/urlsplit/configure.zcml:
exclude_subpackages = (
)
exclude_packages = []
for subp in exclude_subpackages:
exclude_packages.extend([package_name + '.' + subp,
package_name + '.' + subp + '.*',
])
packages = find_packages(
'src',
exclude=exclude_packages)
def github_urls(package, **kwargs):
pop = kwargs.pop
pkg_list = package.split('.')
res = {}
readthedocs = pop('readthedocs', False)
if readthedocs:
if readthedocs in (1, True):
readthedocs = ''.join(pkg_list)
res['Documentation'] = \
'https://%(readthedocs)s.readthedocs.io' % locals()
assert 'docs' not in kwargs
else:
docs = pop('docs', None)
if docs is None:
res['Documentation'] = 'https://pypi.org/project/%(package)s' \
% locals()
elif docs:
res['Documentation'] = docs
if not pop('github', 1):
assert not kwargs
return res
pop_user = pop('pop_user', False)
if pop_user:
assert 'pick_user' not in kwargs
assert 'user' not in kwargs
user = pkg_list.pop(0)
package = '.'.join(pkg_list)
else:
pick_user = pop('pick_user', 'user' not in kwargs)
if pick_user:
user = pkg_list[0]
if 'user' in kwargs:
assert pop('user') == user
base = 'https://github.com/%(user)s/%(package)s' % locals()
res.update({
'Source': base,
'Tracker': base + '/issues',
})
return res
project_urls = github_urls(package_name,
pop_user=0) # or pick_user=1, or github=0
# ------------------------------------------- ] ... for setup_kwargs ]
setup_kwargs = dict(
name=package_name,
version=VERSION,
description="Plone integration of urlSplit.js",
long_description=long_description,
long_description_content_type='text/x-rst',
# Get more from https://pypi.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Environment :: Web Environment",
"Framework :: Plone",
"Framework :: Plone :: 4.3",
"Framework :: Zope",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
],
# keywords='Python Plone',
author='Tobias Herp',
author_email='tobias.herp@visaplan.com',
project_urls=project_urls,
license='MIT',
packages=packages,
namespace_packages=['visaplan', 'visaplan.js'],
package_dir={'': 'src'},
include_package_data=True,
zip_safe=False,
install_requires=[
'setuptools',
# -*- Extra requirements: -*-
'plone.resource',
'Products.GenericSetup>=1.8.2',
],
extras_require={
'test': [
'plone.app.testing',
# plone.app.robotframework 1.2.0 requires plone.testing 4.0.11;
# plone.app.robotframework 1.3+ drops Plone 4.3 compatibility:
'plone.testing',
# currently disabled because of import problems:
# 'plone.app.robotframework[debug]',
],
},
entry_points="""
[z3c.autoinclude.plugin]
target = plone
""",
)
setup(**setup_kwargs)