summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck16
-rw-r--r--pgpwordlist/__init__.py2
-rw-r--r--pgpwordlist/version.py2
-rw-r--r--pylint.conf37
-rwxr-xr-xsetup.py159
-rw-r--r--without-tests2
6 files changed, 217 insertions, 1 deletions
diff --git a/check b/check
index c6dd0cf..93b0044 100755
--- a/check
+++ b/check
@@ -1,4 +1,20 @@
#!/bin/sh
+# Copyright 2016 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
set -eu
diff --git a/pgpwordlist/__init__.py b/pgpwordlist/__init__.py
index ceb321c..495f736 100644
--- a/pgpwordlist/__init__.py
+++ b/pgpwordlist/__init__.py
@@ -16,6 +16,6 @@
# =*= License: GPL-3+ =*=
+from .version import __version__, __version_info__
from .wordlist import pgp_word_list
from .funcs import get_word, get_hex, hex_to_words, words_to_hex
-
diff --git a/pgpwordlist/version.py b/pgpwordlist/version.py
new file mode 100644
index 0000000..9e74f14
--- /dev/null
+++ b/pgpwordlist/version.py
@@ -0,0 +1,2 @@
+__version__ = '0.0'
+__version_info__ = (0, 0)
diff --git a/pylint.conf b/pylint.conf
new file mode 100644
index 0000000..146a84e
--- /dev/null
+++ b/pylint.conf
@@ -0,0 +1,37 @@
+[MASTER]
+persistent=no
+
+[MESSAGES CONTROL]
+disable=
+ abstract-class-little-used,
+ abstract-class-not-used,
+ attribute-defined-outside-init,
+ cyclic-import,
+ fixme,
+ global-statement,
+ interface-not-implemented,
+ invalid-name,
+ locally-disabled,
+ missing-docstring,
+ no-self-use,
+ protected-access,
+ redefined-variable-type,
+ star-args,
+ too-few-public-methods,
+ too-many-arguments,
+ too-many-branches,
+ too-many-instance-attributes,
+ too-many-lines,
+ too-many-locals,
+ too-many-public-methods,
+ too-many-statements,
+ unidiomatic-typecheck,
+ unsubscriptable-object,
+ unsupported-membership-test,
+ unused-argument
+
+[REPORTS]
+reports=no
+
+[SIMILARITIES]
+min-similarity-lines=999
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..c7c96b5
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,159 @@
+#!/usr/bin/env python
+# Copyright 2016 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+from distutils.core import setup, Extension
+from distutils.cmd import Command
+from distutils.command.build import build
+from distutils.command.clean import clean
+import glob
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+
+import cliapp
+
+import pgpwordlist
+
+
+class Check(Command):
+
+ user_options = [
+ ('unit-tests', 'u', 'run unit tests?'),
+ ('nitpick', 'n', 'check copyright statements, line lengths, etc'),
+ ]
+
+ def set_all_options(self, new_value):
+ self.unit_tests = new_value
+ self.nitpick = new_value
+
+ def initialize_options(self):
+ self.set_all_options(False)
+
+ def finalize_options(self):
+ any_set = (
+ self.unit_tests or
+ self.nitpick)
+ if not any_set:
+ self.set_all_options(True)
+
+ def run(self):
+ if self.unit_tests:
+ self.run_unit_tests()
+
+ if self.nitpick:
+ self.run_nitpick_checks()
+
+ print "setup.py check done"
+
+ def run_unit_tests(self):
+ print "run unit tests"
+ cliapp.runcmd(['python', '-m', 'CoverageTestRunner',
+ '--ignore-missing-from=without-tests'])
+ if os.path.exists('.coverage'):
+ os.remove('.coverage')
+
+ def run_nitpick_checks(self):
+ self.check_with_pep8()
+ self.check_with_pylint()
+ if os.path.exists('.git'):
+ sources = self.find_all_source_files()
+ self.check_copyright_statements(sources)
+ else:
+ print "no .git, no nitpick for you"
+
+ def check_with_pep8(self):
+ output = cliapp.runcmd(['pep8', '--version'])
+ parts = output.strip().split('.')
+ # pep8 version 1.5.7 is in Debian jessie. Previous versions
+ # give bad warnings about whitespace around some operators,
+ # and later versions don't. So we only run pep8 if it's new
+ # enough.
+ if parts >= ['1', '5', '7']:
+ print 'running pep8'
+ cliapp.runcmd(['pep8', 'pgpwordlist'], stdout=None, stderr=None)
+ else:
+ print 'not running pep8'
+
+ def check_with_pylint(self):
+ output = cliapp.runcmd(['pylint', '--version'])
+ parts = output.splitlines()[0].split('.')
+ # pylint version 1.3.1 is in Debian jessie. Previous versions
+ # do not know all the things in the pylint.conf file we use,
+ # so we only run pylint if it's new enough.
+ if parts >= ['pylint 1', '3', '1,']:
+ print 'running pylint'
+ cliapp.runcmd(
+ ['pylint', '--rcfile=pylint.conf', 'obnamlib'],
+ stdout=None, stderr=None)
+ else:
+ print 'not running pylint', parts
+
+ def check_copyright_statements(self, sources):
+ if self.copylint_is_available():
+ print 'check copyright statements in source files'
+ cliapp.runcmd(['copyright-statement-lint'] + sources)
+ else:
+ print 'no copyright-statement-lint: no copyright checks'
+
+ def copylint_is_available(self):
+ returncode, stdout, stderr = cliapp.runcmd_unchecked(
+ ['sh', '-c', 'command -v copyright-statement-lint'])
+ return returncode == 0
+
+ def find_all_source_files(self):
+ exclude = [
+ r'^debian/',
+ r'^README\.',
+ r'^NEWS$',
+ r'^COPYING$',
+ r'^without-tests$',
+ r'^pgpwordlist/wordlist\.py$',
+ r'^pgpwordlist/version\.py$',
+ ]
+
+ pats = [re.compile(x) for x in exclude]
+
+ output = cliapp.runcmd(['git', 'ls-files'])
+ result = []
+ for line in output.splitlines():
+ for pat in pats:
+ if pat.search(line):
+ break
+ else:
+ result.append(line)
+ return result
+
+
+setup(
+ name='py_pgpwordlist',
+ version=pgpwordlist.__version__,
+ description='Convert hex strings to words from PGP word list, and back',
+ author='Lars Wirzenius',
+ author_email='liw@liw.fi',
+ url='http://liw.fi/py_pgpwordlist/',
+ packages=[
+ 'pgpwordlist',
+ ],
+ cmdclass={
+ 'check': Check,
+ },
+)
diff --git a/without-tests b/without-tests
index e122dc0..00cf132 100644
--- a/without-tests
+++ b/without-tests
@@ -1,2 +1,4 @@
+setup.py
pgpwordlist/__init__.py
pgpwordlist/wordlist.py
+pgpwordlist/version.py