Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Commit

Permalink
Complete Makefiles:
Browse files Browse the repository at this point in the history
- Automatic generation of the version
- Automatic completion of the about dialog

Signed-off-by: Jerome Flesch <[email protected]>
  • Loading branch information
jflesch committed Feb 11, 2018
1 parent 065cba8 commit 5fdd580
Show file tree
Hide file tree
Showing 14 changed files with 334 additions and 118 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repo/
*.flatpak
venv*/
*.pyo
_version.py

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
54 changes: 0 additions & 54 deletions AUTHORS

This file was deleted.

26 changes: 26 additions & 0 deletions AUTHORS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Code contributors is automatically completed by the Makefile

authors_ui = """
Mathieu Jourdan <[email protected]>
"""

authors_translators = """
French: Jerome Flesch <[email protected]>
German: Tristan Kohl (Mirodin) <[email protected]>
Ukrainian: Daniel Korostil <[email protected]>
"""

authors_documentation = """
Alain <[email protected]>
arthurlutz <[email protected]>
Christophe Delaere <[email protected]>
Christophe GERARDIN (RTDaemons) <[email protected]>
Daniel Hahler <[email protected]>
Davidbrcz <[email protected]>
Jehan <[email protected]>
lb1a <[email protected]>
Ludo <[email protected]>
Samuel Dorsaz <[email protected]>
Santiago Castro <[email protected]>
swap38 <[email protected]>
"""
76 changes: 68 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,91 @@ ALL_COMPONENTS = paperwork-backend paperwork-gtk

build: $(ALL_COMPONENTS:%=%_build)

clean: $(ALL_COMPONENTS:%=%_clean)

install: $(ALL_COMPONENTS:%=%_install)

install_py: $(ALL_COMPONENTS:%=%_install_py)

install_c: $(ALL_COMPONENTS:%=%_install_c)

uninstall: $(ALL_COMPONENTS:%=%_uninstall)

uninstall_py: $(ALL_COMPONENTS:%=%_uninstall_py)

uninstall_c: $(ALL_COMPONENTS:%=%_uninstall_c)

check: $(ALL_COMPONENTS:%=%_check)

test: $(ALL_COMPONENTS:%=%_test)

doc: $(ALL_COMPONENTS:%=%_doc)

release: $(ALL_COMPONENTS:%=%_release)

help:
@echo "make build: run 'python3 ./setup.py build' in all components"
@echo "make clean"
@echo "make help: display this message"
@echo "make install : run 'python3 ./setup.py install' on all components"
@echo "make release"
@echo "make uninstall : run 'pip3 uninstall -y (component)' on all components"
@echo "Components:" $(ALL_COMPONENTS:%=%_install)
@echo "Components:" ${ALL_COMPONENTS}

%_check:
echo "Checking $(@:%_check=%)"
make -C $(@:%_check=%) check

%_test:
echo "Checking $(@:%_test=%)"
make -C $(@:%_check=%) test

%_doc:
echo "Checking $(@:%_doc=%)"
make -C $(@:%_check=%) doc

%_build:
echo "Building $(@:%_build=%)"
(cd $(@:%_build=%) ; python3 ./setup.py build)
make -C $(@:%_build=%) build

%_clean:
echo "Building $(@:%_clean=%)"
make -C $(@:%_clean=%) clean

%_install:
echo "Installing $(@:%_install=%)"
(cd $(@:%_install=%) ; python3 ./setup.py install ${PIP_ARGS})
make -C $(@:%_install=%) install

%_build_py:
echo "Building $(@:%_build_py=%)"
make -C $(@:%_build=%) build_py

%_install_py:
echo "Installing $(@:%_install_py=%)"
make -C $(@:%_build=%) install_py

%_build_c:
echo "Building $(@:%_build_c=%)"
make -C $(@:%_build=%) build_c

%_install_c:
echo "Installing $(@:%_install_c=%)"
make -C $(@:%_build=%) install_c

