Skip to content

Commit

Permalink
Move static assets to the project directory
Browse files Browse the repository at this point in the history
Installing the static assets in the project directory instead of an external directory
make installation easier.

Add whitenoise to requires in setup.py so that the static assets are automatically (without
user action) served after installation.

Remove package_data from setup.py, you should use package_data or MANIFEST.in to specify
which non-python files have to be installed, not both.
  • Loading branch information
piotr1212 committed Jan 31, 2019
1 parent 0c7d5d1 commit 3c02110
Show file tree
Hide file tree
Showing 351 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ include conf/*.example
include webapp/graphite/local_settings.py.example
recursive-include distro/ *
recursive-include webapp/graphite/ *.html
recursive-include webapp/content/ *
recursive-include webapp/graphite/static/ *
exclude webapp/graphite/local_settings.py
exclude conf/*.conf
16 changes: 5 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@

for subdir in ('whisper/dummy.txt', 'ceres/dummy.txt', 'rrd/dummy.txt',
'log/dummy.txt', 'log/webapp/dummy.txt'):
storage_dirs.append( ('storage/%s' % subdir, []) )

webapp_content = defaultdict(list)

for root, dirs, files in os.walk('webapp/content'):
for filename in files:
filepath = os.path.join(root, filename)
webapp_content[root].append(filepath)
storage_dirs.append(('storage/%s' % subdir, []))

conf_files = [('conf', glob('conf/*.example'))]
examples = [('examples', glob('examples/example-*'))]
Expand Down Expand Up @@ -63,11 +56,12 @@ def read(fname):
'graphite.whitelist',
'graphite.worker_pool',
],
package_data={'graphite': ['templates/*', 'local_settings.py.example']},
scripts=glob('bin/*'),
data_files=list(webapp_content.items()) + storage_dirs + conf_files + examples,
include_package_data=True,
data_files=storage_dirs + conf_files + examples,
install_requires=['Django>=1.8,<2.2', 'django-tagging==0.4.3', 'pytz',
'pyparsing', 'cairocffi', 'urllib3', 'scandir', 'six'],
'pyparsing', 'cairocffi', 'urllib3', 'scandir', 'six',
'whitenoise'],
classifiers=[
'Intended Audience :: Developers',
'Natural Language :: English',
Expand Down
5 changes: 2 additions & 3 deletions webapp/graphite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

# Filesystem layout
WEB_DIR = dirname(abspath(__file__))
WEBAPP_DIR = dirname(WEB_DIR)
GRAPHITE_ROOT = '/opt/graphite'
# Initialize additional path variables
# Defaults for these are set after local_settings is imported
Expand Down Expand Up @@ -219,7 +218,7 @@


STATICFILES_DIRS = (
join(WEBAPP_DIR, 'content'),
join(WEB_DIR, 'static'),
)

# Handle renamed timeout settings
Expand All @@ -229,7 +228,7 @@
## Set config dependent on flags set in local_settings
# Path configuration
if not STATIC_ROOT:
STATIC_ROOT = join(GRAPHITE_ROOT, 'static')
STATIC_ROOT = join(WEB_DIR, 'static')

if not CONF_DIR:
CONF_DIR = os.environ.get('GRAPHITE_CONF_DIR', join(GRAPHITE_ROOT, 'conf'))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3c02110

Please sign in to comment.