aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Spranger <b.spranger@linutronix.de>2020-05-15 15:48:33 +0200
committerThomas Gleixner <tglx@linutronix.de>2020-10-01 15:27:29 +0200
commit3b278ecb68344d4371a2010443ad025551278cf3 (patch)
tree50f73bb51ff820e1fb88ba84ecbcfbf36e01b105
parent25edbe0d11ef97db05ff1df910ee28e5a8fb22bd (diff)
downloadquilttools-3b278ecb68344d4371a2010443ad025551278cf3.tar.gz
quilttools: Add Python setup support
The Python ecosystem provides mechanism to maintain proper information for installation and packaging. Provide these informations. Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--.gitignore5
-rw-r--r--MANIFEST.in5
-rw-r--r--setup.py93
3 files changed, 103 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 855ae2b..6325123 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,8 @@ series
# Sphinx
Documentation/output/
+
+# Setup odds and ends
+*.egg-info/
+build/
+dist/
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..8a935b2
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,5 @@
+include COPYING Documentation/conf.py
+recursive-include . *.rst
+recursive-include . *.txt
+recursive-include Documentation/ *.yaml
+recursive-include LICENSES/ * \ No newline at end of file
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..9450c1a
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,93 @@
+# SPDX-License-Identifier: GPL2.0
+# Copyright Benedikt Spranger <b.spranger@linutronix.de>
+
+"""
+quilttools: package information and setup
+"""
+
+from distutils.command.build import build
+from re import sub
+from time import time
+from setuptools import setup, find_packages
+
+from git import InvalidGitRepositoryError, Repo
+from sphinx.setup_command import BuildDoc
+
+from quilttoolsversion import QUILTTOOLSVERSION as version
+
+NAME = 'quilttools'
+
+CMDCLASS = {'build_sphinx': BuildDoc}
+
+try:
+ repo = Repo()
+ assert not repo.bare
+ gitversion = repo.git.describe('--tags', '--dirty', '--broken')
+ gitversion = sub(r'^\D*', '', gitversion, count=1)
+except InvalidGitRepositoryError:
+ gitversion = ''
+
+if gitversion.__contains__('-'):
+ version = gitversion.split('-')[0]
+ release = version + '.dev%d'%time()
+else:
+ release = version
+
+print("Package Information:")
+print("name : %s"%NAME)
+print("version: %s"%version)
+print("release: %s"%release)
+print("git : %s"%gitversion)
+
+with open("README.md", "r") as fh:
+ long_description = fh.read()
+
+class BuildExtras(build):
+ """ Override distutil build command to build man pages """
+ def run(self):
+ super().run()
+ cmd_obj = self.distribution.get_command_obj('build_sphinx')
+ cmd_obj.builder = "man"
+ self.run_command('build_sphinx')
+
+CMDCLASS = {'build': BuildExtras, 'build_sphinx': BuildDoc}
+DATA_FILES = [("share/doc/" + NAME + "/examples",
+ ["Documentation/examples/.mb2q.yaml"]),
+ ("share/man/man1/", ["build/sphinx/man/mb2q.1"])]
+PACKAGE_DATA = {"": ["*.rst", "*.txt", "LICENSES/*", "Documentation/conf.py"]}
+
+setup(
+ name=NAME,
+ version=release,
+ author="Thomas Gleixner",
+ author_email="tglx@linutronix.de",
+ license="GPL2.0",
+ description="A small but powerful collection of quilt helper tools",
+ long_description=long_description,
+ long_description_content_type="text/markdown",
+ url="https://git.kernel.org/pub/scm/linux/kernel/git/tglx/quilttools.git",
+ packages=find_packages(),
+ package_data=PACKAGE_DATA,
+ data_files=DATA_FILES,
+ classifiers=[
+ "Development Status :: 5 - Production/Stable",
+ "Environment :: Console",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: GNU General Public License v2 (GPLv2)"
+ "Operating System :: OS Independent",
+ "Programming Language :: Python :: 3",
+ "Topic :: Communications :: Email :: Filters",
+ "Topic :: Software Development",
+ ],
+ platforms=['any'],
+ python_requires='>=3.6',
+ scripts=['mb2q'],
+ install_requires=['pyyaml', 'notmutch'],
+ cmdclass=CMDCLASS,
+ command_options={
+ 'build_sphinx': {
+ 'project': ('setup.py', NAME),
+ 'version': ('setup.py', version),
+ 'release': ('setup.py', release),
+ 'source_dir': ('setup.py', 'Documentation')}},
+)