diff --git a/atramhasis/static/package-lock.json b/atramhasis/static/package-lock.json index dc364a09..77752f27 100644 --- a/atramhasis/static/package-lock.json +++ b/atramhasis/static/package-lock.json @@ -18,18 +18,15 @@ "resolved": "https://registry.npmjs.org/d3/-/d3-3.5.17.tgz", "integrity": "sha512-yFk/2idb8OHPKkbAL8QaOaqENNoMhIaSHZerk3oQsECwkObkCpJyjYwCe+OHiq6UEdhe1m8ZGARRRO3ljFjlKg==" }, - "node_modules/font-awesome": { + "font-awesome": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz", - "integrity": "sha1-j6jPBBGhoxr9B7BtKQK7n8gVoTM=", - "engines": { - "node": ">=0.10.3" - } + "integrity": "sha512-U6kGnykA/6bFmg1M/oT9EkFeIYv7JlX3bozwQJWiiLz6L0w3F5vBVPxHlwyX/vtNq1ckcpRKOB9f2Qal/VtFpg==" }, - "node_modules/foundation-sites": { + "foundation-sites": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/foundation-sites/-/foundation-sites-5.5.3.tgz", - "integrity": "sha1-ZVbrKzHN47ImYwEWvSFdldBWwKc=" + "integrity": "sha512-z0NZl6Orkmeu0yhgjl3a8Ecd3frjEichn9IqocQX2jHMv9Ecd6UOPWS85f1YJXdCF6bHqnekGkrcWQ37ciR0Pw==" } } } diff --git a/cookiecutters/demo/cookiecutter.json b/cookiecutters/demo/cookiecutter.json new file mode 100644 index 00000000..b07501bf --- /dev/null +++ b/cookiecutters/demo/cookiecutter.json @@ -0,0 +1,5 @@ +{ + "root_folder": "atramhasis_demo", + "python_package": "atramhasis_demo", + "package_logger": "demo_logger" +} diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/CHANGES.txt b/cookiecutters/demo/{{cookiecutter.root_folder}}/CHANGES.txt new file mode 100644 index 00000000..00655981 --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/CHANGES.txt @@ -0,0 +1,4 @@ +0.0 +--- + +- Initial version \ No newline at end of file diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/MANIFEST.in b/cookiecutters/demo/{{cookiecutter.root_folder}}/MANIFEST.in new file mode 100644 index 00000000..637fe6be --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/MANIFEST.in @@ -0,0 +1,2 @@ +include *.txt *.ini *.cfg *.rst +recursive-include {{cookiecutter.python_package}} *.ico *.png *.css *.gif *.jpg *.pt *.txt *.jinja2 *.js *.html *.xml diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/README.rst b/cookiecutters/demo/{{cookiecutter.root_folder}}/README.rst new file mode 100644 index 00000000..8555ad9b --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/README.rst @@ -0,0 +1,3 @@ +{{cookiecutter.python_package}} README + +This is an Atramhasis demo application diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/alembic.ini b/cookiecutters/demo/{{cookiecutter.root_folder}}/alembic.ini new file mode 100644 index 00000000..2da4fe97 --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/alembic.ini @@ -0,0 +1,60 @@ +# A generic, single database configuration. + +[alembic] +# path to migration scripts +script_location = atramhasis:alembic + +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# max length of characters to apply to the +# "slug" field +#truncate_slug_length = 40 + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + +# set to 'true' to allow .pyc and .pyo files without +# a source .py file to be detected as revisions in the +# versions/ directory +# sourceless = false + +# sqlalchemy.url = sqlite:///%(here)s/atramhasis.sqlite + +ini_location = %(here)s/development.ini + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/development.ini b/cookiecutters/demo/{{cookiecutter.root_folder}}/development.ini new file mode 100644 index 00000000..835d8dac --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/development.ini @@ -0,0 +1,129 @@ +### +# app configuration +# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html +### + +[app:main] +use = egg:{{cookiecutter.python_package}} + +pyramid.reload_templates = true +pyramid.debug_authorization = false +pyramid.debug_notfound = false +pyramid.debug_routematch = false +pyramid.default_locale_name = en +pyramid.includes = + pyramid_debugtoolbar + pyramid_tm +jinja2.directories = + atramhasis:templates + {{cookiecutter.python_package}}:templates +jinja2.extensions = + jinja2.ext.do +jinja2.filters = + label_sort = atramhasis.utils.label_sort +available_languages = en nl fr +sqlalchemy.url = sqlite:///%(here)s/{{cookiecutter.python_package}}.sqlite + +atramhasis.session_factory.secret = test123 + +skosprovider.skosregistry_location = request +skosprovider.skosregistry_factory = {{cookiecutter.python_package}}.skos.create_registry + +jinja2.i18n.domain = atramhasis + +# Run dojo from source (src) or distribution (dist) +# If unspecified, defaults to src. +dojo.mode = dist + +# cache +cache.tree.backend = dogpile.cache.memory +cache.tree.arguments.cache_size = 5000 +cache.tree.expiration_time = 7000 + +cache.list.backend = dogpile.cache.memory +cache.list.arguments.cache_size = 5000 +cache.list.expiration_time = 7000 + +# Filesystem location to dump exports +atramhasis.dump_location = %(here)s/datadumps + +# Location of rdf2hdt executable +# atramhasis.rdf2hdt = /link/to/rdf2hdt + +# Assume an LDF server is present? +# atramhasis.ldf.enabled = True + +# Location of the config file for the LDF server +# atramhasis.ldf.config_location = %(here)s + +# External url of the LDF server +# atramhasis.ldf.baseurl = http://demo.atramhasis.org/ldf + +# Protocol the LDF server is operating under. +# See the LDF docs for more info +# atramhasis.ldf.protocol = http + +# By default, the toolbar only appears for clients from IP addresses +# '127.0.0.1' and '::1'. +# debugtoolbar.hosts = 127.0.0.1 ::1 + + +layout.focus_conceptschemes = + HERITAGETYPE + PERIOD + GEOGRAPHY + MATERIALS + +### +# wsgi server configuration +### + +[server:main] +use = egg:waitress#main +host = 0.0.0.0 +port = 6543 + +### +# logging configuration +# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +### + +[loggers] +keys = root, atramhasis, sqlalchemy, {{cookiecutter.package_logger}} + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = INFO +handlers = console + +[logger_atramhasis] +level = DEBUG +handlers = +qualname = atramhasis + +[logger_sqlalchemy] +level = INFO +handlers = +qualname = sqlalchemy.engine +# "level = INFO" logs SQL queries. +# "level = DEBUG" logs SQL queries and results. +# "level = WARN" logs neither. (Recommended for production systems.) + +[logger_{{cookiecutter.package_logger}}] +level = DEBUG +handlers = +qualname = {{cookiecutter.python_package}} + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/pyproject.toml b/cookiecutters/demo/{{cookiecutter.root_folder}}/pyproject.toml new file mode 100644 index 00000000..3e2a420c --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/pyproject.toml @@ -0,0 +1,32 @@ +[build-system] +requires = ["hatchling", "hatch-fancy-pypi-readme"] +build-backend = "hatchling.build" + +[project] +name = "{{ cookiecutter.python_package }}" +description = "My atramhasis setup" +version = "0.0.1" + +dependencies = [ + "atramhasis", + "pyramid", + "SQLAlchemy", + "skosprovider", + "skosprovider_getty", +] + +[project.optional-dependencies] +dev = [ + "waitress", + "pyramid_debugtoolbar", +] + +[project.entry-points."paste.app_factory"] +main = "{{ cookiecutter.python_package }}:main" + +[tool.hatch.metadata.hooks.fancy-pypi-readme] +content-type = "text/x-rst" +fragments = [ + { path = "README.rst" }, + { path = "CHANGES.rst" }, +] \ No newline at end of file diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py b/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py new file mode 100644 index 00000000..2a41bbf4 --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py @@ -0,0 +1,40 @@ +import os + +from atramhasis.data.models import Base +from pyramid.config import Configurator +from pyramid.session import SignedCookieSessionFactory +from pyramid.settings import aslist +from sqlalchemy import engine_from_config + + +def main(global_config, **settings): + """This function returns a Pyramid WSGI application.""" + + # Set up sqlalchemy + engine = engine_from_config(settings, "sqlalchemy.") + Base.metadata.bind = engine + + # update settings + settings["layout.focus_conceptschemes"] = aslist( + settings["layout.focus_conceptschemes"], flatten=False + ) + + # set up dump location + dump_location = settings["atramhasis.dump_location"] + if not os.path.exists(dump_location): + os.makedirs(dump_location) + + with Configurator(settings=settings) as config: + # set default session factory + atramhasis_session_factory = SignedCookieSessionFactory( + settings["atramhasis.session_factory.secret"] + ) + config.set_session_factory(atramhasis_session_factory) + + # Set up atramhasis + config.include("atramhasis") + # Set up atramhasis db + config.include("atramhasis:data.db") + + config.scan() + return config.make_wsgi_app() diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/event_handlers.py b/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/event_handlers.py new file mode 100644 index 00000000..57467500 --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/event_handlers.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +from atramhasis.protected_resources import ProtectedResourceEvent +from atramhasis.protected_resources import ProtectedResourceException +from pyramid.events import subscriber + + +@subscriber(ProtectedResourceEvent) +def sample_impl(event): + if event.uri.endswith("2"): + referenced_in = ["urn:someobject", "http://test.test.org/object/2"] + raise ProtectedResourceException( + "resource {0} is still in use, preventing operation".format(event.uri), + referenced_in, + ) diff --git a/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/skos/__init__.py b/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/skos/__init__.py new file mode 100644 index 00000000..deeeb26a --- /dev/null +++ b/cookiecutters/demo/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/skos/__init__.py @@ -0,0 +1,41 @@ +import logging + +import requests +from atramhasis import skos +from cachecontrol import CacheControl +from cachecontrol.heuristics import ExpiresAfter +from skosprovider.registry import Registry +from skosprovider_getty.providers import AATProvider +from skosprovider_getty.providers import TGNProvider + +log = logging.getLogger(__name__) +LICENSES = [ + 'https://creativecommons.org/licenses/by/4.0/', + 'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0' +] + + +def create_registry(request): + try: + registry = Registry(instance_scope='threaded_thread') + + getty_session = CacheControl(requests.Session(), heuristic=ExpiresAfter(weeks=1)) + + aat = AATProvider( + {'id': 'AAT', 'subject': ['external']}, + session=getty_session + ) + + tgn = TGNProvider( + {'id': 'TGN', 'subject': ['external']}, + session=getty_session + ) + + registry.register_provider(aat) + registry.register_provider(tgn) + skos.register_providers_from_db(registry, request.db) + + return registry + except AttributeError: + log.exception("Attribute error during creation of Registry.") + raise diff --git a/cookiecutters/scaffold/cookiecutter.json b/cookiecutters/scaffold/cookiecutter.json new file mode 100644 index 00000000..493c6f7c --- /dev/null +++ b/cookiecutters/scaffold/cookiecutter.json @@ -0,0 +1,5 @@ +{ + "root_folder": "atramhasis_scaffold", + "python_package": "atramhasis_scaffold", + "package_logger": "atramhasis_scaffold_logger" +} diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/CHANGES.txt b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/CHANGES.txt new file mode 100644 index 00000000..00655981 --- /dev/null +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/CHANGES.txt @@ -0,0 +1,4 @@ +0.0 +--- + +- Initial version \ No newline at end of file diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/README.rst b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/README.rst new file mode 100644 index 00000000..45fe820b --- /dev/null +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/README.rst @@ -0,0 +1,3 @@ +{{cookiecutter.python_package}} README + +this is just a scaffold diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/alembic.ini b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/alembic.ini new file mode 100644 index 00000000..0dfeb651 --- /dev/null +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/alembic.ini @@ -0,0 +1,64 @@ +# A generic, single database configuration. + +[alembic] +# path to migration scripts +script_location = atramhasis:alembic + +# uncomment if your project uses its own alembic +# script_location = alembic +# version_locations = %(here)s/alembic/versions atramhasis:alembic/versions + +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# max length of characters to apply to the +# "slug" field +#truncate_slug_length = 40 + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + +# set to 'true' to allow .pyc and .pyo files without +# a source .py file to be detected as revisions in the +# versions/ directory +# sourceless = false + +# sqlalchemy.url = sqlite:///%(here)s/atramhasis.sqlite + +ini_location = %(here)s/development.ini + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/development.ini b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/development.ini new file mode 100644 index 00000000..32bf3ebb --- /dev/null +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/development.ini @@ -0,0 +1,58 @@ +[app:main] +use = egg:{{ cookiecutter.python_package }} + +sqlalchemy.url = sqlite:///%(here)s/{{cookiecutter.python_package}}.sqlite + +# Filesystem location to dump exports +atramhasis.dump_location = %(here)s/datadumps + + +[server:main] +use = egg:waitress#main +host = 0.0.0.0 +port = 6543 + +### +# logging configuration +# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +### + +[loggers] +keys = root, atramhasis, sqlalchemy, {{cookiecutter.package_logger}} + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = INFO +handlers = console + +[logger_atramhasis] +level = DEBUG +handlers = +qualname = atramhasis + +[logger_sqlalchemy] +level = INFO +handlers = +qualname = sqlalchemy.engine +# "level = INFO" logs SQL queries. +# "level = DEBUG" logs SQL queries and results. +# "level = WARN" logs neither. (Recommended for production systems.) + +[logger_{{cookiecutter.package_logger}}] +level = DEBUG +handlers = +qualname = {{cookiecutter.package}} + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s \ No newline at end of file diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/pyproject.toml b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/pyproject.toml new file mode 100644 index 00000000..b464bb93 --- /dev/null +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/pyproject.toml @@ -0,0 +1,22 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "{{ cookiecutter.python_package }}" +description = "My atramhasis setup" +version = "0.0.1" + +dependencies = [ + "atramhasis", + "pyramid", +] + +[project.optional-dependencies] +dev = [ + "waitress", + "pyramid_debugtoolbar", +] + +[project.entry-points."paste.app_factory"] +main = "{{ cookiecutter.python_package }}:main" diff --git a/cookiecutters/scaffold/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py new file mode 100644 index 00000000..b97108fa --- /dev/null +++ b/cookiecutters/scaffold/{{cookiecutter.root_folder}}/{{cookiecutter.python_package}}/__init__.py @@ -0,0 +1,28 @@ +import os + +from pyramid.config import Configurator +from sqlalchemy import engine_from_config + +from atramhasis.data.models import Base + + +def main(global_config, **settings): + """This function returns a Pyramid WSGI application.""" + + # Set up sqlalchemy + engine = engine_from_config(settings, "sqlalchemy.") + Base.metadata.bind = engine + + # set up dump location + dump_location = settings["atramhasis.dump_location"] + if not os.path.exists(dump_location): + os.makedirs(dump_location) + + with Configurator(settings=settings) as config: + # Set up atramhasis + config.include("atramhasis") + # Set up atramhasis db + config.include("atramhasis:data.db") + + config.scan() + return config.make_wsgi_app() diff --git a/docs/source/customisation.rst b/docs/source/customisation.rst index 500ca206..b26907de 100644 --- a/docs/source/customisation.rst +++ b/docs/source/customisation.rst @@ -16,9 +16,80 @@ instance with only these default settings. Creating your own project ========================= -Follow the README at `atramhasis_scaffold_cookiecutter `_ +Requirements +------------ + +* Python 3.9+ +* npm + +Usage +----- + +1. Create a virtual environment and install requirements + + .. code-block:: bash + + # create a new virtual environment for the project, fe python -m venv $HOME/.virtualenvs/my_atramhasis + $ VENV_PATH=$HOME/Envs + $ python -m venv $VENV_PATH/my_atramhasis + $ . $VENV_PATH/my_atramhasis/bin/activate + # Make sure pip and pip-tools are up to date + $ pip install --upgrade pip pip-tools + $ pip install --upgrade cookiecutter + +2. Use cookiecutter to generate an atramhasis project + + .. code-block:: bash + + $ cookiecutter gh:OnroerendErfgoed/atramhasis --directory cookiecutters/scaffold + +3. Install requirements + +You can opt to generate requirements*.txt files from the pyproject.toml file and install the dependencies, +or you can install them directly from the pyproject.toml file. + +*Using requirements*.txt files*: + + .. code-block:: bash + + $ cd + # Generate requirements files from the existing pyproject.toml + $ PIP_COMPILE_ARGS="-v --strip-extras --no-header --resolver=backtracking --no-emit-options --no-emit-find-links"; + # Generate requirements files for a production environment + $ pip-compile $PIP_COMPILE_ARGS; + # Generate requirements files for a development environment + $ pip-compile $PIP_COMPILE_ARGS --all-extras -o requirements-dev.txt; + + # Install dependencies + $ pip-sync requirements-dev.txt + # Install the new project in editable mode + $ pip install -e . + + Note that pip-sync will uninstall all packages that are not listed in the requirements. The package cookiecutter + is no longer needed and will be uninstalled when executing pip-sync. + +*Using pyproject.toml*: + + .. code-block:: bash + + $ cd + # Install the new project in editable mode via argument -e + # Optional: Include [dev] to install the development dependencies + $ pip install -e .[dev] + +4. Setup database + + .. code-block:: bash + + $ alembic upgrade head + +5. Run server + + .. code-block:: bash + + $ pserve development.ini + -This gives you a clean slate to start your customisations on. Database -------- diff --git a/docs/source/demo.rst b/docs/source/demo.rst index 15d0e45a..e220521f 100644 --- a/docs/source/demo.rst +++ b/docs/source/demo.rst @@ -10,35 +10,69 @@ Running a demo site with Cookiecutter Checking a working instance of the Atramhasis can be done at `the Flanders Heritage Thesaurus `_ or by running a demo yourself. This allows you to quickly evaluate and inspect the software. -This can be done through the `cookiecutter` package. +This can be done through the `cookiecutter` package. -.. code-block:: bash - - $ python -m venv atramhasis_demo - $ . atramhasis_demo/bin/activate - # Make sure pip and setuptools are up to date - $ pip install --upgrade pip setuptools - $ pip install -U cookiecutter -Once cookiecutter is installed, you use it to generate the demo site. +1. Create a virtual environment and install requirements + +.. code-block:: bash + + # create a new virtual environment for the project, fe python -m venv $HOME/.virtualenvs/atramhasis_demo + # Change directory into your newly created project if not already there. + $ python -m venv atramhasis_demo + $ . atramhasis_demo/bin/activate + # Make sure pip and pip-tools are up to date + $ pip install --upgrade pip pip-tools + $ pip install --upgrade cookiecutter + +2. Use cookiecutter to generate an demo project .. code-block:: bash - $ cookiecutter gh:OnroerendErfgoed/atramhasis_demo_cookiecutter + # Change the ATRAMHASIS_PATH to the path where your atramhasis project is located + $ ATRAMHASIS_PATH=$HOME/dev/atramhasis + $ cookiecutter gh:OnroerendErfgoed/atramhasis --directory $ATRAMHASIS_PATH/cookiecutters/demo Running this command will ask a few questions. Just accept the default answers, unless you want to give your project a different name. After the cookiecutter command, there should be a directory with the name of your -project (default: atramhasis_demo). Enter this directory and install -requirements: +project (default: atramhasis_demo). Now enter this directory to start updating your virtual environment. + + +3. Install requirements .. code-block:: bash + # Change directory into your newly created project $ cd atramhasis_demo + # Generate requirements files from the existing pyproject.toml + $ PIP_COMPILE_ARGS="-v --strip-extras --no-header --resolver=backtracking --no-emit-options --no-emit-find-links"; + # Generate requirements files for a production environment + $ pip-compile $PIP_COMPILE_ARGS; + # Generate requirements files for a development environment + $ pip-compile $PIP_COMPILE_ARGS --all-extras -o requirements-dev.txt; + + # Install dependencies + $ pip-sync requirements-dev.txt + # Install the new project in editable mode + $ pip install -e . + +Note that pip-sync will uninstall all packages that are not listed in the requirements. +If you started from an existing virtualenv and you have packages in your virtualenv that +you want to keep or need, you should either reinstall them afterwards or use the +pip install command as follows: + +.. code-block:: bash + + # Install dependencies $ pip install -r requirements-dev.txt + # Install the new project in editable mode $ pip install -e . -Now it's time to setup our database (a simple SQLite database) and add some + +4. Setup database + +Now it's time to setup our database (a simple SQLite database) and add some testdata: .. code-block:: bash @@ -47,6 +81,8 @@ testdata: # fill the database with data $ initialize_atramhasis_db development.ini +5. Create RDF dumps + Optionally, we can create RDF dumps, but this is not necessary for basic functionality: @@ -54,15 +90,14 @@ functionality: $ dump_rdf development.ini -Almost done! All we need now are some frontend dependencies: +6. All we need now are some frontend dependencies: .. code-block:: bash $ cd atramhasis_demo/static $ npm install -Finally, we can start our server. Return to the root of your project repo and -run pserve: +7. Run server .. code-block:: bash @@ -70,6 +105,7 @@ run pserve: # start server $ pserve development.ini + The Atramhasis demo instance is now running on your localhost at port 6543. To reach it, open your browser and surf to the address ``_. diff --git a/docs/source/development.rst b/docs/source/development.rst index 2f4f9269..a8af6e22 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -123,6 +123,17 @@ production environment. $ pserve --reload development.ini +Update requirements files +========================= +The dependencies are defined within pyproject.toml. There, you can add, modify, or remove libraries. +Afterward, run pip-compile to generate the requirements files. + +.. code-block:: bash + # Update pyproject.toml and run pip-compile as follows: + $ PIP_COMPILE_ARGS="-v --strip-extras --no-header --resolver=backtracking --no-emit-options --no-emit-find-links"; + $ pip-compile $PIP_COMPILE_ARGS; + $ pip-compile $PIP_COMPILE_ARGS --all-extras -o requirements-dev.txt; + Admin development ================= @@ -220,6 +231,23 @@ language switcher. If you want to add your new language, you need to edit your After restarting your server you will now have the option of switching to German. +Update Cookiecutters +==================== + +In case changes are needed for the cookiecutters, you may want to test them on an unreleased version of Atramhasis. +You can test them on a specific branch by running the following commands: + +.. code-block:: bash + + # fe you are working on the branch feature/876_cookiecutters and you want to test the demo cookiecutter + $ cookiecutter gh:OnroerendErfgoed/atramhasis --directory cookiecutters/demo --checkout feature/876_cookiecutters + $ cd atramhasis_demo # or whatever you named the root_folder of your project + $ pip install "atramhasis @ git+ssh://git@github.com/OnroerendErfgoed/atramhasis.git@feature/876_cookiecutters" + $ pip install -e .[dev] + $ alembic upgrade head + $ initialize_atramhasis_db development.ini # (for demo only) + $ pserve development.ini + Running a Linked Data Fragments server ====================================== diff --git a/requirements-dev.txt b/requirements-dev.txt index a59f056d..c24995b0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -38,8 +38,6 @@ docutils==0.19 # via sphinx dogpile-cache==1.3.3 # via atramhasis (pyproject.toml) -exceptiongroup==1.2.1 - # via pytest flake8==4.0.1 # via atramhasis (pyproject.toml) frozendict==2.4.4 @@ -217,12 +215,6 @@ rpds-py==0.18.1 # via # jsonschema # referencing -setuptools==70.0.0 - # via - # pyramid - # zope-deprecation - # zope-interface - # zope-sqlalchemy six==1.16.0 # via # bleach @@ -268,18 +260,14 @@ sphinxcontrib-serializinghtml==1.1.10 # via sphinx sqlalchemy==2.0.30 # via - # atramhasis (pyproject.toml) # alembic + # atramhasis (pyproject.toml) # skosprovider-sqlalchemy # zope-sqlalchemy stevedore==5.2.0 # via dogpile-cache testfixtures==7.2.2 # via atramhasis (pyproject.toml) -tomli==2.0.1 - # via - # coverage - # pytest transaction==4.0 # via # atramhasis (pyproject.toml) @@ -292,7 +280,6 @@ translationstring==1.4 typing-extensions==4.12.2 # via # alembic - # dogpile-cache # sqlalchemy urllib3==2.2.2 # via requests @@ -325,3 +312,6 @@ zope-interface==6.4.post2 # zope-sqlalchemy zope-sqlalchemy==3.1 # via atramhasis (pyproject.toml) + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/requirements.txt b/requirements.txt index 22d1b745..873e1414 100644 --- a/requirements.txt +++ b/requirements.txt @@ -152,12 +152,6 @@ rpds-py==0.18.1 # via # jsonschema # referencing -setuptools==70.0.0 - # via - # pyramid - # zope-deprecation - # zope-interface - # zope-sqlalchemy six==1.16.0 # via # bleach @@ -180,8 +174,8 @@ skosprovider-sqlalchemy==2.1.1 # via atramhasis (pyproject.toml) sqlalchemy==2.0.30 # via - # atramhasis (pyproject.toml) # alembic + # atramhasis (pyproject.toml) # skosprovider-sqlalchemy # zope-sqlalchemy stevedore==5.2.0 @@ -198,7 +192,6 @@ translationstring==1.4 typing-extensions==4.12.2 # via # alembic - # dogpile-cache # sqlalchemy urllib3==2.2.2 # via requests @@ -223,3 +216,6 @@ zope-interface==6.4.post2 # zope-sqlalchemy zope-sqlalchemy==3.1 # via atramhasis (pyproject.toml) + +# The following packages are considered to be unsafe in a requirements file: +# setuptools