Skip to content

Commit

Permalink
Merge pull request #2 from jim-easterbrook/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
jim-easterbrook authored Jan 4, 2025
2 parents 35154f3 + 7037700 commit 9cad1e2
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 185 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pyctools - a picture processing algorithm development kit.
http://github.com/jim-easterbrook/pyctools
Copyright (C) 2012-19 Jim Easterbrook [email protected]
https://github.com/jim-easterbrook/pyctools
Copyright (C) 2012-25 Pyctools contributors

This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand All @@ -16,6 +16,12 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.

Changes in v0.7.0:
1/ Python 2 is no longer supported.
2/ Some components are deprecated in favour of better replacements.
3/ Documentation build is much improved.
4/ Many smaller changes.

Changes in v0.5.0:
1/ Rethought use of range, black level, and white level. Now almost every
component will assume 0..255 and if conversion to/from 16..235 is needed it
Expand Down
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
include *.txt
recursive-include src/doc *
prune src/doc/api
recursive-exclude src/doc *
47 changes: 45 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pyctools - a picture processing algorithm development kit.
# http://github.com/jim-easterbrook/pyctools
# Copyright (C) 2023-24 Pyctools contributors
# Copyright (C) 2023-25 Pyctools contributors
#
# This file is part of Pyctools.
#
Expand Down Expand Up @@ -45,13 +45,56 @@ classifiers = [
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Scientific/Engineering :: Visualization",
]
requires-python = ">= 3.6"
dynamic = ["scripts"]
dependencies = [
"docutils",
"exiv2 >= 0.11",
"numpy",
"numpy < 2",
"pillow",
]

[project.optional-dependencies]
# Qt options - only one required
PyQt5 = ["PyQt5 >= 5.9"]
PyQt6 = [
"pyctools-core[PyQt6-linux]; platform_system == 'Linux'",
"pyctools-core[PyQt6-darwin]; platform_system == 'Darwin'",
]
PySide2 = [
"PySide2 >= 5.11.1; python_version < '3.8'",
"PySide2 >= 5.14; python_version >= '3.8'",
]
PySide6 = [
"pyctools-core[PySide6-linux]; platform_system == 'Linux'",
"pyctools-core[PySide6-darwin]; platform_system == 'Darwin'",
]
PyQt6-linux = [
"PyQt6 >= 6.2; python_version != '3.6.*'",
"PyQt6 >= 6.2, < 6.3; python_version == '3.6.*'",
"PyQt6-Qt6 < 6.3; python_version == '3.6.*'",
]
PyQt6-darwin = [
"PyQt6 >= 6.2",
"PyQt6-Qt6 >= 6.2, != 6.6.1",
]
PySide6-linux = ["PySide6 >= 6.2"]
PySide6-darwin = ["PySide6 >= 6.2, != 6.6.1"]
# other packages
cv2 = ["pyctools-core[OpenCV]"]
matplotlib = ["matplotlib"]
OpenCV = [
"opencv-python-headless; python_version != '3.6.*'",
"opencv-python-headless < 4.7; python_version == '3.6.*'",
]
OpenGL = ["pyctools-core[PyOpenGL]"]
PyOpenGL = ["PyOpenGL", "PyOpenGL-accelerate"]
rawkit = ["rawkit"]
rawpy = ["rawpy"]
SciPy = ["scipy"]
# install everything except a Qt package
all = ["pyctools-core[matplotlib,OpenCV,PyOpenGL,rawkit,rawpy,SciPy]"]

[project.urls]
homepage = "https://github.com/jim-easterbrook/pyctools"
documentation = "https://pyctools.readthedocs.io/"
Expand Down
44 changes: 9 additions & 35 deletions src/doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pyctools - a picture processing algorithm development kit.
# http://github.com/jim-easterbrook/pyctools
# Copyright (C) 2014-24 Pyctools contributors
# Copyright (C) 2014-25 Pyctools contributors
#
# This file is part of Pyctools.
#
Expand All @@ -17,47 +17,20 @@
# You should have received a copy of the GNU General Public License
# along with Pyctools. If not, see <http://www.gnu.org/licenses/>.

from collections import defaultdict
import os
import pkgutil
import site
import sys
import types
from unittest.mock import Mock

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
site.addsitedir(os.path.abspath('..'))
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

# cludge to allow documentation to be compiled without installing some
# dependencies
for mod_name in ('cv2', 'OpenGL', 'matplotlib', 'matplotlib.pyplot',
'scipy', 'scipy.optimize', 'scipy.signal', 'scipy.special',
'sip'):
sys.modules[mod_name] = Mock()

# Qt stuff needs a bit more work as it's used as base classes
class QtMock(Mock):
QT_VERSION_STR = '0.0.0'
QObject = object
QWidget = object
QGraphicsRectItem = object
QGraphicsPolygonItem = object
QGLWidget = object
QOpenGLWidget = object

