summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-23 23:24:06 +0100
committerFlorian Dold <florian@dold.me>2023-02-23 23:24:20 +0100
commit245e2ae15c1f770bf6e8953fe951795a9d2461ea (patch)
treece21a2821ba22b64216d3cfc3a261f1bfb79db05
parent8a66f6c11d5cb2c23be3fe263a5e9b85f5df8da0 (diff)
downloadtaler-merchant-demos-245e2ae15c1f770bf6e8953fe951795a9d2461ea.tar.gz
taler-merchant-demos-245e2ae15c1f770bf6e8953fe951795a9d2461ea.tar.bz2
taler-merchant-demos-245e2ae15c1f770bf6e8953fe951795a9d2461ea.zip
use venv for installationv0.9.2
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules3
-rw-r--r--Makefile22
-rwxr-xr-xbootstrap29
-rw-r--r--build-system/configure.py21
m---------build-system/taler-build-scripts0
-rwxr-xr-xconfigure129
7 files changed, 110 insertions, 95 deletions
diff --git a/.gitignore b/.gitignore
index 23a69e0..845d547 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
translations/*/LC_MESSAGES/messages.mo
config.mk
+.config.mk
*~
.sass-cache
dist/
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..527bc74
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "build-system/taler-build-scripts"]
+ path = build-system/taler-build-scripts
+ url = git://git.taler.net/build-common
diff --git a/Makefile b/Makefile
index 5e3adff..403c64d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
install_global=false
--include config.mk
+-include .config.mk
version := $(shell poetry version | awk '{ print $$2 }')
@@ -10,12 +10,6 @@ all:
.PHONY: install
-ifeq ($(install_global), true)
-install: install-global
-else
-install: install-local
-endif
-
setup-arch:
# TODO: We should probabally add some form of "ignore me if already completed"
set -e
@@ -56,15 +50,15 @@ setup-deb:
pip install poetry
echo "Done!"
-.PHONY: install-global
-install-global: compile
- poetry build -f wheel
- pip3 install --upgrade --ignore-installed "dist/talermerchantdemos-$(version)-py3-none-any.whl"
+my_venv = $(prefix)/lib/taler-merchant-demos/venv
-.PHONY: install-local
-install-local: compile
+.PHONY: install
+install: compile
+ mkdir -p $(prefix)/bin
poetry build -f wheel
- pip3 install --upgrade --ignore-installed --user "dist/talermerchantdemos-$(version)-py3-none-any.whl"
+ python3 -m venv $(my_venv)
+ $(my_venv)/bin/pip3 install --upgrade --ignore-installed "dist/talermerchantdemos-$(version)-py3-none-any.whl"
+ ln -sf $(my_venv)/bin/taler-merchant-demos $(prefix)/bin/taler-merchant-demos
# run testcases
.PHONY: check
diff --git a/bootstrap b/bootstrap
index fbf99b5..09a6fa0 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,5 +1,28 @@
#!/bin/sh
-# This bootstrap script currently does nothing, but
-# is there for uniformity, since almost all our other
-# repos have a bootstrap script.
+# Bootstrap the repository. Used when the repository is checked out from git.
+# When using the source tarball, running this script is not necessary.
+
+set -eu
+
+if ! git --version >/dev/null; then
+ echo "git not installed"
+ exit 1
+fi
+
+git submodule update --init
+
+copy_configure() {
+ src=$1
+ dst=$2
+ rm -f $dst
+ cp $src $dst
+ # Try making the configure script read-only to prevent
+ # accidental changes in the wrong place.
+ chmod ogu-w $dst || true
+}
+
+# To enable a GNU-style build system, we copy a configure
+# script to each package that can be installed
+our_configure=build-system/taler-build-scripts/configure
+copy_configure "$our_configure" ./configure
diff --git a/build-system/configure.py b/build-system/configure.py
new file mode 100644
index 0000000..f8e01aa
--- /dev/null
+++ b/build-system/configure.py
@@ -0,0 +1,21 @@
+# This configure.py file is places in the public domain.
+
+# Configure the build directory.
+# This file is invoked by './configure' and should usually not be invoked
+# manually.
+
+import talerbuildconfig as tbc
+import sys
+import shutil
+
+if getattr(tbc, "serialversion", 0) < 2:
+ print("talerbuildconfig outdated, please update the build-common submodule and/or bootstrap")
+ sys.exit(1)
+
+b = tbc.BuildConfig()
+b.enable_prefix()
+b.enable_configmk(dotfile=True)
+b.add_tool(tbc.PosixTool("make"))
+b.add_tool(tbc.PosixTool("zip"))
+b.add_tool(tbc.PosixTool("find"))
+b.run()
diff --git a/build-system/taler-build-scripts b/build-system/taler-build-scripts
new file mode 160000
+Subproject 23538677f6c6be2a62f38dc6137ecdd1c76b7b1
diff --git a/configure b/configure
index 469bad7..ad724cc 100755
--- a/configure
+++ b/configure
@@ -1,87 +1,60 @@
-#!/usr/bin/env bash
-
-set -eu
-
-usage() {
- echo "Usage: ./configure [OPTION]"
- echo
- echo "Configuration:"
- echo " -h, --help display this help and exit"
- echo
- echo "Installation directories:"
- echo " --destination=[local|global] install Python package locally or globally"
-}
-
-
-# -allow a command to fail with !’s side effect on errexit
-# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
-! getopt --test > /dev/null
-if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
- echo 'getopt not available'
- exit 1
+#!/bin/sh
+
+# This file is part of GNU Taler.
+# (C) 2020 Taler Systems S.A.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
+# LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+# THIS SOFTWARE.
+#
+# SPDX-License-Identifier: 0BSD
+
+# This script checks if a suitable python3 executable is installed and then
+# executes the actual configure logic written in Python.
+
+build_system_dir=build-system
+
+if ! test -d "$build_system_dir"; then
+ # Maybe this is not a top-level configure invocation
+ # For monorepos, try location from top-level
+ build_system_dir=../../build-system
fi
-LONGOPTS=destination:,help
-OPTIONS=h
-
-! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
-if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
- # e.g. return value is 1
- # then getopt has complained about wrong arguments to stdout
- exit 2
+if ! test -d "$build_system_dir"; then
+ echo "fatal error: build-system directory not found" >&2
+ echo "hint: are you running this script from the right directory?" >&2
+ exit 1
fi
-# read getopt’s output this way to handle the quoting right:
-eval set -- "$PARSED"
-
-destination="local"
-
-while true; do
- case "$1" in
- --destination)
- destination="$2"
- shift 2
- ;;
- -h|--help)
- usage
- exit 1
- ;;
- --)
- shift
- break
- ;;
- *)
- echo "Programming error"
- exit 3
- ;;
- esac
-done
-
-case "$destination" in
- local)
- install_global=false
- ;;
- global)
- install_global=true
- ;;
- *)
- echo "Destination (--destination) must be 'local' or 'global', paths are not allowed."
- exit 3
- ;;
-esac
-
-cat << EOF > config.mk
-# this file is autogenerated by ./configure
-install_global=$install_global
-EOF
-
-
-if ! python3 --version &>/dev/null; then
- echo 'Error: python3 missing'
+scriptpath=$build_system_dir/taler-build-scripts
+if ! test -d "$build_system_dir"; then
+ echo "fatal error: taler-build-scripts directory not found at $scriptpath" >&2
+ echo "hint: did you run './bootstrap'?" >&2
exit 1
fi
-if ! pip3 --version &>/dev/null; then
- echo 'Error: pip3 missing'
+export TALERBUILDSYSTEMDIR=$build_system_dir
+
+# Check that the python3 executable is on the PATH.
+# This follows PEP 394 (https://www.python.org/dev/peps/pep-0394/).
+if ! python3 --version >/dev/null 2>&1; then
+ echo "error: python3 not found" >&2
exit 1
fi
+
+# Let python3 check that its own version is okay for us.
+python3 "$scriptpath/pyvercheck.py" || exit $?
+
+# Allow Python to find libraries that are checked into the build system git.
+export PYTHONPATH="$scriptpath:${PYTHONPATH:-}"
+
+# Call configure.py, assuming all went well.
+python3 $TALERBUILDSYSTEMDIR/configure.py "$@"