Browse Source

Development (#41)

* Move doc/ to docs/.

* Docstring conversion #2

* Query API
* Resource API

* Docstring conversion #3.

* Convert all .md docs to .rst.

* Sphinx setup.

* Clean up docstrings.

* Further major setup.

* Add indexing strategy and setup docs
* Move most text out of README
* RTD theme
* Other amendments here and there

* Mock LMDB import.

http://docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules

* Experimental: do not abort startup if cannot connect to STOMP server.

* Workaround for LMDB import.

* Many doc adjustments and additions. Good to publish.

* Separate dev requirements.

* Add docs badge.

* Fix doc page link.

* Fix contributing link.

* Amend contributing link.

* Fix some docstring formatting; use `venv` for installing virtual env.

* Docstring improvements here and there.

* Package software.

* Add setup.py
* Integrate with pytest-runner
* Remove requirements_dev.txt
* Rework console scripts to produce binaries with distro
* Adapt travis.yml

* Fix pip script in travis.

* Package software.

* Add setup.py
* Integrate with pytest-runner
* Remove requirements_dev.txt
* Rework console scripts to produce binaries with distro
* Adapt travis.yml

* Remove top-level init.

* Prepare for alpha9

* Update documentation
* Update Docker files
* Add wsgi script

* Amend Dockerfile.

* Packaging (#39)

Restructure many files for distro inclusion.

* Add assets and HTML templates
* Move utils under lakesuperior package

* Packaging (#40)

Restructure many files for distro inclusion.

* Add assets and HTML templates
* Move utils under lakesuperior package
* Move etc.defaults into lakesuperior package.
* Gunicorn gets default config dir from config parser.
* More reliable base directory for configuration.
* Change config dir in Dockerfile.
Stefano Cossu 6 years ago
parent
commit
ac4556e54a

+ 1 - 1
Dockerfile

@@ -4,8 +4,8 @@ RUN         mkdir -p /usr/local /data
 WORKDIR     /usr/local
 ADD         . lakesuperior
 WORKDIR     /usr/local/lakesuperior
-RUN         cp ./docker/etc/* ./etc.defaults/
 RUN         pip install -e .
+RUN         cp ./docker/etc/* ./lakesuperior/etc.defaults/
 CMD         ./docker/docker_entrypoint
 EXPOSE      8000
 HEALTHCHECK --interval=30s --timeout=5s \

+ 1 - 0
MANIFEST.in

@@ -1,3 +1,4 @@
 include README.rst
 include LICENSE
 graft lakesuperior/endpoints/templates
+graft lakesuperior/etc.defaults

+ 2 - 2
docker/etc/gunicorn.yml

@@ -4,12 +4,12 @@
 # Commented values are the application defaults.
 
 # Directory where the WSGI server data are stored.
-data_dir: 'data'
+data_dir: '/data'
 
 # Set app_mode to either 'prod', 'test' or 'dev'.
 # 'prod' is normal running mode. 'test' is used for running test suites.
 # 'dev' is similar to normal mode but with reload and debug enabled.
-app_mode: 'dev'
+app_mode: 'prod'
 
 #listen_addr: '0.0.0.0'
 #listen_port: 8000

+ 1 - 2
docs/conf.py

@@ -22,8 +22,7 @@ import sys
 
 from unittest.mock import MagicMock
 
-#sys.path.insert(0, os.path.abspath('../'))
-sys.path.append(os.path.abspath('../'))
+#sys.path.append(os.path.abspath('../'))
 
 class MockModule(MagicMock):
     @classmethod

+ 2 - 2
docs/setup.rst

@@ -79,14 +79,14 @@ the ``data`` directory.
 
 To change the default configuration you should:
 
-#. Copy the ``etc.skeleton`` folder to a separate location
+#. Copy the ``etc.default`` folder to a separate location
 #. Set the configuration folder location in the environment:
    ``export FCREPO_CONFIG_DIR=<your config dir location>`` (you can add
    this line at the end of your virtualenv ``activate`` script)
 #. Configure the application
 #. Bootstrap the app or copy the original data folders to the new
    location if any loction options changed
-#. (Re)start the server: ``./fcrepo``
+#. (Re)start the server: ``fcrepo``
 
 The configuration options are documented in the files.
 

+ 16 - 2
lakesuperior/config_parser.py

@@ -5,6 +5,21 @@ from os import path, environ
 import hiyapyco
 import yaml
 
+import lakesuperior
+
+
+default_config_dir = environ.get('FCREPO_CONFIG_DIR', path.dirname(
+            path.abspath(lakesuperior.__file__)) + '/etc.defaults')
+"""
+Default configuration directory.
+
+This value falls back to the provided ``etc.defaults`` directory if the
+``FCREPO_CONFIG_DIR`` environment variable is not set.
+
+This value can still be overridden by custom applications by passing the
+``config_dir`` value to :func:`parse_config` explicitly.
+"""
+
 
 def parse_config(config_dir=None):
     """
@@ -30,8 +45,7 @@ def parse_config(config_dir=None):
     )
 
     if not config_dir:
-        config_dir = environ.get('FCREPO_CONFIG_DIR', path.dirname(
-                path.dirname(path.abspath(__file__))) + '/etc.defaults')
+        config_dir = default_config_dir
 
     # This will hold a dict of all configuration values.
     _config = {}

+ 0 - 0
etc.defaults/README → lakesuperior/etc.defaults/README


+ 0 - 0
etc.defaults/application.yml → lakesuperior/etc.defaults/application.yml


+ 0 - 0
etc.defaults/flask.yml → lakesuperior/etc.defaults/flask.yml


+ 0 - 0
etc.defaults/gunicorn.yml → lakesuperior/etc.defaults/gunicorn.yml


+ 0 - 0
etc.defaults/logging.yml → lakesuperior/etc.defaults/logging.yml


+ 0 - 0
etc.defaults/namespaces.yml → lakesuperior/etc.defaults/namespaces.yml


+ 0 - 0
etc.defaults/test.yml → lakesuperior/etc.defaults/test.yml


+ 2 - 4
lakesuperior/wsgi.py

@@ -6,12 +6,10 @@ from os import environ, makedirs, path
 import gunicorn.app.base
 
 from lakesuperior.server import fcrepo
+from lakesuperior.config_parser import default_config_dir
 
 
-default_config_dir = '{}/etc.defaults'.format(
-        path.dirname(path.abspath(__file__)))
-config_dir = environ.get('FCREPO_CONFIG_DIR', default_config_dir)
-config_file = '{}/gunicorn.yml'.format(config_dir)
+config_file = '{}/gunicorn.yml'.format(default_config_dir)
 
 with open(config_file, 'r') as fh:
     config = yaml.load(fh, yaml.SafeLoader)

+ 1 - 3
setup.py

@@ -27,7 +27,7 @@ with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
 
 setup(
     name='lakesuperior',
-    version='1.0.0a98',
+    version='1.0.0a99',
 
     description='A Linked Data Platform repository sever.',
     long_description=long_description,
@@ -104,10 +104,8 @@ setup(
     include_package_data=True,
     #extras_require={},
     #package_data={
-    #    'endpoints': ['templates/*'],
     #},
     data_files=[
-        ('etc', glob('etc.defaults/*.yml')),
         ('data/bootstrap', glob('data/bootstrap/*')),
         ('data/ldpnr_store', ['data/ldpnr_store/.keep']),
         ('data/ldprs_store', ['data/ldprs_store/.keep']),