-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
executable file
·152 lines (123 loc) · 4.49 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2018 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause
import codecs
from os import path
from setuptools import setup
README = """
django-yamlconf
===============
``django_yamlconf`` is part of VMware's support of open source
development and community.
Handle YAML based Django settings: load Django settings from YAML files
based on a Django project name. The YAML files loaded start with a YAML
file in the directory containing the Django settings file and then loads
any other YAMLCONF files up the directory tree from the initial file.
Values from files higher up the directory tree over-ride lower in the
tree. The contents of the YAML file simply defines values that over-ride
(or add to) attributes of the standard Django settings file, e.g., for
the project "buildaudit", the settings.py file could contain:
.. code:: python
DEBUG = True
i.e., the value for development. This can be redefined via a
``buildaudit.yaml`` file using the definition:
.. code:: python
DEBUG: false
If the environment variable ``YAMLCONF_CONFFILE`` is defined, it uses as
the final YAML file loaded (in this case, the file name does not need to
match the project name and it can be located anywhere in the file
system).
Quick Start
-----------
The YAMLCONF definitions are added to the Django settings file by
including a call to the ``load`` function in the settings file. This
would normally be towards the end of the settings file. The simplest,
and likely normal usage is to call without arguments. YAMLCONF will
infer the project information from the call stack. For a standard Django
application structure, the settings file::
myproject/myproject/settings.py
would contain the development oriented definitions, e.g., database
definitions for user and password for a development database. The
settings file would then end with a call the the ``load`` function.
Additional definitions could be defined after the ``load`` function to
update conditional definitions, e.g., if ``DEBUG`` is enabled.
.. code:: python
import django_yamlconf
...
DATABASES = {
'default': {
'NAME': 'example',
'USER': 'example',
'PASSWORD': 'example',
'HOST': 'localhost',
...
}
}
...
django_yamlconf.load()
On a production server, for this example, a ``myproject.yaml`` would be
put in place containing the host name for the production database and
the password for the example user (assuming production is using the same
database name and username). In this example, a random ``pwgen``
password is used:
.. code:: yaml
DATABASES.default.PASSWORD: 'zibiemohjuD6foh0'
DATABASES.default.HOST: 'myproject-db.eng.vmware.com'
See the ``load`` function for more information on other optional
arguments.
License
-------
``django-yamlconf`` is release under the BSD-2 license, see the LICENSE
file.
SPDX-License-Identifier: BSD-2-Clause
"""
def version():
vers_path = path.join(
path.dirname(__file__),
"django_yamlconf",
"VERSION"
)
with open(vers_path, "r") as fh:
v_info = fh.readline()
return ".".join(filter(lambda x: x != '', v_info.split(" "))).strip()
setup(
name='django-yamlconf',
version=version(),
author='Michael Rohan',
author_email='[email protected]',
description='Define Django settings in local YAML (or JSON) files',
long_description=README,
license='BSD-2',
platforms=['Any'],
keywords=['django'],
url='https://github.com/vmware/django-yamlconf',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: OS Independent',
"Framework :: Django",
"Framework :: Django :: 1.7",
"Framework :: Django :: 2.0",
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Topic :: Software Development :: Libraries :: Python Modules',
],
install_requires=[
'PyYAML>=3.10',
'six>=1.10.0',
],
packages=[
'django_yamlconf',
'django_yamlconf.templatetags',
'django_yamlconf.management',
'django_yamlconf.management.commands',
],
include_package_data=True,
zip_safe=False,
test_suite='nose.collector',
tests_require=['nose', 'Jinja2'],
)