Skip to content

Commit 5a88b5b

Browse files
authored
Merge pull request #84 from ayan-b/sep-lint
Travis config for syncing template
2 parents c1562e0 + 5cf3ba8 commit 5a88b5b

File tree

4 files changed

+74
-52
lines changed

4 files changed

+74
-52
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ stages:
3131
python: 2.7
3232
stage: moban
3333
install: pip install moban>=0.0.4
34-
script: make
34+
script:
35+
- make
36+
- make push
3537

3638
jobs:
3739
include:
3840
- *moban
3941
- *lint
42+
allow_failures:
43+
- test
4044

4145
stage: test
4246

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ upstreaming:
44
moban -m mobanfile
55

66
lint: flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long
7+
8+
push:
9+
git config user.email "[email protected]"
10+
git config user.name "traviscibot"
11+
git add .
12+
git reset HEAD =0.0.4
13+
git commit -m "Sync templates [skip ci]"
14+
git push https://moremoban:${GITHUB_TOKEN}@github.com/moremoban/pypi-mobans HEAD:moban -f

tests/fixtures/setup.py.output

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env python3
22

33
# Template by pypi-mobans
4-
import os
5-
import sys
64
import codecs
75
import locale
6+
import os
87
import platform
8+
import sys
99
from shutil import rmtree
1010

11-
from setuptools import Command, setup, find_packages
11+
from setuptools import Command, find_packages, setup
1212

1313
PY2 = sys.version_info[0] == 2
1414
PY26 = PY2 and sys.version_info[1] < 7
@@ -22,52 +22,56 @@ PY33 = sys.version_info < (3, 4)
2222
try:
2323
lc = locale.getlocale()
2424
pf = platform.system()
25-
if pf != 'Windows' and lc == (None, None):
26-
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
25+
if pf != "Windows" and lc == (None, None):
26+
locale.setlocale(locale.LC_ALL, "C.UTF-8")
2727
except (ValueError, UnicodeError, locale.Error):
28-
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
28+
locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
2929

30-
NAME = ''
31-
AUTHOR = ''
32-
VERSION = ''
33-
EMAIL = ''
34-
LICENSE = ''
30+
NAME = "pypi-mobans"
31+
AUTHOR = "C.W."
32+
VERSION = ""
33+
34+
LICENSE = "NEW BSD"
3535
DESCRIPTION = (
36-
'test'
36+
"Scaffolding templates for your Python project."
3737
)
38-
URL = 'https://github.com//'
39-
DOWNLOAD_URL = '%s/archive/.tar.gz' % URL
40-
FILES = ['README.rst', 'CHANGELOG.rst']
38+
URL = "https://github.com/moremoban/pypi-mobans"
39+
DOWNLOAD_URL = "%s/archive/0.0.0.tar.gz" % URL
40+
FILES = ["README.rst", "CHANGELOG.rst"]
4141
KEYWORDS = [
42-
'python',
42+
"python",
4343
]
4444

4545
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',
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+
"Programming Language :: Python :: 3.7",
57+
58+
"Programming Language :: Python :: 3.8",
59+
5560
]
5661

5762
INSTALL_REQUIRES = [
5863
]
5964
SETUP_COMMANDS = {}
6065

6166

