Skip to content

Commit c8d485c

Browse files
committed
📰 add missing text fixture
1 parent 9c299be commit c8d485c

File tree

1 file changed

+196
-0
lines changed

1 file changed

+196
-0
lines changed

tests/fixtures/setup.py.output

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
#!/usr/bin/env python3
2+
3+
# Template by pypi-mobans
4+
import os
5+
import sys
6+
import codecs
7+
import locale
8+
import platform
9+
from shutil import rmtree
10+
11+
from setuptools import Command, setup, find_packages
12+
13+
PY2 = sys.version_info[0] == 2
14+
PY26 = PY2 and sys.version_info[1] < 7
15+
PY33 = sys.version_info < (3, 4)
16+
17+
# Work around mbcs bug in distutils.
18+
# http://bugs.python.org/issue10945
19+
# This work around is only if a project supports Python < 3.4
20+
21+
# Work around for locale not being set
22+
try:
23+
lc = locale.getlocale()
24+
pf = platform.system()
25+
if pf != 'Windows' and lc == (None, None):
26+
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
27+
except (ValueError, UnicodeError, locale.Error):
28+
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
29+
30+
NAME = ''
31+
AUTHOR = ''
32+
VERSION = ''
33+
EMAIL = ''
34+
LICENSE = ''
35+
DESCRIPTION = (
36+
'test'
37+
)
38+
URL = 'https://github.com//'
39+
DOWNLOAD_URL = '%s/archive/.tar.gz' % URL
40+
FILES = ['README.rst', 'CHANGELOG.rst']
41+
KEYWORDS = [
42+
'python',
43+
]
44+
45+
CLASSIFIERS = [
46+
'Topic :: Software Development :: Libraries',
47+
'Programming Language :: Python',
48+
'Intended Audience :: Developers',
49+
'Programming Language :: Python :: 2.6',
50+
'Programming Language :: Python :: 2.7',
51+
'Programming Language :: Python :: 3.3',
52+
'Programming Language :: Python :: 3.4',
53+
'Programming Language :: Python :: 3.5',
54+
'Programming Language :: Python :: 3.6',
55+
]
56+
57+
INSTALL_REQUIRES = [
58+
]
59+
SETUP_COMMANDS = {}
60+
61+
62+
PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests'])
63+
EXTRAS_REQUIRE = {}
64+
# You do not need to read beyond this line
65+
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format(
66+
sys.executable)
67+
GS_COMMAND = ('gs v ' +
68+
"Find in changelog for more details")
69+
NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
70+
'Please install gease to enable it.')
71+
UPLOAD_FAILED_MSG = (
72+
'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND)
73+
HERE = os.path.abspath(os.path.dirname(__file__))
74+
75+
76+
class PublishCommand(Command):
77+
"""Support setup.py upload."""
78+
79+
description = 'Build and publish the package on github and pypi'
80+
user_options = []
81+
82+
@staticmethod
83+
def status(s):
84+
"""Prints things in bold."""
85+
print('\033[1m{0}\033[0m'.format(s))
86+
87+
def initialize_options(self):
88+
pass
89+
90+
def finalize_options(self):
91+
pass
92+
93+
def run(self):
94+
try:
95+
self.status('Removing previous builds...')
96+
rmtree(os.path.join(HERE, 'dist'))
97+
rmtree(os.path.join(HERE, 'build'))
98+
rmtree(os.path.join(HERE, '.egg-info'))
99+
except OSError:
100+
pass
101+
102+
self.status('Building Source and Wheel (universal) distribution...')
103+
run_status = True
104+
if has_gease():
105+
run_status = os.system(GS_COMMAND) == 0
106+
else:
107+
self.status(NO_GS_MESSAGE)
108+
if run_status:
109+
if os.system(PUBLISH_COMMAND) != 0:
110+
self.status(UPLOAD_FAILED_MSG % PUBLISH_COMMAND)
111+
112+
sys.exit()
113+
114+
115+
SETUP_COMMANDS.update({
116+
'publish': PublishCommand
117+
})
118+
119+
120+
def has_gease():
121+
"""
122+
test if github release command is installed
123+
124+
visit http://github.com/moremoban/gease for more info
125+
"""
126+
try:
127+
import gease # noqa
128+
return True
129+
except ImportError:
130+
return False
131+
132+
133+
def read_files(*files):
134+
"""Read files into setup"""
135+
text = ""
136+
for single_file in files:
137+
content = read(single_file)
138+
text = text + content + "\n"
139+
return text
140+
141+
142+
def read(afile):
143+
"""Read a file into setup"""
144+
the_relative_file = os.path.join(HERE, afile)
145+
with codecs.open(the_relative_file, 'r', 'utf-8') as opened_file:
146+
content = filter_out_test_code(opened_file)
147+
content = "".join(list(content))
148+
return content
149+
150+
151+
def filter_out_test_code(file_handle):
152+
found_test_code = False
153+
for line in file_handle.readlines():
154+
if line.startswith('.. testcode:'):
155+
found_test_code = True
156+
continue
157+
if found_test_code is True:
158+
if line.startswith(' '):
159+
continue
160+
else:
161+
empty_line = line.strip()
162+
if len(empty_line) == 0:
163+
continue
164+
else:
165+
found_test_code = False
166+
yield line
167+
else:
168+
for keyword in ['|version|', '|today|']:
169+
if keyword in line:
170+
break
171+
else:
172+
yield line
173+
174+
175+
if __name__ == '__main__':
176+
setup(
177+
test_suite="tests",
178+
name=NAME,
179+
author=AUTHOR,
180+
version=VERSION,
181+
author_email=EMAIL,
182+
description=DESCRIPTION,
183+
url=URL,
184+
download_url=DOWNLOAD_URL,
185+
long_description=read_files(*FILES),
186+
license=LICENSE,
187+
keywords=KEYWORDS,
188+
extras_require=EXTRAS_REQUIRE,
189+
tests_require=['nose'],
190+
install_requires=INSTALL_REQUIRES,
191+
packages=PACKAGES,
192+
include_package_data=True,
193+
zip_safe=False,
194+
classifiers=CLASSIFIERS,
195+
cmdclass=SETUP_COMMANDS
196+
)

0 commit comments

Comments
 (0)