From 8a14bd3fbfae543f684d97a678ed3f2a003f794c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Thu, 26 Sep 2024 10:44:35 +0200 Subject: [PATCH 1/2] Setup local installation --- .gitignore | 2 + .meta.toml | 6 +++ Makefile | 123 +++++++++++++++++++++++++++++++++++++++++++ constraints.txt | 1 + instance.yaml | 7 +++ mx.ini | 9 ++++ news/+setup.internal | 2 + requirements.txt | 1 + 8 files changed, 151 insertions(+) create mode 100644 Makefile create mode 100644 constraints.txt create mode 100644 instance.yaml create mode 100644 mx.ini create mode 100644 news/+setup.internal create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 486392f6..8d63c885 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,8 @@ local.cfg /venv/ .installed.txt +/test_* +robot_* ## # Add extra configuration options in .meta.toml: diff --git a/.meta.toml b/.meta.toml index 3bf9f054..74ca55db 100644 --- a/.meta.toml +++ b/.meta.toml @@ -11,3 +11,9 @@ dependencies_ignores = "['ZServer', 'plone.app.event', 'Products.CMFPlone',]" [tox] constraints_file = "https://dist.plone.org/release/6.1-dev/constraints.txt" + +[gitignore] +extra_lines = """ +/test_* +robot_* +""" diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..cf20422b --- /dev/null +++ b/Makefile @@ -0,0 +1,123 @@ +### Defensive settings for make: +# https://tech.davis-hansson.com/p/make/ +SHELL:=bash +.ONESHELL: +.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c +.SILENT: +.DELETE_ON_ERROR: +MAKEFLAGS+=--warn-undefined-variables +MAKEFLAGS+=--no-builtin-rules + +# We like colors +# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects +RED=`tput setaf 1` +GREEN=`tput setaf 2` +RESET=`tput sgr0` +YELLOW=`tput setaf 3` + +BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +DOCS_DIR=${BACKEND_FOLDER}/docs + +# Python checks +PYTHON?=python3 + +# installed? +ifeq (, $(shell which $(PYTHON) )) + $(error "PYTHON=$(PYTHON) not found in $(PATH)") +endif + +# version ok? +PYTHON_VERSION_MIN=3.8 +PYTHON_VERSION_OK=$(shell $(PYTHON) -c "import sys; print((int(sys.version_info[0]), int(sys.version_info[1])) >= tuple(map(int, '$(PYTHON_VERSION_MIN)'.split('.'))))") +ifeq ($(PYTHON_VERSION_OK),0) + $(error "Need python $(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)") +endif + +all: build + +# Add the following 'help' target to your Makefile +# And add help text after each target name starting with '\#\#' +.PHONY: help +help: ## This help message + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: clean +clean: clean-build clean-pyc clean-test clean-venv clean-instance ## remove all build, test, coverage and Python artifacts + +.PHONY: clean-instance +clean-instance: ## remove existing instance + rm -fr instance etc inituser var + +.PHONY: clean-venv +clean-venv: ## remove virtual environment + rm -fr bin include lib lib64 env pyvenv.cfg .tox .pytest_cache constraints-mxdev.txt requirements-mxdev.txt sources/ + +.PHONY: clean-build +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + rm -fr parts/ + rm -fr coverage.xml + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -rf {} + + +.PHONY: clean-pyc +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +.PHONY: clean-test +clean-test: ## remove test and coverage artifacts + rm -f .coverage + rm -fr htmlcov/ + rm -fr test_* + rm -fr robot_* + +bin/pip bin/tox bin/mxdev: + @echo "$(GREEN)==> Setup Virtual Env$(RESET)" + $(PYTHON) -m venv . + bin/pip install -U "pip" "wheel" "cookiecutter" "mxdev" "tox" "pre-commit" + bin/pre-commit install + +.PHONY: config +config: bin/pip ## Create instance configuration + @echo "$(GREEN)==> Create instance configuration$(RESET)" + bin/cookiecutter -f --no-input --config-file instance.yaml gh:plone/cookiecutter-zope-instance + +.PHONY: install-plone-6.0 +install-plone-6.0: config ## pip install Plone packages + @echo "$(GREEN)==> Setup Build$(RESET)" + bin/mxdev -c mx.ini + bin/pip install -r requirements-mxdev.txt + +.PHONY: install +install: install-plone-6.0 ## Install Plone 6.0 + +.PHONY: start +start: ## Start a Plone instance on localhost:8080 + PYTHONWARNINGS=ignore ./bin/runwsgi instance/etc/zope.ini + +.PHONY: console +console: ## Start a console on a Plone instance + PYTHONWARNINGS=ignore ./bin/zconsole debug instance/etc/zope.conf + +.PHONY: format +format: bin/tox ## Format the codebase according to our standards + @echo "$(GREEN)==> Format codebase$(RESET)" + bin/tox -e format + +.PHONY: lint +lint: ## check code style + bin/tox -e lint + +# Tests +.PHONY: test +test: bin/tox ## run tests + bin/tox -e test + +.PHONY: test-coverage +test-coverage: bin/tox ## run tests with coverage + bin/tox -e coverage diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 00000000..3bb2e326 --- /dev/null +++ b/constraints.txt @@ -0,0 +1 @@ +-c https://dist.plone.org/release/6.0.13/constraints.txt diff --git a/instance.yaml b/instance.yaml new file mode 100644 index 00000000..fe9d3149 --- /dev/null +++ b/instance.yaml @@ -0,0 +1,7 @@ +default_context: + initial_user_name: 'admin' + initial_user_password: 'admin' + + zcml_package_includes: ['plone.app.contenttypes'] + + db_storage: direct diff --git a/mx.ini b/mx.ini new file mode 100644 index 00000000..db2906f9 --- /dev/null +++ b/mx.ini @@ -0,0 +1,9 @@ +; This is a mxdev configuration file +; it can be used to override versions of packages already defined in the +; constraints files and to add new packages from VCS like git. +; to learn more about mxdev visit https://pypi.org/project/mxdev/ + +[settings] +main-package = -e .[test] +version-overrides = + plone.app.contenttypes >= 4.0.1.dev0 diff --git a/news/+setup.internal b/news/+setup.internal new file mode 100644 index 00000000..3ca94f9d --- /dev/null +++ b/news/+setup.internal @@ -0,0 +1,2 @@ +Setup local installation +[@ericof] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..da443200 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +-c constraints.txt From f5409885bb6bfdc3abd3f825770bf4749485805f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Andrei?= Date: Thu, 26 Sep 2024 11:20:07 +0200 Subject: [PATCH 2/2] Fix MANIFEST.in --- MANIFEST.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 74225c91..5993732e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,3 +8,9 @@ global-exclude *.pyc recursive-exclude news * exclude news + +include requirements.txt +include constraints.txt +include *.yaml +include Makefile +exclude *-mxdev.txt