From a2dffdb8e49e666a2284f8010661766325d1e050 Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Sun, 9 Dec 2018 15:48:12 +0100 Subject: [PATCH 1/3] Add extras for optional requirements --- AUTHORS | 3 ++- README.rst | 6 ++++++ setup.py | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 108baa8..9661ac9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3,4 +3,5 @@ Gilles Fabio Jannis Leidel Marc Abramowitz Michael van Tellingen -Mike Fogel \ No newline at end of file +Mike Fogel +Peter Bittner diff --git a/README.rst b/README.rst index c80f72c..faf46ed 100644 --- a/README.rst +++ b/README.rst @@ -32,6 +32,12 @@ Install django-configurations: pip install django-configurations +or, alternatively, if you want to use URL-based values: + +.. code-block:: console + + pip install django-configurations[cache,database,email,search] + Then subclass the included ``configurations.Configuration`` class in your project's **settings.py** or any other module you're using to store the settings constants, e.g.: diff --git a/setup.py b/setup.py index 06fd946..62ded85 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,12 @@ setup( 'django-cadmin = configurations.management:execute_from_command_line', ], }, + extras_require={ + 'cache': ['django-cache-url'], + 'database': ['dj-database-url'], + 'email': ['dj-email-url'], + 'search': ['dj-search-url'], + }, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Framework :: Django', From 0e45c7b3e4ec2f20e26d0ff71eb7f9c487922182 Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Sun, 9 Dec 2018 15:52:05 +0100 Subject: [PATCH 2/3] Also move testing requirements into packaging setup --- setup.py | 13 +++++++++++-- tests/requirements.txt | 8 -------- tox.ini | 13 ++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 tests/requirements.txt diff --git a/setup.py b/setup.py index 62ded85..7a2efdf 100644 --- a/setup.py +++ b/setup.py @@ -46,6 +46,16 @@ setup( 'database': ['dj-database-url'], 'email': ['dj-email-url'], 'search': ['dj-search-url'], + 'testing': [ + 'django-discover-runner', + 'mock', + 'django-cache-url>=1.0.0', + 'dj-database-url', + 'dj-email-url', + 'dj-search-url', + 'six', + 'Sphinx>=1.4', + ], }, classifiers=[ 'Development Status :: 5 - Production/Stable', @@ -55,10 +65,9 @@ setup( 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: Utilities', ], zip_safe=False, diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index f62636b..0000000 --- a/tests/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -django-discover-runner -mock -dj-database-url -dj-email-url -dj-search-url -django-cache-url>=1.0.0 -six -Sphinx>=1.4 diff --git a/tox.ini b/tox.ini index cca6f96..5f3454b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] -skipsdist = True -usedevelop = True +skipsdist = true +usedevelop = true minversion = 1.8 -whitelist_externals=sphinx-build +whitelist_externals = sphinx-build envlist = flake8-py27, flake8-py36, @@ -19,7 +19,6 @@ setenv = coverage: COVERAGE_PROCESS_START = {toxinidir}/setup.cfg coverage: _TEST_RUN_PREFIX=coverage run deps = - -rtests/requirements.txt dj18: django>=1.8,<1.9 dj110: django>=1.10,<1.11 dj111: django>=1.11,<2.0 @@ -29,7 +28,7 @@ deps = py27,pypy: mock coverage: coverage coverage: coverage_enable_subprocess - +extras = testing commands = python --version {env:_TEST_RUN_PREFIX:} {envbindir}/django-cadmin test -v2 {posargs:tests} @@ -49,5 +48,5 @@ commands = flake8 configurations tests deps = flake8 [flake8] -exclude=.tox -ignore=E501,E127,E128,E124 +exclude = .tox +ignore = E501,E127,E128,E124 From 06f2d57386da4b58a0510f0d3e401ce738f866eb Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Sun, 9 Dec 2018 15:52:53 +0100 Subject: [PATCH 3/3] Fix flake8 complaints --- configurations/importer.py | 4 ++-- configurations/values.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configurations/importer.py b/configurations/importer.py index f9dfd6c..e43f2b8 100644 --- a/configurations/importer.py +++ b/configurations/importer.py @@ -124,8 +124,8 @@ class ConfigurationImporter(object): def stylize(text): return colorize(text, fg='green') - if (self.argv[1] == 'runserver' and - os.environ.get('RUN_MAIN') == 'true'): + if self.argv[1] == 'runserver' \ + and os.environ.get('RUN_MAIN') == 'true': message = ("django-configurations version {0}, using " "configuration '{1}'".format(__version__, diff --git a/configurations/values.py b/configurations/values.py index 056e9a0..af53b62 100644 --- a/configurations/values.py +++ b/configurations/values.py @@ -52,8 +52,8 @@ class Value(object): instance.late_binding = kwargs.get('late_binding') if not instance.late_binding: instance.__init__(*args, **kwargs) - if ((instance.environ and instance.environ_name) or - (not instance.environ and instance.default)): + if (instance.environ and instance.environ_name) \ + or (not instance.environ and instance.default): instance = instance.setup(instance.environ_name) return instance