for mod_name in ('PyQt5', 'PyQt5.QtCore', 'PyQt5.QtGui',
'PyQt5.QtOpenGL', 'PyQt5.QtWidgets'):
sys.modules[mod_name] = QtMock()

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
needs_sphinx = '2.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
Expand All @@ -75,9 +48,9 @@ class QtMock(Mock):

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
'PIL': ('http://pillow.readthedocs.io/en/latest/', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'PIL': ('https://pillow.readthedocs.io/en/latest/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
}

keep_warnings = True
Expand All @@ -102,7 +75,7 @@ class QtMock(Mock):

# General information about the project.
project = u'Pyctools'
copyright = u'2014-20, Pyctools contributors'
copyright = u'2014-25, Pyctools contributors'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -127,9 +100,9 @@ class QtMock(Mock):
# pkgutil.walk_packages doesn't work with namespace packages, so we do
# a simple file search instead
for path in pyctools.__path__:
depth = len(path.split('/')) - 1
depth = len(path.split(os.path.sep)) - 1
for root, dirs, files in os.walk(path):
parts = root.split('/')
parts = root.split(os.path.sep)
if parts[-1] == '__pycache__':
continue
parts = parts[depth:]
Expand Down Expand Up @@ -190,7 +163,8 @@ def submodules(parent):
# import module
try:
mod = __import__(module['name'], globals(), locals(), ['*'])
except ImportError:
except ImportError as ex:
print(str(ex))
continue
module['mod'] = mod
if getattr(mod, '__doc__'):
Expand Down
13 changes: 9 additions & 4 deletions src/doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Sphinx==7.2.4
sphinx-rtd-theme==1.3.0
rawkit
rawpy
Sphinx==8.1.3
toml==0.10.2
sphinx-rtd-theme==3.0.2
PyQt5==5.15.11
rawkit==0.6.0
rawpy==0.24.0
opencv-python-headless==4.10.0.84
scipy==1.15.0
matplotlib==3.10.0
31 changes: 17 additions & 14 deletions src/pyctools/components/io/imagefilecv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pyctools - a picture processing algorithm development kit.
# http://github.com/jim-easterbrook/pyctools
# Copyright (C) 2016-20 Pyctools contributors
# Copyright (C) 2016-25 Pyctools contributors
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand All @@ -16,8 +16,6 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.

from __future__ import print_function

__all__ = ['ImageFileReaderCV', 'ImageFileWriterCV']
__docformat__ = 'restructuredtext en'

Expand Down Expand Up @@ -110,26 +108,31 @@ class ImageFileWriterCV(Transformer):
:py:class:`~pyctools.components.io.imagefilepil.ImageFileWriterPIL`
component instead.
============================== ==== ====
================== ==== ====
Config
============================== ==== ====
``path`` str Path name of file to be written.
``16bit`` bool Write a 16-bit depth file, if the format supports it.
{}
============================== ==== ====
================== ==== ====
``path`` str Path name of file to be read.
``16bit`` bool Write a 16-bit depth file, if the format supports it.
``{a}``{sa} int
...
``{b}``{sb} int
================== ==== ====
The config items from ``{a}`` to ``{b}`` are format-specific
parameters to the :py:func:`cv2.imwrite` function with the
``CV_IMWRITE_`` prefix removed.
.. _OpenCV documentation:
http://docs.opencv.org/2.4.11/modules/highgui/doc/reading_and_writing_images_and_video.html#imwrite
https://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#imwrite
"""

cv2_params = [x[8:] for x in cv2.__dict__ if x.startswith('IMWRITE_')]
cv2_params.sort()

__doc__ = __doc__.format(
'\n '.join([
'``{x}``{s} int OpenCV CV_IMWRITE_{x} parameter.'.format(
x=x, s=' '*(26-len(x))) for x in cv2_params]))
__doc__ = __doc__.format(a=cv2_params[0], b=cv2_params[-1],
sa=' '*(12-len(cv2_params[0])),
sb=' '*(12-len(cv2_params[-1])))

def initialise(self):
self.done = False
Expand Down
11 changes: 9 additions & 2 deletions src/pyctools/components/qt/qtdisplay.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pyctools - a picture processing algorithm development kit.
# http://github.com/jim-easterbrook/pyctools
# Copyright (C) 2014-24 Pyctools contributors
# Copyright (C) 2014-25 Pyctools contributors
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand All @@ -20,10 +20,14 @@
__docformat__ = 'restructuredtext en'

from collections import deque
import sys
import time

import numpy
from OpenGL import GL
if 'sphinx' in sys.modules:
GL = None
else:
from OpenGL import GL

from pyctools.core.config import ConfigBool, ConfigInt, ConfigStr
from pyctools.core.base import Transformer
Expand Down Expand Up @@ -225,6 +229,9 @@ def __init__(self, **config):
super(QtDisplay, self).__init__(**config)
self.setWindowFlags(QtCore.Qt.WindowType.Window |
QtCore.Qt.WindowType.WindowStaysOnTopHint)
dpr = self.window().devicePixelRatio()
if int(dpr) != dpr:
self.logger.warning('Non-integer screen pixel ratio %g', dpr)
self.setLayout(QtWidgets.QGridLayout())
fmt = QtGui.QSurfaceFormat()
fmt.setProfile(
Expand Down
Loading

0 comments on commit 9cad1e2

Please sign in to comment.