{ "info": { "author": "Depop", "author_email": "dev@depop.com", "bugtrack_url": null, "classifiers": [ "Environment :: Plugins", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6" ], "description": "flexisettings\n=============\n\n|PyPI Version| |Build Status|\n\n.. |PyPI Version| image:: http://img.shields.io/pypi/v/flexisettings.svg?style=flat\n :target: https://pypi.python.org/pypi/flexisettings/\n :alt: Latest PyPI version\n\n.. |Build Status| image:: https://circleci.com/gh/depop/python-flexisettings.svg?style=shield&circle-token=ae7b355ec3b18c69d3370898a69932091c43d152\n :alt: Build Status\n\nPartly inspired by Django's ``from django.conf import settings`` settings object.\n\nThe goal is to allow shared libraries to be configured by a settings file in\nthe project which imports them (like how Django libraries can expect the Django\n``settings`` object to exist).\n\nUsage\n-----\n\n.. code:: bash\n\n pip install flexisettings\n\nWe want the shared lib to be able to load config values *from the app which is*\n*importing it*.\n\nA suggested layout would be as found in ``test_project/test_lib`` in this repo.\nFor example, create a ``test_lib/conf/__init__.py`` like:\n\n.. code:: python\n\n\tfrom flexisettings import Settings\n\n\tsettings = Settings(initial_namespace='TEST_LIB', defaults='test_lib.conf.defaults')\n\nWe have a concept of customisable 'namespace' (prefix) for config values. This\nis as defined by the `ConfigLoader `_\nlib we are making use of.\n\n``initial_namespace`` is the default namespace for config values of your shared\nlib. Projects who want to use your lib will be able to customise the namespace,\nbut as they are used for bootstrapping there are two config values which will\n*always* use the default name (``APP_CONFIG`` and ``CONFIG_NAMESPACE``).\n\nSo for example, say ``myapp`` wants to use ``test_lib``. ``myapp`` can\ncustomise the namespace by defining ``TEST_LIB_CONFIG_NAMESPACE = 'CUSTOM'``.\n\n``defaults`` is the import path to a python module or object *in your shared lib*\nwhich contains default values for your config. These keys should *not* be\nnamespaced.\n\nFor example if you want the config namespace for your shared lib to be\nconfigurable via env var you could create ``test_lib/conf/defaults.py`` like:\n\n.. code:: python\n\n\timport os\n\n\t# namespace for config keys loaded from e.g. Django conf or env vars\n\tCONFIG_NAMESPACE = os.getenv('TEST_LIB_CONFIG_NAMESPACE', 'TEST_LIB')\n\n\tAPP_CONFIG = os.getenv('TEST_LIB_APP_CONFIG', None)\n\nThen ``myapp`` would be able to ``export TEST_LIB_CONFIG_NAMESPACE=CUSTOM``.\n\nThat explains namespace customisation a bit, what about the ``APP_CONFIG``?\n\nSay for example that ``myapp`` is a Django website and ``test_lib`` has the\ndefaults file shown above. In your ``myapp`` project you could:\n\n.. code:: bash\n\n\texport TEST_LIB_CONFIG_NAMESPACE=CUSTOM\n\texport TEST_LIB_APP_CONFIG=django.conf.settings\n\nThen in ``myapp/settings.py`` you could have:\n\n.. code:: python\n\n\tCUSTOM_VAR1 = 'whatever'\n\nNow, recall the ``test_lib/conf/__init__.py`` that we created at the start. In\nyour ``test_lib`` code you could have:\n\n.. code:: python\n\n\tfrom test_lib.conf import settings\n\n\tassert settings.VAR1 == 'whatever'\n\nAs you can see the ``VAR1`` was set in the importing project's Django settings\nwith the ``CUSTOM_`` prefix but is available in your shared lib's ``settings``\nobject under its non-prefixed name.\n\nCompatibility\n-------------\n\nThis project is tested against:\n\n=========== ===\nPython 2.7 * \nPython 3.6 * \n=========== ===\n\nRunning the tests\n-----------------\n\nCircleCI\n~~~~~~~~\n\n| The easiest way to test the full version matrix is to install the\n CircleCI command line app:\n| https://circleci.com/docs/2.0/local-jobs/\n| (requires Docker)\n\nThe cli does not support 'workflows' at the moment so you have to run\nthe two Python version jobs separately:\n\n.. code:: bash\n\n circleci build --job python-2.7\n\n.. code:: bash\n\n circleci build --job python-3.6\n\npy.test (single python version)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIt's also possible to run the tests locally, allowing for debugging of\nerrors that occur.\n\nNow decide which Python version you want to test and create a virtualenv:\n\n.. code:: bash\n\n pyenv virtualenv 3.6.4 flexisettings\n pip install -r requirements-test.txt\n\nThe code in ``test_project`` demonstrates collaborative config between a shared\nlibrary ``test_lib`` and the app that wants to use it ``app``. Set the path to\nthe test project\n\n.. code:: bash\n\n make test", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/depop/python-flexisettings", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "flexisettings", "package_url": "https://pypi.org/project/flexisettings/", "platform": "", "project_url": "https://pypi.org/project/flexisettings/", "project_urls": { "Homepage": "https://github.com/depop/python-flexisettings" }, "release_url": "https://pypi.org/project/flexisettings/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "Overridable config for shared libraries.", "version": "1.0.3" }, "last_serial": 3929225, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "7b4cd35877dff96abb1696e12cadc310", "sha256": "8423b707ec2f910767c1ccfbe0cdbf94dac3e4789bf785307b53a86bd4d8aee1" }, "downloads": -1, "filename": "flexisettings-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7b4cd35877dff96abb1696e12cadc310", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4863, "upload_time": "2017-11-03T10:25:08", "url": "https://files.pythonhosted.org/packages/b9/dd/f979e785d0eb84e4c86154d0e36d488e3e1249c2f749cb6aa0a8e8404b2d/flexisettings-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "278a98ec2427af5a57cd4a89fa888f61", "sha256": "7a2fd8efd356aa6458a37f72f2f642ed81786a5201d644c8ef308ec1a4c057b9" }, "downloads": -1, "filename": "flexisettings-1.0.1.tar.gz", "has_sig": false, "md5_digest": "278a98ec2427af5a57cd4a89fa888f61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4979, "upload_time": "2018-02-19T16:07:59", "url": "https://files.pythonhosted.org/packages/01/75/9b9ad5cf90b1aa25f387144ace0e70dbb6058134cb60a3037dc76b53487f/flexisettings-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "443f75a645e33a27dd4be8286af5e6f6", "sha256": "7449c9ef79b6f2124f6a65162a69233e84f21cc240ddcb4dbb95ff6f7ac0126b" }, "downloads": -1, "filename": "flexisettings-1.0.2.tar.gz", "has_sig": false, "md5_digest": "443f75a645e33a27dd4be8286af5e6f6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4972, "upload_time": "2018-03-15T10:12:05", "url": "https://files.pythonhosted.org/packages/8e/30/e12d1cf8c60fac91ee8bd728da0d7dabf4c3a54737311196b793a8beacfa/flexisettings-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "d6bf323b439bb0bffae9d40191302afa", "sha256": "0d058b9c7238e57310850461ddc9d1ad08ea71351970ab29f9d16bc5a5559b09" }, "downloads": -1, "filename": "flexisettings-1.0.3.tar.gz", "has_sig": false, "md5_digest": "d6bf323b439bb0bffae9d40191302afa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5339, "upload_time": "2018-06-04T16:24:15", "url": "https://files.pythonhosted.org/packages/1c/39/25d538aaab21c503a557d213bddaf41b7b308fb778eafcadb94557436a15/flexisettings-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d6bf323b439bb0bffae9d40191302afa", "sha256": "0d058b9c7238e57310850461ddc9d1ad08ea71351970ab29f9d16bc5a5559b09" }, "downloads": -1, "filename": "flexisettings-1.0.3.tar.gz", "has_sig": false, "md5_digest": "d6bf323b439bb0bffae9d40191302afa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5339, "upload_time": "2018-06-04T16:24:15", "url": "https://files.pythonhosted.org/packages/1c/39/25d538aaab21c503a557d213bddaf41b7b308fb778eafcadb94557436a15/flexisettings-1.0.3.tar.gz" } ] }