summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorMichael Weiser <michael.weiser@gmx.de>2019-05-14 11:46:33 +0000
committerMichael Weiser <michael.weiser@gmx.de>2019-05-21 13:59:50 +0000
commit1a5ff8dfdb0561382a736aa524b73e2f671f32f7 (patch)
tree72cb6774b1c9deb8cfb1b709642165b039e2900f /setup.py
parent8bc271b6354b837ff2e83349a4b4e3e1a01f08db (diff)
Distribute sample configuration files
Add ruleset.conf.sample to the distribution and configure setuptools to install it together with the README, peekaboo.conf.sample and our systemd unit into an fhs-like documentation directory. Add a number of comments to setup.py so we remember why this seems to be the least disruptive way out of the limited options presented by the python/setuptools/distutils/pip mechanics of providing these files at a location visible to users and still somewhat manageable by alternative packagers (e.g. Linux distributions). In short again: - package_data would hide the files away below the site-packages directory making them invisible to the user and hard(er) to find programmatically - absolute paths really don't work well with data_files - relative paths work somewhat better but still not fully consistently between setup.py and pip - overriding the install command solves the installation but not the packaging problem
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py46
1 files changed, 44 insertions, 2 deletions
diff --git a/setup.py b/setup.py
index 6413708..256a2e3 100755
--- a/setup.py
+++ b/setup.py
@@ -25,10 +25,10 @@
###############################################################################
-from setuptools import setup, find_packages
from codecs import open
-from os import path, system
+from os import path
from sys import path as pythonpath
+from setuptools import setup, find_packages
# Add peekaboo to PYTHONPATH
pythonpath.append(path.dirname(path.dirname(path.abspath(__file__))))
@@ -70,6 +70,48 @@ setup(
keywords='Cuckoo, Amavis',
packages=find_packages(exclude=['docs', 'tests*']),
include_package_data=True,
+ # package_files augments MANIFEST.in in what is packaged into a
+ # distribution. Files to add must be inside a package. Thus files in the
+ # root of our source directory cannot be packaged with this. Files inside
+ # packages will stay there, totally obscured to the user. Meant for default
+ # configuration or other package-internal data.
+ # package_files=[...],
+ #
+ # data_files is another way to augment what is installed from the
+ # distribution. Allows paths outside packages for both sources and targets.
+ # Absolute paths are strongly discouraged because they exhibit confusing if
+ # not downright broken behaviour. Relative paths are added to the
+ # distribution and then installed into
+ # site-packages/<package>-<ver>.egg/<relative path> (setup.py) or <python
+ # prefix>/<relative path> (pip). The latter works well with venvs and
+ # distribution-provided pip (e.g. /usr/local/<relative path>).
+ # We go this route for providing sample files because using setup.py
+ # directly is discouraged anyway and "only" tucks the files away in the egg
+ # directory, providing the most consistent option.
+ data_files=[
+ ("share/doc/peekaboo", [
+ "README.md",
+ "CHANGELOG.md",
+ "peekaboo.conf.sample",
+ "ruleset.conf.sample",
+ ]),
+ ("share/doc/peekaboo/systemd", [
+ "systemd/peekaboo.service",
+ ]),
+ ("share/doc/peekaboo/amavis", [
+ "amavis/10-ask_peekaboo",
+ ]),
+ ],
+ # overriding the whole install_data command allows for arbitrary
+ # installation mechanics but does not solve the problem of adding files to
+ # a binary distribution (e.g. wheel, which pip uses internally always) in
+ # such a way that they will later be put at the correct location. Thus they
+ # would go around pip entirely, be missing from any actual wheel
+ # distribution package, pollute the system directly and not be removed upon
+ # uninstall or upgrade.
+ # cmdclass={
+ # 'install_data': OffsetDataInstall,
+ # },
author=__author__,
install_requires=install_requires,
dependency_links=dependency_links,