Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # This file is part of Adblock Plus <https://adblockplus.org/>, | |
2 # Copyright (C) 2006-2016 Eyeo GmbH | |
3 # | |
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 | |
6 # published by the Free Software Foundation. | |
7 # | |
8 # Adblock Plus is distributed in the hope that it will be useful, | |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 # GNU General Public License for more details. | |
12 # | |
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/>. | |
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 | |
23 from os import path | |
24 from setuptools import setup, Command | |
25 | |
26 | |
27 PACKAGE = 'python-abp' | |
28 DEVENV = 'devenv' | |
29 MODULE = 'abp' | |
30 TESTS = 'tests' | |
31 | |
32 PYTHON = path.join(DEVENV, 'bin', 'python') | |
33 PIP = path.join(DEVENV, 'bin', 'pip') | |
34 PYTEST = path.join(DEVENV, 'bin', 'py.test') | |
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 | |
47 | |
48 def make_command(func): | |
49 """Converting function to a command suitable for use with setup.""" | |
50 | |
51 class CmdClass(Command): | |
52 | |
53 description = func.__doc__[0].lower() + func.__doc__[1:-1] | |
54 user_options = [] | |
55 | |
56 def initialize_options(self): | |
57 pass | |
58 | |
59 def finalize_options(self): | |
60 pass | |
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) | |
82 | |
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 | |
119 | |
120 setup( | |
121 name=PACKAGE, | |
122 version='0.0.1', | |
123 description='ABP python tools', | |
124 long_description=__doc__, | |
125 author='Vasily Kuznetsov', | |
126 author_email='vasily@adblockplus.org', | |
127 url='https://hg.adblockplus.org/python-abp/', | |
128 packages=['abp', 'abp.filters'], | |
129 cmdclass={ | |
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, | |
140 license='GPLv3', | |
141 zip_safe=False, | |
142 keywords='filterlist adblockplus ABP', | |
143 classifiers=[ | |
144 'Development Status :: 2 - Pre-Alpha', | |
145 'Intended Audience :: Developers', | |
146 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', | |
147 'Natural Language :: English', | |
148 'Programming Language :: Python :: 2', | |
149 'Programming Language :: Python :: 2.7', | |
150 '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', | |
154 ] | |
155 ) | |
OLD | NEW |