Skip to content

Commit

Permalink
Migrate to autotools
Browse files Browse the repository at this point in the history
The reasoning for this is that this is more a gnome application
than a python module and as such autotools is more integrated
to that ecosystem which allows for eaiser handling for:

- GResource
- GSettings
- Translations
- Appdata/Desktop files
- Icons

Fixes #61
  • Loading branch information
TingPing committed Oct 15, 2015
1 parent 9d316e3 commit 9eadb1f
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 163 deletions.
31 changes: 11 additions & 20 deletions .gitignore
@@ -1,22 +1,13 @@
__pycache__/
*.py[cod]
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
config/
*.patch
debian/
build-debian.sh
.project
.pydevproject
.settings/
bin/pithos
Makefile.in
Makefile
configure
missing
py-compile
m4/
config.*
autom4te.cache/
aclocal.m4
install-sh
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

69 changes: 69 additions & 0 deletions Makefile.am
@@ -0,0 +1,69 @@
ACLOCAL_AMFLAGS = -I m4

# ----------- pithos --------------

pithosdir = $(pythondir)/pithos/
pithos_PYTHON = $(wildcard pithos/*.py)

pandoradir = $(pithosdir)/pandora
pandora_PYTHON = $(wildcard pithos/pandora/*.py)

pluginsdir = $(pithosdir)/plugins
plugins_PYTHON = $(wildcard pithos/plugins/*.py)

pithosmediadir = $(pithosdir)/data/media
pithosmedia_DATA = \
$(wildcard pithos/data/media/*.svg) \
$(wildcard pithos/data/media/*.png)

pithosuidir = $(pithosdir)/data/ui
pithosui_DATA = \
$(wildcard pithos/data/ui/*.xml) \
$(wildcard pithos/data/ui/*.ui)

bin_SCRIPTS = bin/pithos
bin/pithos: bin/pithos.in
@$(MKDIR_P) bin
$(AM_V_GEN)sed \
-e s!\@prefix\@!$(prefix)! \
-e s!\@datadir\@!$(datadir)! \
-e s!\@pkgdatadir\@!$(pkgdatadir)! \
-e s!\@pkglibdir\@!$(pkglibdir)! \
-e s!\@localedir\@!$(localedir)! \
-e s!\@pythondir\@!$(pythondir)! \
-e s!\@pyexecdir\@!$(pyexecdir)! \
< $< > $@
@chmod a+x $@

# ------------ data ----------------

desktop_FILES = data/pithos.desktop
@DESKTOP_FILE_RULES@

appstream_XML = data/pithos.appdata.xml
@APPSTREAM_XML_RULES@

hicolor_scalabledir = $(datadir)/icons/hicolor/scalable/apps
hicolor_scalable_DATA = $(wildcard data/icons/hicolor/pithos*.svg)

hicolor_48dir = $(datadir)/icons/hicolor/48x48/apps
hicolor_48_DATA = $(wildcard data/icons/hicolor/pithos*.png)

ubuntu_lightdir = $(datadir)/icons/ubuntu-mono-light/apps/16
ubuntu_light_DATA = $(wildcard data/icons/ubuntu-mono-light/pithos*.svg)

ubuntu_darkdir = $(datadir)/icons/ubuntu-mono-dark/apps/16
ubuntu_dark_DATA = $(wildcard data/icons/ubuntu-mono-dark/pithos*.svg)

UPDATE_ICON_CACHE = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor || :

install-data-hook:
$(UPDATE_ICON_CACHE);

uninstall-hook:
$(UPDATE_ICON_CACHE);

CLEANFILES = $(bin_SCRIPTS)
EXTRA_DIST = license README.md autogen.sh requirements-osx.txt bin/pithos.in \
$(pithosui_DATA) $(pithosmedia_DATA) $(appstream_XML) $(desktop_FILES) \
$(hicolor_scalable_DATA) $(hicolor_48_DATA) $(ubuntu_light_DATA) $(ubuntu_dark_DATA)
25 changes: 25 additions & 0 deletions autogen.sh
@@ -0,0 +1,25 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.

srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.

(test -f $srcdir/configure.ac) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the top-level directory"
exit 1
}

aclocal --install -I m4 || exit 1
autoreconf --force --install -Wno-portability || exit 1

if [ "$NOCONFIGURE" = "" ]; then
$srcdir/configure "$@" || exit 1

if [ "$1" = "--help" ]; then exit 0 else
echo "Now type \`make\' to compile" || exit 1
fi
else
echo "Skipping configure process."
fi

set +x
16 changes: 16 additions & 0 deletions bin/pithos.in
@@ -0,0 +1,16 @@
#!/usr/bin/env python3

import os
import sys

sys.path.insert(1, '@pyexecdir@')
sys.path.insert(1, '@pythondir@')

srcdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if os.path.exists(os.path.join(srcdir, 'configure.ac')):
print('Running locally...')
sys.path.insert(1, srcdir)

if __name__ == "__main__":
from pithos import application
application.main()
23 changes: 23 additions & 0 deletions configure.ac
@@ -0,0 +1,23 @@
AC_PREREQ(2.68)
AC_INIT([pithos], [1.1.1], [https://github.com/pithos/pithos/issues],
[pithos], [https://pithos.github.io])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([pithos/__main__.py])

AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip foreign subdir-objects -Wall -Wno-portability])
AM_SILENT_RULES([yes])
AM_PATH_PYTHON([3.3])

DESKTOP_FILE
APPSTREAM_XML

AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT

echo "
$PACKAGE $VERSION

prefix: ${prefix}
"
27 changes: 0 additions & 27 deletions debug.py

This file was deleted.

86 changes: 86 additions & 0 deletions m4/appstream-xml.m4
@@ -0,0 +1,86 @@
# appstream-xml.m4
#
# serial 6

dnl APPSTREAM_XML
dnl Installs and validates AppData XML files.
dnl
dnl Call APPSTREAM_XML in configure.ac to check for the appstream-util tool.
dnl Add @APPSTREAM_XML_RULES@ to a Makefile.am to substitute the make rules. Add
dnl .appdata.xml files to appstream_XML in Makefile.am and they will be validated
dnl at make check time, if appstream-util is installed, as well as installed
dnl to the correct location automatically. Add --enable-appstream-util to
dnl DISTCHECK_CONFIGURE_FLAGS in Makefile.am to require valid AppData XML when
dnl doing a distcheck.
dnl
dnl Adding files to appstream_XML does not distribute them automatically.

AC_DEFUN([APPSTREAM_XML],
[
m4_pattern_allow([AM_V_GEN])
AC_ARG_ENABLE([appstream-util],
[AS_HELP_STRING([--disable-appstream-util],
[Disable validating AppData XML files during check phase])])
AS_IF([test "x$enable_appstream_validate" != "xno"],
[AC_PATH_PROG([APPSTREAM_UTIL], [appstream-util])
AS_IF([test "x$APPSTREAM_UTIL" = "x"],
[have_appstream_validate=no],
[have_appstream_validate=yes
AC_SUBST([APPSTREAM_UTIL])])],
[have_appstream_validate=no])
AS_IF([test "x$have_appstream_validate" != "xno"],
[appstream_validate=yes],
[appstream_validate=no
AS_IF([test "x$enable_appstream_validate" = "xyes"],
[AC_MSG_ERROR([AppData validation was requested but appstream-util was not found])])])
AC_SUBST([appstreamxmldir], [${datadir}/appdata])
APPSTREAM_XML_RULES='
.PHONY : uninstall-appstream-xml install-appstream-xml clean-appstream-xml
mostlyclean-am: clean-appstream-xml
%.appdata.valid: %.appdata.xml
$(AM_V_GEN) if test -f "$<"; then d=; else d="$(srcdir)/"; fi; \
if test -n "$(APPSTREAM_UTIL)"; \
then $(APPSTREAM_UTIL) --nonet validate $${d}$<; fi \
&& touch [$]@
check-am: $(appstream_XML:.appdata.xml=.appdata.valid)
uninstall-am: uninstall-appstream-xml
install-data-am: install-appstream-xml
.SECONDARY: $(appstream_XML)
install-appstream-xml: $(appstream_XML)
@$(NORMAL_INSTALL)
if test -n "$^"; then \
test -z "$(appstreamxmldir)" || $(MKDIR_P) "$(DESTDIR)$(appstreamxmldir)"; \
$(INSTALL_DATA) $^ "$(DESTDIR)$(appstreamxmldir)"; \
fi
uninstall-appstream-xml:
@$(NORMAL_UNINSTALL)
@list='\''$(appstream_XML)'\''; test -n "$(appstreamxmldir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e '\''s|^.*/||'\''`; \
test -n "$$files" || exit 0; \
echo " ( cd '\''$(DESTDIR)$(appstreamxmldir)'\'' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(appstreamxmldir)" && rm -f $$files
clean-appstream-xml:
rm -f $(appstream_XML:.appdata.xml=.appdata.valid)
'
_APPSTREAM_XML_SUBST(APPSTREAM_XML_RULES)
])

dnl _APPSTREAM_XML_SUBST(VARIABLE)
dnl Abstract macro to do either _AM_SUBST_NOTMAKE or AC_SUBST
AC_DEFUN([_APPSTREAM_XML_SUBST],
[
AC_SUBST([$1])
m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([$1])])
]
)
102 changes: 102 additions & 0 deletions m4/desktop.m4
@@ -0,0 +1,102 @@
# desktop.m4
#
# serial 4

dnl DESKTOP_VALIDATE
dnl Validates and installs desktop files.
dnl
dnl To use:
dnl 1. Call DESKTOP_FILE in configure.ac to check for the desktop-file-utils tools.
dnl 2. Add @DESKTOP_FILE_RULES@ to a Makefile.am to substitute the make rules.
dnl 3. Add .desktop files to desktop_FILES in Makefile.am and they will be validated
dnl at make check time and installed on make install.
dnl 4. Add --enable-desktop-validate to DISTCHECK_CONFIGURE_FLAGS
dnl in Makefile.am to require valid desktop file when doing a distcheck.
dnl
dnl On installation desktop-file-install will be used when available which also
dnl rebuilds the mime info cache. After install update-desktop-database is called.
dnl
dnl Author: TingPing <tingping@tingping.se>
dnl Based upon appdata-xml.m4

AC_DEFUN([DESKTOP_FILE],
[
m4_pattern_allow([AM_V_GEN])
AC_ARG_ENABLE([desktop-validate],
[AS_HELP_STRING([--disable-desktop-validate],
[Disable validating desktop files during check phase])])
AS_IF([test "x$enable_desktop_validate" != "xno"],
[AC_PATH_PROG([DESKTOP_FILE_VALIDATE], [desktop-file-validate])
AS_IF([test "x$DESKTOP_FILE_VALIDATE" = "x"],
[have_desktop_validate=no],
[have_desktop_validate=yes
AC_SUBST([DESKTOP_FILE_VALIDATE])])],
[have_desktop_validate=no])
AC_PATH_PROG([UPDATE_DESKTOP_DATABASE], [update-desktop-database])
AS_IF([test "x$UPDATE_DESKTOP_DATABASE" != "x"], [AC_SUBST([UPDATE_DESKTOP_DATABASE])])
AC_PATH_PROG([DESKTOP_FILE_INSTALL], [desktop-file-install])
AS_IF([test "x$DESKTOP_FILE_INSTALL" != "x"], [AC_SUBST([DESKTOP_FILE_INSTALL])])
AS_IF([test "x$have_desktop_validate" != "xno"],
[desktop_validate=yes],
[desktop_validate=no
AS_IF([test "x$enable_desktop_validate" = "xyes"],
[AC_MSG_ERROR([Desktop validation was requested but desktop-file-validate was not found])])])
AC_SUBST([desktopfiledir], [${datadir}/applications])
DESKTOP_FILE_RULES='
.PHONY : uninstall-desktop-file install-desktop-file clean-desktop-file
mostlyclean-am: clean-desktop-file
%.desktop.valid: %.desktop
$(AM_V_GEN) if test -f "$<"; then d=; else d="$(srcdir)/"; fi; \
if test -n "$(DESKTOP_FILE_VALIDATE)"; \
then $(DESKTOP_FILE_VALIDATE) $${d}$<; fi \
&& touch [$]@
check-am: $(desktop_FILES:.desktop=.desktop.valid)
uninstall-am: uninstall-desktop-file
install-data-am: install-desktop-file
.SECONDARY: $(desktop_FILES)
install-desktop-file: $(desktop_FILES)
@$(NORMAL_INSTALL)
if test -n "$^"; then \
test -z "$(desktopfiledir)" || $(MKDIR_P) "$(DESTDIR)$(desktopfiledir)"; \
if test -n "$(DESKTOP_FILE_INSTALL)"; then \
$(DESKTOP_FILE_INSTALL) --dir="$(DESTDIR)$(desktopfiledir)" --mode=644 $^; \
else \
$(INSTALL_DATA) $^ "$(DESTDIR)$(desktopfiledir)"; \
fi; \
#test -z "$(UPDATE_DESKTOP_DATABASE)" || $(UPDATE_DESKTOP_DATABASE) -q "$(DESTDIR)$(desktopfiledir)"; \
fi
uninstall-desktop-file:
@$(NORMAL_UNINSTALL)
@list='\''$(desktop_FILES)'\''; test -n "$(desktopfiledir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e '\''s|^.*/||'\''`; \
test -n "$$files" || exit 0; \
echo " ( cd '\''$(DESTDIR)$(desktopfiledir)'\'' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(desktopfiledir)" && rm -f $$files; \
#test -z "$(UPDATE_DESKTOP_DATABASE)" || $(UPDATE_DESKTOP_DATABASE) -q "$(DESTDIR)$(desktopfiledir)"
clean-desktop-file:
rm -f $(desktop_FILES:.desktop=.desktop.valid)
'
_DESKTOP_FILE_SUBST(DESKTOP_FILE_RULES)
])

dnl _DESKTOP_FILE_SUBST(VARIABLE)
dnl Abstract macro to do either _AM_SUBST_NOTMAKE or AC_SUBST
AC_DEFUN([_DESKTOP_FILE_SUBST],
[
AC_SUBST([$1])
m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([$1])])
]
)

0 comments on commit 9eadb1f

Please sign in to comment.