diff --git a/.gitignore b/.gitignore index d5e4595..cc528d3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,13 +7,12 @@ debian/uberwriter/opt debian/uberwriter/usr bin/ flatpak/* -!flatpak/fonts-download -!flatpak/pandoc-download -!flatpak/pip-download !flatpak/uberwriter.json !flatpak/de.wolfvollprecht.UberWriter.* !flatpak/flatpak_texlive.json !flatpak/texlive_install.sh +!flatpak/python3-enchant.json +!flatpak/python3-packages.json *.py~ data/ui/shortcut_handlers *.ui~ diff --git a/Makefile b/Makefile index 4e6ad1e..0f57ea2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ -all: - python3 ./setup.py build +.PHONY: flatpak-user-install flatpak-generate-python-modules -install: - python3 ./setup.py install --prefix=/app --skip-build --optimize=1 +flatpak-user-install: + cd flatpak; flatpak-builder --force-clean --install --user _build uberwriter.json +flatpak-generate-python-modules: + # gtkspellcheck's setup.py wants enchant to already be installed + flatpak-pip-generator --output flatpak/python3-enchant.json pyenchant + flatpak-pip-generator --output flatpak/python3-packages.json `grep -v enchant requirements.txt` diff --git a/README.md b/README.md index 802d3f9..0c367dc 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,7 @@ but you'll need to install and compile the schemas before: It's also possible to build, run and debug a flatpak package. You'll need flatpak-builder for this: -- cd to the flatpak dir of the repo -- `flatpak-builder --install --force-clean some_folder_name uberwriter.json` (this installs and cleans the build folder) +- `make flatpak-user-install` (this installs the Flatpak) - `flatpak run de.wolfvollprecht.UberWriter` If you can't find Uberwriter after this, it's due to a Flatpak bug. Try to export it to a local repo before installing it: @@ -54,4 +53,4 @@ If you want to update an existing installation, just run You can also debug it with the following: `flatpak-builder --run --share=network some_folder_name uberwriter.json sh` -If you want to install it using setuptools, simply run `python3 setup.py build install` \ No newline at end of file +If you want to install it using setuptools, simply run `python3 setup.py build install` diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 8b13789..0000000 --- a/autogen.sh +++ /dev/null @@ -1 +0,0 @@ - diff --git a/configure b/configure deleted file mode 100755 index 8b13789..0000000 --- a/configure +++ /dev/null @@ -1 +0,0 @@ - diff --git a/flatpak/uberwriter.json b/flatpak/uberwriter.json index 620c285..10472e7 100644 --- a/flatpak/uberwriter.json +++ b/flatpak/uberwriter.json @@ -1,27 +1,18 @@ { "app-id": "de.wolfvollprecht.UberWriter", "runtime": "org.gnome.Platform", - "runtime-version": "3.28", + "runtime-version": "3.30", "sdk": "org.gnome.Sdk", - "command": "/app/usr/bin/uberwriter", + "command": "start-uberwriter", "finish-args": [ "--socket=x11", "--share=ipc", "--filesystem=host", - "--env=IN_FLATPAK=1", "--filesystem=xdg-run/dconf", "--filesystem=~/.config/dconf:ro", "--talk-name=ca.desrt.dconf", - "--env=DCONF_USER_CONFIG_DIR=.config/dconf", - "--env=XDG_DATA_DIRS=/app/usr/share", - "--env=PATH=/app/extensions/TexLive/bin:/app/extensions/TexLive/2018/bin/x86_64-linux:/app/usr/bin:/app/bin" + "--env=DCONF_USER_CONFIG_DIR=.config/dconf" ], - "build-options" : { - "env": { - "PYTHON": "python3", - "IN_FLATPAK": "1" - } - }, "add-extensions": { "de.wolfvollprecht.UberWriter.Plugin": { "directory": "extensions", @@ -32,75 +23,6 @@ } }, "modules": [ - { - "name": "uberwriter", - "sources": [ - { - "type" : "git", - "url" : "../", - "branch" : "refactoring" - } - ], - "build-commands": [ - "install -Dm644 flatpak/de.wolfvollprecht.UberWriter.appdata.xml /app/share/appdata/de.wolfvollprecht.UberWriter.appdata.xml " - ], - "post-install": [ - "glib-compile-schemas /app/usr/share/glib-2.0/schemas", - "install -d /app/extensions" - ] - }, - { - "name": "pandoc", - "only-arches": [ - "x86_64" - ], - "buildsystem": "simple", - "build-commands": [ - "cp bin/pandoc /app/usr/bin/pandoc", - "cp bin/pandoc-citeproc /app/usr/bin/pandoc-citeproc" - ], - "sources": [ - { - "type": "archive", - "url": "https://github.com/jgm/pandoc/releases/download/2.2/pandoc-2.2-linux.tar.gz", - "sha256": "06ecd882e42ef9b7390b1c82e1e71b3ea48679181289b9b810a8797825bed8ed" - } - ] - }, - { - "name": "pipdeps", - "buildsystem": "simple", - "build-commands": [ - "pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} pyenchant regex pypandoc" - ], - "sources": [ - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/5d/c1/45947333669b31bc6b4933308dd07c2aa2fedcec0a95b14eedae993bd449/wheel-0.31.0.tar.gz", - "sha256": "1ae8153bed701cb062913b72429bcf854ba824f973735427681882a688cb55ce" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/ae/e8/2340d46ecadb1692a1e455f13f75e596d4eab3d11a57446f08259dee8f02/pip-10.0.1.tar.gz", - "sha256": "f2bd08e0cd1b06e10218feaf6fef299f473ba706582eb3bd9d52203fdbd7ee68" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/71/81/00184643e5a10a456b4118fc12c96780823adb8ed974eb2289f29703b29b/pypandoc-1.4.tar.gz", - "sha256": "e914e6d5f84a76764887e4d909b09d63308725f0cbb5293872c2c92f07c11a5b" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/a2/51/c39562cfed3272592c60cfd229e5464d715b78537e332eac2b695422dc49/regex-2018.02.21.tar.gz", - "sha256": "b44624a38d07d3c954c84ad302c29f7930f4bf01443beef5589e9157b14e2a29" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/9e/54/04d88a59efa33fefb88133ceb638cdf754319030c28aadc5a379d82140ed/pyenchant-2.0.0.tar.gz", - "sha256": "fc31cda72ace001da8fe5d42f11c26e514a91fa8c70468739216ddd8de64e2a0" - } - ] - }, { "name": "fonts", "buildsystem": "simple", @@ -117,18 +39,72 @@ ] }, { - "name": "appdata", - "buildsystem": "simple", - "build-commands": [ - "mkdir -p /app/share/appdata", - "install -Dm644 de.wolfvollprecht.UberWriter.appdata.xml /app/share/appdata/de.wolfvollprecht.UberWriter.appdata.xml" + "name": "pandoc", + "only-arches": [ + "x86_64" + ], + "buildsystem": "simple", + "build-commands": [ + "install -Dm 755 bin/pandoc /app/bin/pandoc", + "install -Dm 755 bin/pandoc-citeproc /app/bin/pandoc-citeproc" + ], + "sources": [ + { + "type": "archive", + "url": "https://github.com/jgm/pandoc/releases/download/2.2/pandoc-2.2-linux.tar.gz", + "sha256": "06ecd882e42ef9b7390b1c82e1e71b3ea48679181289b9b810a8797825bed8ed" + } + ] + }, + { + "name": "enchant", + "config-opts": [ + "--with-myspell-dir=/usr/share/myspell" ], "sources": [ { - "type": "file", - "path": "de.wolfvollprecht.UberWriter.appdata.xml" + "type": "archive", + "url": "https://github.com/AbiWord/enchant/releases/download/enchant-1-6-1/enchant-1.6.1.tar.gz", + "sha256": "bef0d9c0fef2e4e8746956b68e4d6c6641f6b85bd2908d91731efb68eba9e3f5" } ] + }, + "python3-enchant.json", + "python3-packages.json", + { + "name": "uberwriter", + "buildsystem": "simple", + "build-commands": [ + "desktop-file-edit --set-key=Exec --set-value='uberwriter.in %U' data/de.wolfvollprecht.UberWriter.desktop", + "python3 -m pip install --prefix=/app --install-option=--optimize=1 ." + ], + "sources": [ + { + "type" : "dir", + "path" : "../" + } + ], + "post-install": [ + "install -d /app/extensions", + "glib-compile-schemas /app/share/glib-2.0/schemas" + ] + }, + { + "name": "scripts", + "buildsystem": "simple", + "build-commands": [ + "install -Dm 755 start-uberwriter.sh /app/bin/start-uberwriter" + ], + "sources": [ + { + "type": "script", + "dest-filename": "start-uberwriter.sh", + "commands": [ + "export PATH=/app/extensions/TexLive/bin:/app/extensions/TexLive/2018/bin/$(uname -a)-linux:$PATH", + "exec uberwriter.in \"$@\"" + ] + } + ] } ] - } +} diff --git a/requirements.txt b/requirements.txt index 340d2e0..eed1919 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ regex -enchant -python-gtkspellcheck pandoc +pyenchant +pygtkspellcheck diff --git a/setup.py b/setup.py index 8671284..e2995be 100644 --- a/setup.py +++ b/setup.py @@ -2,16 +2,16 @@ # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- ### BEGIN LICENSE # Copyright (C) 2012, Wolf Vollprecht -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 3, as published +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranties of -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, 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 +# +# You should have received a copy of the GNU General Public License along # with this program. If not, see . ### END LICENSE @@ -22,24 +22,20 @@ from setuptools import setup import os -def package_files(directory): - paths = [] - for (path, directories, filenames) in os.walk(directory): +def data_files(basename): + data = os.path.join('.', 'data') + root = os.path.join(data, basename) + extra_files = [] + for path, directories, filenames in os.walk(root): + paths = [] for filename in filenames: paths.append(os.path.join(path, filename)) - return paths + extra_files.append(('share/uberwriter/data/{}'.format(os.path.relpath(path, data)), paths)) + return extra_files -extra_files_ui = package_files('./data/ui') -extra_files_media = package_files('./data/media') -extra_files_scripts = package_files('./data/lua') -from pprint import pprint -pprint(extra_files_ui) -pprint(extra_files_media) - -if os.path.isfile("/.flatpak-info"): - app_prefix = '/app/' -else: - app_prefix = '/usr/' +extra_files_ui = data_files('ui') +extra_files_media = data_files('media') +extra_files_scripts = data_files('lua') setup( name='uberwriter', @@ -49,10 +45,10 @@ setup( author_email='w.vollprecht@gmail.com', description='A beautiful, simple and distraction free markdown editor.', long_description="""UberWriter, beautiful distraction free writing - With UberWriter you get only one thing: An empty textbox, that is to - fill with your ideas. There are no settings, you don't have to choose a - font, it is only for writing.You can use markdown for all your markup - needs. PDF, RTF and HTML are generated with pandoc. For PDF generation it + With UberWriter you get only one thing: An empty textbox, that is to + fill with your ideas. There are no settings, you don't have to choose a + font, it is only for writing.You can use markdown for all your markup + needs. PDF, RTF and HTML are generated with pandoc. For PDF generation it is also required that you choose to install the texlive-luatex package.""", url='https://github.com/wolfv/uberwriter/', # cmdclass={'install': InstallAndUpdateDataDirectory}, @@ -75,12 +71,11 @@ setup( 'uberwriter.pylocales' : ['locales.db'], }, data_files=[ - (app_prefix + 'bin', ['bin/uberwriter']), - (app_prefix + 'share/glib-2.0/schemas', ['data/de.wolfvollprecht.UberWriter.gschema.xml']), - (app_prefix + 'share/icons/hicolor/scalable/apps', ['data/media/de.wolfvollprecht.UberWriter.svg']), - (app_prefix + 'share/applications', ['de.wolfvollprecht.UberWriter.desktop']), - (app_prefix + 'share/uberwriter/data/ui', extra_files_ui), - (app_prefix + 'share/uberwriter/data/media', extra_files_media), - (app_prefix + 'share/uberwriter/data/lua', extra_files_scripts) + ('bin', ['uberwriter.in']), + ('share/applications', ['data/de.wolfvollprecht.UberWriter.desktop']), + ('share/metainfo', ['data/de.wolfvollprecht.UberWriter.appdata.xml']), + ('share/icons/hicolor/scalable/apps', ['data/media/de.wolfvollprecht.UberWriter.svg']), + ('share/glib-2.0/schemas', ['data/de.wolfvollprecht.UberWriter.gschema.xml']), + *(extra_files_ui + extra_files_media + extra_files_scripts) ] ) diff --git a/uberwriter/uberwriterconfig.py b/uberwriter/uberwriterconfig.py index fc3f7b1..5d2da16 100644 --- a/uberwriter/uberwriterconfig.py +++ b/uberwriter/uberwriterconfig.py @@ -53,7 +53,6 @@ def get_data_path(): """ # Get pathname absolute or relative. - # TODO: Abstract this (the old env IN_FLATPAK) if os.path.isfile("/.flatpak-info"): return '/app/share/uberwriter/data/'