Skip to content

Commit

Permalink
Fixed packaging problems
Browse files Browse the repository at this point in the history
* moved gresource file into package
* MANIFEST.in for sdist
* single source __version__ constant
  • Loading branch information
hnesk committed Jul 21, 2020
1 parent 5a10920 commit 08874e6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@ dmypy.json
# Pyre type checker
.pyre/
/resources/ocrd-browser.gresource
/ocrd_browser/ui.gresource
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include LICENSE
include README.md
include *.py
include ocrd_browser/*.gresource
1 change: 1 addition & 0 deletions ocrd_browser/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.2'
6 changes: 2 additions & 4 deletions ocrd_browser/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from gi.repository import Gtk, Gio
from pathlib import Path

BASE_PATH = Path(__file__).absolute().parent.parent
RESOURCE_FILE_NAME = "resources/ocrd-browser.gresource"

resources = Gio.resource_load(str(BASE_PATH / RESOURCE_FILE_NAME))
BASE_PATH = Path(__file__).absolute().parent
resources = Gio.resource_load(str(BASE_PATH / "ui.gresource"))
Gio.resources_register(resources)

def install_excepthook():
Expand Down
8 changes: 4 additions & 4 deletions ocrd_browser/window.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import gi
from ocrd_utils import pushd_popd

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GdkPixbuf, Gio, GObject, GLib

from ocrd_utils import pushd_popd
from ocrd_browser import __version__
from ocrd_browser.image_util import pil_to_pixbuf
from ocrd_browser.model import Document
from ocrd_browser.views import ViewSingle, ViewXml, ViewMulti
Expand Down Expand Up @@ -119,6 +118,7 @@ class AboutDialog(Gtk.AboutDialog):
def __init__(self, **kwargs):
Gtk.AboutDialog.__init__(self, **kwargs)
self.set_logo(GdkPixbuf.Pixbuf.new_from_resource('/org/readmachine/ocrd-browser/icons/logo.png'))
self.set_version(__version__)


@Gtk.Template(resource_path="/org/readmachine/ocrd-browser/ui/open-dialog.ui")
Expand Down Expand Up @@ -211,7 +211,7 @@ def __init__(self, document: Document, **kwargs):

def goto_index(self, index):
index = index if index >= 0 else len(self.model) + index
if index >= 0 and index < len(self.model):
if 0 <= index < len(self.model):
self.goto_path(Gtk.TreePath(index))

def skip(self, pos):
Expand Down
10 changes: 7 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,34 @@

import setuptools
from setuptools import setup
from ocrd_browser import __version__

install_requires = open('requirements.txt').read().split('\n')


print("Generating gresources bundle")
subprocess.call(
[
"glib-compile-resources",
"--sourcedir=resources",
"--target=ocrd_browser/ui.gresource",
"resources/ocrd-browser.gresource.xml",
]
)

setup(
name='browse-ocrd',
version='0.1',
version=__version__,
author='Johannes Künsebeck',
author_email='[email protected]',
description='An extensible viewer for OCRD mets.xml files',
license='MIT License',
long_description=codecs.open('README.md', encoding='utf-8').read(),
long_description_content_type='text/markdown',
url="https://github.com/hnesk/ocrd-browser",
url="https://github.com/hnesk/browse-ocrd",
packages=setuptools.find_packages(),
install_requires=install_requires,
include_package_data=True,
setup_requires=['wheel'],
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
Expand All @@ -45,4 +48,5 @@
'browse-ocrd = ocrd_browser.main:main',
]
},
package_data={'ocrd_browser': ['*.gresource']},
)

0 comments on commit 08874e6

Please sign in to comment.