Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify packaging and publishing process #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 197 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,199 @@
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

### Linux ###
*~
__env__

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Project ###
# Package results
pkg/
126 changes: 126 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Variables
SOFTWARE = $(shell awk -F'[ ="]+' '$$1 == "name" {print $$2;exit}' pyproject.toml)
DESCRIPTION = "directory cover thumbnailer for GTK based file viewers"
VERSION := $(shell awk -F'[ ="]+' '$$1 == "version" {print $$2;exit}' pyproject.toml)
DATE := $(shell date +"%a, %d %b %Y")

INSTALL_PATH ?= /
PACKAGE_PATH ?= ./pkg
LOGFILE ?= install.log

# Tools
PYTHON ?= /usr/bin/python3
PIP := $(PYTHON) -m pip
PKG_CONFIG := pkg-config
GTK_VERSION := gtk+-3.0
GI_MODULE := gi

# Colors for output
RED := \033[1;31m
GREEN := \033[1;32m
NORMAL := \033[0m
BOLD := \033[1m

# Targets
.PHONY: all install remove locale check_dep

all: help

help:
@echo "$(SOFTWARE) v$(VERSION) - $(DESCRIPTION)"
@echo ""
@echo "Targets:"
@echo -e "\t- $(BOLD)install$(NORMAL) : Install $(SOFTWARE)"
@echo -e "\t- $(BOLD)remove$(NORMAL) : Remove $(SOFTWARE)"
@echo -e "\t- $(BOLD)locale$(NORMAL) : Extract strings for translation template"
@echo -e "\t- $(BOLD)package$(NORMAL) : Generate a package distribution"
@echo -e "\t- $(BOLD)publish$(NORMAL) : Publish current version to git"

check_build_deps:
@echo -e "$(BOLD) * Checking system dependencies...$(NORMAL)"
@test -x /usr/bin/xgettext || { echo -e "gettext: $(RED)Missing$(NORMAL)" && exit 1; }
@echo -e "gettext: $(GREEN)Found$(NORMAL)"

check_run_deps:
@$(PYTHON) --version 2>&1 | grep "^Python 3" >/dev/null || { echo -e "Python 3: $(RED)Missing$(NORMAL)" && exit 1; }
@echo -e "Python 3: $(GREEN)Found$(NORMAL)"
@$(PYTHON) -c "import $(GI_MODULE)" 2>/dev/null || { echo -e "PyGObject: $(RED)Missing$(NORMAL)"; exit 1; }
@echo -e "PyGObject: $(GREEN)Found$(NORMAL)"
@$(PKG_CONFIG) --exists $(GTK_VERSION) || { echo -e "GTK+3: $(RED)Missing$(NORMAL)"; exit 1; }
@echo -e "GTK+3: $(GREEN)Found$(NORMAL)"

locale: check_build_deps
@echo "$(BOLD) * Extracting strings for translation...$(NORMAL)"
@mkdir -pv ./locale/
@xgettext -k_ -kN_ -o ./locale/cover-thumbnailer-gui.pot ./cover-thumbnailer-gui.py ./share/cover-thumbnailer-gui.glade
@for lcfile in $$(find ./locale/ -name "*.po"); do \
echo -n " * $$lcfile"; \
msgmerge --update $$lcfile ./locale/cover-thumbnailer-gui.pot; \
done

_install: locale
@echo -e "$(BOLD) * $(action) $(SOFTWARE)...$(NORMAL)"
@mkdir -pv $(INSTALL_PATH)/usr/bin || { echo -e "$(RED)Error creating directory$(NORMAL)" && exit 1; }
@sed "s/{{VERSION}}/$(VERSION)/g" ./cover-thumbnailer.py > $(INSTALL_PATH)/usr/bin/cover-thumbnailer
@chmod 755 $(INSTALL_PATH)/usr/bin/cover-thumbnailer
@sed "s/{{VERSION}}/$(VERSION)/g" ./cover-thumbnailer-gui.py > $(INSTALL_PATH)/usr/bin/cover-thumbnailer-gui
@chmod 755 $(INSTALL_PATH)/usr/bin/cover-thumbnailer-gui

@echo -e "$(BOLD) * Creating man entries...$(NORMAL)"
@mkdir -pv $(INSTALL_PATH)/usr/share/man/man1
@sed "s/{{VERSION}}/$(VERSION)/g" ./man/cover-thumbnailer.1\
| sed "s/{{DATE}}/$(DATE)/g" > $(INSTALL_PATH)/usr/share/man/man1/cover-thumbnailer.1
@gzip --best -f $(INSTALL_PATH)/usr/share/man/man1/cover-thumbnailer.1
@sed "s/{{VERSION}}/$(VERSION)/g" ./man/cover-thumbnailer-gui.1\
| sed "s/{{DATE}}/$(DATE)/g" > $(INSTALL_PATH)/usr/share/man/man1/cover-thumbnailer-gui.1
@gzip --best -f $(INSTALL_PATH)/usr/share/man/man1/cover-thumbnailer-gui.1

@echo -e "$(BOLD) * Generating locales...$(NORMAL)"
@for file in $$(find ./locale -name "*.po"); do \
lang=$$(echo $$file | sed -r 's#./locale/(.*).po#\1#g'); \
mkdir -pv $(INSTALL_PATH)/usr/share/locale/$$lang/LC_MESSAGES; \
msgfmt $$file -o $(INSTALL_PATH)/usr/share/locale/$$lang/LC_MESSAGES/cover-thumbnailer-gui.mo; \
done

@echo -e "$(BOLD) * $(action) application data...$(NORMAL)"
@mkdir -pv $(INSTALL_PATH)/usr/share/cover-thumbnailer
@cp -rv ./share/* $(INSTALL_PATH)/usr/share/cover-thumbnailer
@mkdir -pv $(INSTALL_PATH)/usr/share/doc/cover-thumbnailer
@cp -v ./README.md $(INSTALL_PATH)/usr/share/doc/cover-thumbnailer

@echo -e "$(BOLD) * $(action) application files...$(NORMAL)"
@mkdir -pv $(INSTALL_PATH)/usr/share/applications
@cp -v ./freedesktop/cover-thumbnailer-gui.desktop $(INSTALL_PATH)/usr/share/applications/cover-thumbnailer-gui.desktop
@mkdir -pv $(INSTALL_PATH)/usr/share/thumbnailers
@cp -v ./freedesktop/cover.thumbnailer $(INSTALL_PATH)/usr/share/thumbnailers/cover.thumbnailer
@echo -e "$(GREEN)$(SOFTWARE) $(action_end) successfully$(NORMAL)"

install: action:="Installing"
install: action_end:="installed"
install: check_run_deps _install

remove:
@echo "$(BOLD) * Removing $(SOFTWARE)...$(NORMAL)"
@rm -fv /usr/share/applications/cover-thumbnailer-gui.desktop
@rm -rfv /usr/share/cover-thumbnailer
@rm -rfv /usr/share/doc/cover-thumbnailer
@rm -vf /usr/share/man/man1/cover-thumbnailer.1.gz
@rm -vf /usr/share/man/man1/cover-thumbnailer-gui.1.gz
@find /usr/share/locale/ -name cover-thumbnailer-gui.mo -exec rm -v '{}' ';'
@rm -vf /usr/bin/cover-thumbnailer
@rm -vf /usr/bin/cover-thumbnailer-gui
@rm -vf /usr/share/thumbnailers/cover.thumbnailer
@echo "$(GREEN)$(SOFTWARE) removed successfully$(NORMAL)"

package: INSTALL_PATH:=$(PACKAGE_PATH)
package: action:="Packaging"
package: action_end:="packaged"
package:
@mkdir -pv $(PACKAGE_PATH)
package: _install

clean:
@rm -rf $(PACKAGE_PATH)

publish:
@git commit -m v$(VERSION) && git tag v$(VERSION) && git push && git push --tags
7 changes: 1 addition & 6 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ This file is a memo for the maintainer.
1. Release
----------

* Update version number in ``cover-thumbnailer.py`` (``__version__`` var)
* Update version number in ``cover-thumbnailer-gui.py`` (``__version__`` var)
* Update version number in ``install.sh`` (comment)
* Update version number and date in ``man/cover-thumbnailer.1`` (header)
* Update version number and date in ``man/cover-thumbnailer-gui.1`` (header)
* Edit / update changelog in ``README.md``
* Commit / tag (``git commit -m vX.Y.Z && git tag vX.Y.Z && git push && git push --tags``)
* Publish (``make publish``)


2. Publish Github Release
Expand Down
2 changes: 1 addition & 1 deletion cover-thumbnailer-gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
A GUI for easily configuring Cover Thumbnailer.
"""

__version__ = "0.10.1"
__version__ = "{{VERSION}}"
__author__ = "Fabien Loison <http://www.flozz.fr/>"
__copyright__ = "Copyright © 2009 - 2023 Fabien LOISON"
__appname__ = "cover-thumbnailer-gui"
Expand Down
2 changes: 1 addition & 1 deletion cover-thumbnailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
cover-thumbnailer <directory's path> <output thumbnail's path>
"""

__version__ = "0.10.1"
__version__ = "{{VERSION}}"
__author__ = "Fabien Loison <http://www.flozz.fr/>"
__copyright__ = "Copyright © 2009 - 2023 Fabien LOISON"

Expand Down
Loading