Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: setup.py

Issue 29338156: Issue 3754 - Initial setup of the python-abp repo. (Closed)
Left Patch Set: Address review comments (LICENSE.txt -> COPYING, .gitignore, encoding, license headers in empty fil… Created March 15, 2016, 11:24 a.m.
Right Patch Set: Remove pytest from qa dependencies in tox.ini, change "filterlist" to "filter list" Created March 17, 2016, 2:39 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « abp/filters/__init__.py ('k') | tests/test_line_parsing.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 Eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 """A library for working with Adblock Plus filterlists."""
Sebastian Noack 2016/03/15 12:18:07 This doc string seems to be misleading, as this fi
Vasily Kuznetsov 2016/03/15 13:14:36 It's here to be used in the long_description later
17
18 from __future__ import print_function
Sebastian Noack 2016/03/15 12:18:07 It seems you don't use any print statements in her
Vasily Kuznetsov 2016/03/15 13:14:35 Acknowledged.
19
20 import os
21 import shutil
22 import subprocess 16 import subprocess
23 from os import path 17 from os import path
24 from setuptools import setup, Command 18 from setuptools import setup, Command
25 19
26 20
27 PACKAGE = 'python-abp'
28 DEVENV = 'devenv' 21 DEVENV = 'devenv'
29 MODULE = 'abp'
30 TESTS = 'tests'
31
32 PYTHON = path.join(DEVENV, 'bin', 'python')
33 PIP = path.join(DEVENV, 'bin', 'pip') 22 PIP = path.join(DEVENV, 'bin', 'pip')
34 PYTEST = path.join(DEVENV, 'bin', 'py.test') 23 DEV_DEPENDENCIES = ['pytest', 'tox']
35 TOX = path.join(DEVENV, 'bin', 'tox')
36 FLAKE8 = path.join(DEVENV, 'bin', 'flake8')
37 AUTOPEP8 = path.join(DEVENV, 'bin', 'autopep8')
38
39 DEV_DEPENDENCIES = ['pytest', 'pytest-cov', 'tox', 'flake8', 'autopep8']
40 PYCS = sum([[path.join(dirname, fn) for fn in files if fn.endswith('.pyc')]
41 for dirname, _, files in os.walk('.')], [])
42 GARBAGE = [
43 DEVENV, '.cache', '.coverage', '.tox', 'htmlcov', 'build',
44 PACKAGE.replace('-', '_') + '.egg-info', 'dist'
45 ] + PYCS
46 24
47 25
48 def make_command(func): 26 class devenv(Command):
49 """Converting function to a command suitable for use with setup.""" 27 """Set up development virtualenv."""
50 28
51 class CmdClass(Command): 29 description = "set up development virtualenv"
30 user_options = [('python=', 'p', "the python interpreter to use")]
52 31
53 description = func.__doc__[0].lower() + func.__doc__[1:-1] 32 def initialize_options(self):
54 user_options = [] 33 self.python = 'python'
55 34
56 def initialize_options(self): 35 def finalize_options(self):
57 pass 36 pass
58 37
59 def finalize_options(self): 38 def run(self):
60 pass 39 subprocess.check_call(['virtualenv', '-p', self.python, DEVENV])
61
62 def run(self):
63 func()
64
65 return CmdClass
66
67
68 def devclean():
69 """Delete development artifacts."""
70 for item in GARBAGE:
71 if path.isdir(item):
72 shutil.rmtree(item, ignore_errors=True)
73 elif path.isfile(item):
74 os.remove(item)
75
76
77 def devenv():
78 """Create development virtualenv."""
79 if not path.isdir(DEVENV):
80 subprocess.check_call(['virtualenv', DEVENV])
81 subprocess.check_call([PIP, 'install'] + DEV_DEPENDENCIES) 40 subprocess.check_call([PIP, 'install'] + DEV_DEPENDENCIES)
82 41 subprocess.check_call([PIP, 'install', '-e', '.'])
83
84 def syntaxcheck():
85 """Find PEP8 violations and common errors with flake8."""
86 devenv()
87 subprocess.call([FLAKE8, MODULE, TESTS])
88
89
90 def diffpep8():
91 """Produce a diff of PEP8 fixes proposed by autopep8."""
92 devenv()
93 subprocess.check_call([AUTOPEP8, '--diff', '-r', '-aaa', MODULE, TESTS])
94
95
96 def test():
97 """Run tests with py.test."""
98 devenv()
99 subprocess.call([PYTEST, TESTS])
100
101
102 def testall():
103 """Run tests with all supported python versions using tox."""
104 devenv()
105 subprocess.call([TOX])
106
107
108 def testcov():
109 """Produce test coverage report."""
110 devenv()
111 subprocess.call([PYTEST, '--cov=' + MODULE, TESTS])
112
113
114 def htmlcov():
115 """Produce test coverage report in HTML."""
116 devenv()
117 subprocess.call([PYTEST, '--cov-report=html', '--cov=' + MODULE, TESTS])
118 42
119 43
120 setup( 44 setup(
121 name=PACKAGE, 45 name='python-abp',
122 version='0.0.1', 46 version='0.0.1',
123 description='ABP python tools', 47 description='ABP python tools',
124 long_description=__doc__, 48 long_description="A library for working with Adblock Plus filter lists.",
125 author='Vasily Kuznetsov', 49 author='Vasily Kuznetsov',
126 author_email='vasily@adblockplus.org', 50 author_email='vasily@adblockplus.org',
127 url='https://hg.adblockplus.org/python-abp/', 51 url='https://hg.adblockplus.org/python-abp/',
128 packages=['abp', 'abp.filters'], 52 packages=['abp', 'abp.filters'],
129 cmdclass={ 53 cmdclass={'devenv': devenv},
130 'devenv': make_command(devenv),
Sebastian Noack 2016/03/15 12:18:07 As I said before, most of the commands you added i
Vasily Kuznetsov 2016/03/15 13:14:35 Pretty much none of the commands are really specif
Sebastian Noack 2016/03/15 16:33:01 IMO, the tox script should run py.test --cov anywa
131 'devclean': make_command(devclean),
132 'diffpep8': make_command(diffpep8),
133 'syntaxcheck': make_command(syntaxcheck),
134 'test': make_command(test),
135 'testall': make_command(testall),
136 'testcov': make_command(testcov),
137 'htmlcov': make_command(htmlcov)
138 },
139 include_package_data=True, 54 include_package_data=True,
140 license='GPLv3', 55 license='GPLv3',
141 zip_safe=False, 56 zip_safe=False,
142 keywords='filterlist adblockplus ABP', 57 keywords='filterlist adblockplus ABP',
143 classifiers=[ 58 classifiers=[
144 'Development Status :: 2 - Pre-Alpha', 59 'Development Status :: 2 - Pre-Alpha',
145 'Intended Audience :: Developers', 60 'Intended Audience :: Developers',
146 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 61 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
147 'Natural Language :: English', 62 'Natural Language :: English',
148 'Programming Language :: Python :: 2', 63 'Programming Language :: Python :: 2',
149 'Programming Language :: Python :: 2.7', 64 'Programming Language :: Python :: 2.7',
150 'Programming Language :: Python :: 3', 65 'Programming Language :: Python :: 3',
151 'Programming Language :: Python :: 3.3',
Sebastian Noack 2016/03/15 12:18:07 If you list Python 3.3 and 3.4 you might want to a
Vasily Kuznetsov 2016/03/15 13:14:35 Good point. I'd actually rather remove them from h
Sebastian Noack 2016/03/15 16:33:00 So far we didn't care about supporting outdated Py
152 'Programming Language :: Python :: 3.4',
153 'Programming Language :: Python :: 3.5', 66 'Programming Language :: Python :: 3.5',
154 ] 67 ]
155 ) 68 )
LEFTRIGHT

Powered by Google App Engine
This is Rietveld