62-
PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests'])
67+
PACKAGES = find_packages(exclude=["ez_setup", "examples", "tests"])
6368
EXTRAS_REQUIRE = {}
6469
# 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.')
70+
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
71+
GS_COMMAND = ("gs pypi-mobans v0.0.0 " +
72+
"Find 0.0.0 in changelog for more details")
73+
NO_GS_MESSAGE = ("Automatic github release is disabled. " +
74+
"Please install gease to enable it.")
7175
UPLOAD_FAILED_MSG = (
7276
'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND)
7377
HERE = os.path.abspath(os.path.dirname(__file__))
@@ -76,13 +80,13 @@ HERE = os.path.abspath(os.path.dirname(__file__))
7680
class PublishCommand(Command):
7781
"""Support setup.py upload."""
7882

79-
description = 'Build and publish the package on github and pypi'
83+
description = "Build and publish the package on github and pypi"
8084
user_options = []
8185

8286
@staticmethod
8387
def status(s):
8488
"""Prints things in bold."""
85-
print('\033[1m{0}\033[0m'.format(s))
89+
print("\033[1m{0}\033[0m".format(s))
8690

8791
def initialize_options(self):
8892
pass
@@ -92,14 +96,14 @@ class PublishCommand(Command):
9296

9397
def run(self):
9498
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+
self.status("Removing previous builds...")
100+
rmtree(os.path.join(HERE, "dist"))
101+
rmtree(os.path.join(HERE, "build"))
102+
rmtree(os.path.join(HERE, "pypi_mobans.egg-info"))
99103
except OSError:
100104
pass
101105

102-
self.status('Building Source and Wheel (universal) distribution...')
106+
self.status("Building Source and Wheel (universal) distribution...")
103107
run_status = True
104108
if has_gease():
105109
run_status = os.system(GS_COMMAND) == 0
@@ -113,7 +117,7 @@ class PublishCommand(Command):
113117

114118

115119
SETUP_COMMANDS.update({
116-
'publish': PublishCommand
120+
"publish": PublishCommand
117121
})
118122

119123

@@ -142,7 +146,7 @@ def read_files(*files):
142146
def read(afile):
143147
"""Read a file into setup"""
144148
the_relative_file = os.path.join(HERE, afile)
145-
with codecs.open(the_relative_file, 'r', 'utf-8') as opened_file:
149+
with codecs.open(the_relative_file, "r", "utf-8") as opened_file:
146150
content = filter_out_test_code(opened_file)
147151
content = "".join(list(content))
148152
return content
@@ -151,11 +155,11 @@ def read(afile):
151155
def filter_out_test_code(file_handle):
152156
found_test_code = False
153157
for line in file_handle.readlines():
154-
if line.startswith('.. testcode:'):
158+
if line.startswith(".. testcode:"):
155159
found_test_code = True
156160
continue
157161
if found_test_code is True:
158-
if line.startswith(' '):
162+
if line.startswith(" "):
159163
continue
160164
else:
161165
empty_line = line.strip()
@@ -165,14 +169,14 @@ def filter_out_test_code(file_handle):
165169
found_test_code = False
166170
yield line
167171
else:
168-
for keyword in ['|version|', '|today|']:
172+
for keyword in ["|version|", "|today|"]:
169173
if keyword in line:
170174
break
171175
else:
172176
yield line
173177

174178

175-
if __name__ == '__main__':
179+
if __name__ == "__main__":
176180
setup(
177181
test_suite="tests",
178182
name=NAME,
@@ -186,7 +190,7 @@ if __name__ == '__main__':
186190
license=LICENSE,
187191
keywords=KEYWORDS,
188192
extras_require=EXTRAS_REQUIRE,
189-
tests_require=['nose'],
193+
tests_require=["nose"],
190194
install_requires=INSTALL_REQUIRES,
191195
packages=PACKAGES,
192196
include_package_data=True,

tests/test_setup.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import os
2+
3+
from ruamel.yaml import YAML
4+
15
from test_utils import get_file_content, get_rendered_file
26

37

48
def test_setup():
59
filename = 'setup.py.jj2'
6-
context = dict(
7-
description="test"
8-
)
10+
with open(os.path.join("config", "data.yml"))as f:
11+
content = f.read()
12+
yaml = YAML(typ='safe')
13+
context = yaml.load(content)
14+
print(context)
915
rendered = get_rendered_file(filename, context)
10-
expected_requirements = get_file_content('setup.py.output')
11-
assert expected_requirements == rendered
16+
expected = get_file_content('setup.py.output')
17+
assert expected == rendered

0 commit comments

Comments
 (0)