%_uninstall:
echo "Uninstalling $(@:%_uninstall=%)"
pip3 uninstall -y $(subst -,_,$(@:%_uninstall=%))
make -C $(@:%_uninstall=%) uninstall

%_uninstall_py:
echo "Uninstalling $(@:%_uninstall_py=%)"
make -C $(@:%_uninstall=%) uninstall_py

%_uninstall_c:
echo "Uninstalling $(@:%_uninstall_c=%)"
make -C $(@:%_uninstall=%) uninstall_c

paperwork-gtk_uninstall:
echo "Uninstalling paperwork-gtk"
pip3 uninstall -y paperwork
%_release:
echo "Releasing $(@:%_release=%)"
make -C $(@:%_release=%) release

.PHONY: help build install uninstall
.PHONY: help build clean test check install install_py install_c uninstall uninstall_c uninstall_py release
84 changes: 84 additions & 0 deletions paperwork-backend/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
VERSION_FILE = paperwork_backend/_version.py

build: build_c build_py

install: install_py install_c

uninstall: uninstall_py

build_py: ${VERSION_FILE}
python3 ./setup.py build

build_c:

version: ${VERSION_FILE}

${VERSION_FILE}:
echo -n "version = \"" >| $@
echo -n $(shell git describe --always) >> $@
echo "\"" >> $@

doc:

check:
flake8 paperwork_backend

test:

exe:

release:
ifeq (${RELEASE}, )
@echo "You must specify a release version (make release RELEASE=1.2.3)"
else
@echo "Will release: ${RELEASE}"
@echo "Checking release is in ChangeLog ..."
grep ${RELEASE} ChangeLog
@echo "Releasing ..."
git tag -a ${RELEASE} -m ${RELEASE}
git push origin ${RELEASE}
make clean
make version
python3 ./setup.py sdist upload
@echo "All done"
endif

clean:
rm -f ${VERSION_FILE}
rm -rf build dist *.egg-info

install_py: ${VERSION_FILE}
python3 ./setup.py install
paperwork-shell chkdeps paperwork_backend

install_c:

uninstall_py:
pip3 uninstall -y paperwork-backend

uninstall_c:

help:
@echo "make build || make build_py"
@echo "make check"
@echo "make help: display this message"
@echo "make install || make install_py"
@echo "make uninstall || make uninstall_py"
@echo "make release"

.PHONY: \
build \
build_c \
build_py \
check \
doc \
exe \
help \
install \
install_c \
install_py \
release \
test \
uninstall \
uninstall_c \
version
4 changes: 4 additions & 0 deletions paperwork-backend/paperwork_backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os

from . import _version
from . import util

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -53,3 +54,6 @@ def init():
}
state['flatpak'] = init_flatpak()
return state


__version__ = _version.version
20 changes: 15 additions & 5 deletions paperwork-backend/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import os
import sys

from setuptools import setup, find_packages

Expand All @@ -12,12 +13,21 @@
"python-Levenshtein",
]

try:
with open("paperwork_backend/_version.py", "r") as file_descriptor:
version = file_descriptor.read().strip()
version = version.split(" ")[2][1:-1]
print("Paperwork-backend version: {}".format(version))
if "-" in version:
version = version.split("-")[0]
except FileNotFoundError:
print("ERROR: _version.py file is missing")
print("ERROR: Please run 'make version' first")
sys.exit(1)

setup(
name="paperwork-backend",
# if you change the version, don't forget to
# * update the ChangeLog file
# * update the download_url in this file
version="1.2.3",
version=version,
description=(
"Paperwork's backend"
),
Expand All @@ -36,7 +46,7 @@
keywords="documents",
url="https://github.com/openpaperwork/paperwork-backend",
download_url=("https://github.com/openpaperwork/paperwork-backend"
"/archive/1.2.3.tar.gz"),
"/archive/{}.tar.gz".format(version)),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: End Users/Desktop",
Expand Down
Loading

0 comments on commit 5fdd580

Please sign in to comment.