Skip to content

Commit

Permalink
Merge pull request #202 from jim-easterbrook/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
jim-easterbrook committed Jun 28, 2023
2 parents ca22213 + f009eaa commit 2fa75d2
Show file tree
Hide file tree
Showing 21 changed files with 240 additions and 305 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ pip-log.txt

# Extras
MANIFEST
photini.pro
/doc
/doctrees
/src/lang/en/LC_MESSAGES
/utils/make_icons/*.pam
/src/photini/data/lang
/src/photini/_version.py
22 changes: 15 additions & 7 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# ignore setuptools' idea of what should be included
exclude *
recursive-exclude * *
# setuptools-scm automatically includes everything that's in git
# ignore stuff that's not required to build photini
recursive-exclude .github *
recursive-exclude .tx *
recursive-exclude src/doc *
recursive-exclude src/lang *
recursive-exclude src/Photini.egg-info *
recursive-exclude tests *
recursive-exclude utils *
exclude .gitignore .readthedocs.yaml transifex.yml src/run_photini.py

# add the minimum needed to install Photini
include CHANGELOG.txt LICENSE.txt MANIFEST.in pyproject.toml README.rst setup.py
recursive-include src/photini *
global-exclude *~ *.pyc
# add customised build stuff
recursive-include custom_build *.py

# add compiled translations
recursive-include src/photini/data/lang *.qm
54 changes: 54 additions & 0 deletions custom_build/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Photini - a simple photo metadata editor.
# http://github.com/jim-easterbrook/Photini
# Copyright (C) 2023 Jim Easterbrook jim@jim-easterbrook.me.uk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
import subprocess

from setuptools import build_meta as _orig
from setuptools.build_meta import *


def build_lang():
src_dir = os.path.join('src', 'lang')
dst_dir = os.path.join('src', 'photini', 'data', 'lang')
if os.path.exists(dst_dir) and not os.path.exists(src_dir):
# probably building wheel from sdist, no need to compile
return
print('running build_lang')
os.makedirs(dst_dir, exist_ok=True)
for lang in os.listdir(src_dir):
src_file = os.path.join(src_dir, lang, 'photini.ts')
if not os.path.exists(src_file):
continue
dst_file = os.path.join(dst_dir, 'photini.' + lang + '.qm')
if (os.path.exists(dst_file) and
os.stat(dst_file).st_mtime >= os.stat(src_file).st_mtime):
continue
print('compiling {} -> {}'.format(src_file, dst_file))
subprocess.check_call([
'lrelease-qt5', '-silent', src_file, '-qm', dst_file])


def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
build_lang()
return _orig.build_wheel(wheel_directory, config_settings=config_settings,
metadata_directory=metadata_directory)


def build_sdist(sdist_directory, config_settings=None):
build_lang()
return _orig.build_sdist(sdist_directory, config_settings=config_settings)
47 changes: 36 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# Photini - a simple photo metadata editor.
# http://github.com/jim-easterbrook/Photini
# Copyright (C) 2023 Jim Easterbrook jim@jim-easterbrook.me.uk
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.

[build-system]
requires = ["setuptools >= 59.6"]
build-backend = "setuptools.build_meta"
requires = ["setuptools >= 59.6", "setuptools_scm[toml]>=6.2", "toml"]
#build-backend = "setuptools.build_meta"
build-backend = "backend"
backend-path = ["custom_build"]

[project]
name = "Photini"
Expand Down Expand Up @@ -29,15 +49,19 @@ dependencies = [
dynamic = ["version"]

[project.optional-dependencies]
flickr = [
"requests-oauthlib >= 1.0", "requests-toolbelt >= 0.9", "keyring >= 7.0"]
google = ["requests-oauthlib >= 1.0", "keyring >= 7.0"]
flickr = ["photini[keyring,requests-oauthlib,requests-toolbelt]"]
google = ["photini[keyring,requests-oauthlib]"]
importer = ["gphoto2 >= 1.8; platform_system != 'Windows'"]
ipernity = ["requests-toolbelt >= 0.9", "keyring >= 7.0"]
pixelfed = [
"requests-oauthlib >= 1.0", "requests-toolbelt >= 0.9", "keyring >= 7.0"]
ipernity = ["photini[keyring,requests-toolbelt]"]
pixelfed = ["photini[keyring,requests-oauthlib,requests-toolbelt]"]
spelling = ["pyenchant >= 2.0"]
# set versions of common packages
keyring = ["keyring >= 7.0"]
requests-oauthlib = ["requests-oauthlib >= 1.0"]
requests-toolbelt = ["requests-toolbelt >= 0.9"]
# the following are intended for use by the photini-configure script
PyQt5 = ["PyQt5 >= 5.9", "PyQtWebEngine >= 5.12"]
PyQt6 = ["PyQt6 >= 6.2", "PyQt6-WebEngine >= 6.2"]
PySide2 = ["PySide2 >= 5.11"]
PySide6 = ["PySide6 >= 6.2"]
gpxpy = ["gpxpy >= 1.3.5"]
Expand All @@ -59,9 +83,10 @@ photini = "photini.editor:main"
[tool.setuptools]
zip-safe = false

[tool.setuptools.dynamic]
version = {attr = "photini.__version__"}

[tool.setuptools.packages.find]
where = ["src"]
exclude = ["doc*", "lang*"]

[tool.setuptools_scm]
write_to = "src/photini/_version.py"
version_scheme = "post-release"
108 changes: 26 additions & 82 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,103 +16,47 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.

import os
from setuptools import setup
from setuptools import __version__ as setuptools_version


# list dependency packages
install_requires = ['appdirs', 'cachetools', 'chardet', 'exiv2', 'requests']
extras_require = {
'basic' : ['PySide2'],
'flickr' : ['requests-oauthlib', 'requests-toolbelt', 'keyring'],
'google' : ['requests-oauthlib', 'keyring'],
'importer' : ['gphoto2; platform_system != "Windows"'],
'ipernity' : ['requests-toolbelt', 'keyring'],
'pixelfed' : ['requests-oauthlib', 'requests-toolbelt', 'keyring'],
'spelling' : ['pyenchant'],
# the following are intended for use by the photini-configure script
'PyQt5' : ['PyQt5', 'PyQtWebEngine'],
'PyQt6' : ['PyQt6', 'PyQt6-WebEngine'],
'PySide2' : ['PySide2'],
'PySide6' : ['PySide6'],
'gpxpy' : ['gpxpy'],
'Pillow' : ['Pillow'],
}
extras_require['extras'] = list(
set(extras_require['flickr']) | set(extras_require['google']) |
set(extras_require['importer']) | set(extras_require['ipernity']) |
set(extras_require['spelling']) | set(['gpxpy', 'Pillow']))
extras_require['win7'] = list(
set(extras_require['basic']) | set(extras_require['extras']))
extras_require['win10'] = extras_require['win7']

# add version numbers
min_version = {
'appdirs': '1.3', 'cachetools': '3.0', 'chardet': '3.0', 'exiv2': '0.14',
'gphoto2': '1.8.0', 'gpxpy': '1.3.5', 'keyring': '7.0', 'Pillow': '2.0.0',
'pyenchant': '2.0', 'PyQt5': '5.9', 'PyQtWebEngine': '5.12', 'PyQt6': '6.2',
'PyQt6-WebEngine': '6.2', 'PySide2': '5.11.0', 'PySide6': '6.2.0',
'requests': '2.4.0', 'requests-oauthlib': '1.0', 'requests-toolbelt': '0.9',
}

def add_version(package):
package, sep, marker = package.partition(';')
return '{} >= {}'.format(package, min_version[package]) + sep + marker

for option in extras_require:
extras_require[option] = [add_version(x) for x in extras_require[option]]
install_requires = [add_version(x) for x in install_requires]

package_data = []
for root, dirs, files in os.walk('src/photini/data/'):
package_data += [
os.path.join(root.replace('src/photini/', ''), x) for x in files]
url = 'https://github.com/jim-easterbrook/Photini'

if tuple(map(int, setuptools_version.split('.'))) >= (61, 0):
# use metadata from pyproject.toml
# use metadata from pyproject.toml directly
setup()
else:
# read current version info without importing package
with open('src/photini/__init__.py') as f:
exec(f.read())
import os

with open('README.rst') as ldf:
# get metadata from pyproject.toml
import toml
metadata = toml.load('pyproject.toml')

with open(metadata['project']['readme']) as ldf:
long_description = ldf.read()

setup(name = 'Photini',
version = __version__,
author = 'Jim Easterbrook',
author_email = 'jim@jim-easterbrook.me.uk',
url = url,
download_url = url + '/archive/' + __version__ + '.tar.gz',
description = 'Simple photo metadata editor',
package_data = []
for root, dirs, files in os.walk('src/photini/data/'):
package_data += [
os.path.join(root.replace('src/photini/', ''), x) for x in files]

setup(name = metadata['project']['name'],
author = metadata['project']['authors'][0]['name'],
author_email = metadata['project']['authors'][0]['email'],
url = metadata['project']['urls']['homepage'],
description = metadata['project']['description'],
long_description = long_description,
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Win32 (MS Windows)',
'Environment :: X11 Applications :: Qt',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Topic :: Multimedia :: Graphics',
],
license = 'GPLv3+',
classifiers = metadata['project']['classifiers'],
license = metadata['project']['license']['text'],
packages = ['photini'],
package_dir = {'' : 'src'},
package_data = {'photini' : package_data},
entry_points = {
'console_scripts' : [
'photini-configure = photini.scripts:configure',
'photini-post-install = photini.scripts:post_install',
],
'{} = {}'.format(k, v)
for k, v in metadata['project']['scripts'].items()],
'gui_scripts' : [
'photini = photini.editor:main',
],
'{} = {}'.format(k, v)
for k, v in metadata['project']['gui-scripts'].items()],
},
install_requires = install_requires,
extras_require = extras_require,
zip_safe = False,
install_requires = metadata['project']['dependencies'],
extras_require = metadata['project']['optional-dependencies'],
zip_safe = metadata['tool']['setuptools']['zip-safe'],
)
11 changes: 6 additions & 5 deletions src/lang/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Reminders for what to do when translations are updated.
When program source changes::

git checkout main # switch to main branch
python3 utils/lang_update.py -s -t # update translations from source
python3 utils/lang_update.py -s # update translations from source
git push # push updated translations to GitHub
tx push -s # push updated translations to Transifex

Expand All @@ -25,15 +25,15 @@ Then download updated translations::

git checkout main # switch to main branch
git pull # fetch new content
python3 utils/lang_update.py -s -t # reformat translations if needed
python3 utils/lang_update.py -s # reformat translations if needed
git push # push updated translations to GitHub
tx push -t # push updated translations to Transifex

When there is new content on Transifex in language xx::

git checkout main # switch to main branch
tx pull -l xx -f # fetch new content from Transifex
python3 utils/lang_update.py -s -t -l xx # reformat translations if needed
python3 utils/lang_update.py -s -l xx # reformat translations if needed
python3 utils/lang_update.py -d -s -l xx # reformat translations if needed
git push # push updated translations to GitHub

Expand All @@ -43,7 +43,7 @@ Edit translation locally::
git pull # fetch new content
python3 utils/lang_update.py -l xx # update from source, with line numbers
pyside6-linguist src/lang/xx/photini.ts # edit translation of language xx
python3 utils/lang_update.py -s -t -l xx # remove line numbers
python3 utils/lang_update.py -s -l xx # remove line numbers
git push # push updated translation to GitHub
tx push -t -l xx # push updated translations to Transifex

Expand All @@ -59,4 +59,5 @@ Plurals

Qt Linguist and Transifex have different ideas about how many plural forms some languages have.
For example, Transifex expects French to have three plurals ``1``, ``many``, and ``other``, but Qt Linguist expects two ``singular`` and ``plural``.
The ``lang_update.py`` adds empty plural forms to satisfy Transifex (the ``-t`` option) and removes them before running Qt tools.
Transifex provides languages such as ``Italian (QT FILETYPE)`` that use Qt's plural definitions.
Weblate just considers the missing plural forms to be an error that can be ignored.
24 changes: 22 additions & 2 deletions src/photini/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
## Photini - a simple photo metadata editor.
## http://github.com/jim-easterbrook/Photini
## Copyright (C) 2023 Jim Easterbrook jim@jim-easterbrook.me.uk
##
## This program is free software: you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation, either version 3 of the
## License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see
## <http://www.gnu.org/licenses/>.

"""Full documentation is at https://photini.readthedocs.io/"""

__version__ = '2023.6.0'
build = '2731 (b059f91)'
from photini._version import version as __version__

__version__, _sep, build = __version__.partition('+')
build = build or 'release'
11 changes: 0 additions & 11 deletions src/photini/data/linux/photini.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,3 @@ GenericName=Photini photo metadata editor
Terminal=false
Categories=Graphics;Photography;
MimeType=image/jpeg;image/jpeg2000;image/tiff;image/png;image/gif;image/svg+xml;image/x-dcraw;
X-Desktop-File-Install-Version=0.23
GenericName[de]=Photini-Fotometadateneditor
Comment[de]=Ein einfach zu bedienender Metadaten-Editor für digitale Bilder.
GenericName[es]=Photini editor de metadatos fotográficos
Comment[es]=Un editor de metadatos fotográficos fácil de usar.
GenericName[ca]=Photini editor de metadades de foto
Comment[ca]=Un editor de metadades de foto digital fàcil d'usar.
GenericName[pl]=Photini edytor metadanych zdjęcia
Comment[pl]=Łatwy w użyciu edytor metadanych fotografii cyfrowej.
GenericName[cs_CZ]=Editor fotografických popisných údajů Photini
Comment[cs_CZ]=Snadno se používající editor popisů digitálních fotografií.
Loading

0 comments on commit 2fa75d2

Please sign in to comment.