From bb424d349bc66a37f15f0c100a01af5d0d27ed6b Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 19 Jan 2016 15:59:50 +0100 Subject: [PATCH] Generate configuration file in sdist When building source tarball, generate the configuration file to include it in the sources. Change-Id: I81f4669bdf6a4fe51c247b129a1e69c13a657131 --- MANIFEST.in | 1 + doc/source/configuration.rst | 18 +++------------- ...ator.conf => gnocchi-config-generator.conf | 0 gnocchi/genconfig.py | 21 +++++++++++++++++++ setup.cfg | 5 +++++ tox.ini | 4 ++-- 6 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 MANIFEST.in rename etc/gnocchi/gnocchi-config-generator.conf => gnocchi-config-generator.conf (100%) create mode 100644 gnocchi/genconfig.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..8f248e6e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include etc/gnocchi/gnocchi.conf diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 9c8c08e5..debf5e26 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -2,21 +2,9 @@ Configuration =============== -Configure Gnocchi by editing `/etc/gnocchi/gnocchi.conf`. - -No config file is provided with the source code, but one can be easily -created by running: - -:: - - tox -e genconfig - -This command will create an `etc/gnocchi/gnocchi.conf` file which can be used -as a base for the default configuration file at `/etc/gnocchi/gnocchi.conf`. If -you're using *devstack*, this file is already generated and put in place. - -The configuration file should be pretty explicit, but here are some of the base -options you want to change and configure: +Configure Gnocchi by editing `/etc/gnocchi/gnocchi.conf`. The configuration +file should be pretty explicit, but here are some of the base options you want +to change and configure: +---------------------+---------------------------------------------------+ diff --git a/etc/gnocchi/gnocchi-config-generator.conf b/gnocchi-config-generator.conf similarity index 100% rename from etc/gnocchi/gnocchi-config-generator.conf rename to gnocchi-config-generator.conf diff --git a/gnocchi/genconfig.py b/gnocchi/genconfig.py new file mode 100644 index 00000000..cb08b7c3 --- /dev/null +++ b/gnocchi/genconfig.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +# +# Copyright © 2016 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +from oslo_config import generator + + +def sdist_prehook(sdist): + generator.main(['--config-file', + 'gnocchi-config-generator.conf']) diff --git a/setup.cfg b/setup.cfg index 94e43429..5b5dcc15 100644 --- a/setup.cfg +++ b/setup.cfg @@ -73,9 +73,14 @@ test = setup-hooks = pbr.hooks.setup_hook +[sdist] +pre-hook.build_config = gnocchi.genconfig.sdist_prehook + [files] packages = gnocchi +data_files = + etc/gnocchi = etc/gnocchi/* [entry_points] gnocchi.indexer.resources = diff --git a/tox.ini b/tox.ini index 66ec7e5e..def7eb2b 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ setenv = commands = doc8 --ignore-path doc/source/rest.rst doc/source - oslo-config-generator --config-file=etc/gnocchi/gnocchi-config-generator.conf + oslo-config-generator --config-file=gnocchi-config-generator.conf {toxinidir}/run-tests.sh {posargs} [testenv:bashate] @@ -64,7 +64,7 @@ show-source = true [testenv:genconfig] deps = .[mysql,postgresql,test,file,influxdb,ceph,swift] -commands = oslo-config-generator --config-file=etc/gnocchi/gnocchi-config-generator.conf +commands = oslo-config-generator --config-file=gnocchi-config-generator.conf [testenv:docs] # This does not work, see: https://bitbucket.org/hpk42/tox/issues/302