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

Unified Diff: setup.py

Issue 29338156: Issue 3754 - Initial setup of the python-abp repo. (Closed)
Patch Set: Address review comments (LICENSE.txt -> COPYING, .gitignore, encoding, license headers in empty fil… Created March 15, 2016, 11:24 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: setup.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,155 @@
+# This file is part of Adblock Plus <https://adblockplus.org/>,
+# Copyright (C) 2006-2016 Eyeo GmbH
+#
+# Adblock Plus is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# Adblock Plus is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+
+"""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
+
+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.
+
+import os
+import shutil
+import subprocess
+from os import path
+from setuptools import setup, Command
+
+
+PACKAGE = 'python-abp'
+DEVENV = 'devenv'
+MODULE = 'abp'
+TESTS = 'tests'
+
+PYTHON = path.join(DEVENV, 'bin', 'python')
+PIP = path.join(DEVENV, 'bin', 'pip')
+PYTEST = path.join(DEVENV, 'bin', 'py.test')
+TOX = path.join(DEVENV, 'bin', 'tox')
+FLAKE8 = path.join(DEVENV, 'bin', 'flake8')
+AUTOPEP8 = path.join(DEVENV, 'bin', 'autopep8')
+
+DEV_DEPENDENCIES = ['pytest', 'pytest-cov', 'tox', 'flake8', 'autopep8']
+PYCS = sum([[path.join(dirname, fn) for fn in files if fn.endswith('.pyc')]
+ for dirname, _, files in os.walk('.')], [])
+GARBAGE = [
+ DEVENV, '.cache', '.coverage', '.tox', 'htmlcov', 'build',
+ PACKAGE.replace('-', '_') + '.egg-info', 'dist'
+] + PYCS
+
+
+def make_command(func):
+ """Converting function to a command suitable for use with setup."""
+
+ class CmdClass(Command):
+
+ description = func.__doc__[0].lower() + func.__doc__[1:-1]
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ func()
+
+ return CmdClass
+
+
+def devclean():
+ """Delete development artifacts."""
+ for item in GARBAGE:
+ if path.isdir(item):
+ shutil.rmtree(item, ignore_errors=True)
+ elif path.isfile(item):
+ os.remove(item)
+
+
+def devenv():
+ """Create development virtualenv."""
+ if not path.isdir(DEVENV):
+ subprocess.check_call(['virtualenv', DEVENV])
+ subprocess.check_call([PIP, 'install'] + DEV_DEPENDENCIES)
+
+
+def syntaxcheck():
+ """Find PEP8 violations and common errors with flake8."""
+ devenv()
+ subprocess.call([FLAKE8, MODULE, TESTS])
+
+
+def diffpep8():
+ """Produce a diff of PEP8 fixes proposed by autopep8."""
+ devenv()
+ subprocess.check_call([AUTOPEP8, '--diff', '-r', '-aaa', MODULE, TESTS])
+
+
+def test():
+ """Run tests with py.test."""
+ devenv()
+ subprocess.call([PYTEST, TESTS])
+
+
+def testall():
+ """Run tests with all supported python versions using tox."""
+ devenv()
+ subprocess.call([TOX])
+
+
+def testcov():
+ """Produce test coverage report."""
+ devenv()
+ subprocess.call([PYTEST, '--cov=' + MODULE, TESTS])
+
+
+def htmlcov():
+ """Produce test coverage report in HTML."""
+ devenv()
+ subprocess.call([PYTEST, '--cov-report=html', '--cov=' + MODULE, TESTS])
+
+
+setup(
+ name=PACKAGE,
+ version='0.0.1',
+ description='ABP python tools',
+ long_description=__doc__,
+ author='Vasily Kuznetsov',
+ author_email='vasily@adblockplus.org',
+ url='https://hg.adblockplus.org/python-abp/',
+ packages=['abp', 'abp.filters'],
+ cmdclass={
+ '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
+ 'devclean': make_command(devclean),
+ 'diffpep8': make_command(diffpep8),
+ 'syntaxcheck': make_command(syntaxcheck),
+ 'test': make_command(test),
+ 'testall': make_command(testall),
+ 'testcov': make_command(testcov),
+ 'htmlcov': make_command(htmlcov)
+ },
+ include_package_data=True,
+ license='GPLv3',
+ zip_safe=False,
+ keywords='filterlist adblockplus ABP',
+ classifiers=[
+ 'Development Status :: 2 - Pre-Alpha',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
+ 'Natural Language :: English',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ '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
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ ]
+)
« abp/__init__.py ('K') | « abp/filters/__init__.py ('k') | tests/test_line_parsing.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld