Merge pull request #43 from wolfv/flat_master

add flatpak config
gh-pages
Wolf Vollprecht 2018-04-04 23:03:19 +02:00 committed by GitHub
commit cf6333dceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 228 additions and 139 deletions

6
Makefile 100644
View File

@ -0,0 +1,6 @@
all:
echo "Nothing"
install:
python3 setup.py install --prefix=/app

0
autogen.sh 100755
View File

0
configure vendored 100755
View File

View File

@ -0,0 +1,30 @@
#!/bin/sh
for i in "$@"
do
case $i in
--module=*)
MODULENAME="${i#*=}"
shift
;;
*)
ARGS="$ARGS $i"
shift
;;
esac
done
cat <<EOF > Makefile
all:
echo "Nothing"
install:
mkdir /tmp/fonts
cd /tmp/fonts
curl -L https://fonts.google.com/download?family=Fira%20Mono > Fira_Mono.zip
unzip Fira_Mono.zip
rm Fira_Mono.zip
mkdir -p /app/share/fonts
cp ./* /app/share/fonts
EOF

View File

@ -0,0 +1,34 @@
#!/bin/sh
for i in "$@"
do
case $i in
--module=*)
MODULENAME="${i#*=}"
shift
;;
*)
ARGS="$ARGS $i"
shift
;;
esac
done
cat <<EOF > Makefile
all:
echo "Nothing"
install:
CXX=/usr/bin/g++ CC=/usr/bin/gcc PYTHONUSERBASE=/app/ pip3 install --user $MODULENAME;
cd /tmp/
mkdir pandoc_dl && cd pandoc_dl
curl -L https://github.com/jgm/pandoc/releases/download/2.1.3/pandoc-2.1.3-1-amd64.deb > pandoc.deb
ar x pandoc.deb
tar xf data.tar.*
cp ./usr/bin/pandoc /app/bin/pandoc
cp ./usr/bin/pandoc-citeproc /app/bin/pandoc-citeproc
cp ./usr/share/doc/pandoc/copyright /app/share/pandoc.copyright
cd ..
rm -rf /tmp/pandoc_dl
EOF

View File

@ -0,0 +1,24 @@
#!/bin/sh
for i in "$@"
do
case $i in
--module=*)
MODULENAME="${i#*=}"
shift
;;
*)
ARGS="$ARGS $i"
shift
;;
esac
done
cat <<EOF > Makefile
all:
echo "Nothing"
install:
CXX=/usr/bin/g++ CC=/usr/bin/gcc PYTHONUSERBASE=/app/ pip3 install --user $MODULENAME
EOF

View File

@ -0,0 +1,98 @@
{
"app-id": "de.wolfvollprecht.UberWriter",
"runtime": "org.gnome.Platform",
"runtime-version": "3.26",
"sdk": "org.gnome.Sdk",
"command": "uberwriter",
"finish-args": [
"--socket=x11",
"--env=IN_FLATPAK=1"
],
"build-options" : {
"env": {
"PYTHON": "python3"
}
},
"modules": [
{
"name": "uberwriter",
"sources": [
{
"type": "git",
"url": "git://github.com/wolfv/uberwriter",
"branch": "master"
}
]
},
{
"name": "pyenchant",
"build-options" : {
"build-args": ["--share=network"]
},
"config-opts": ["--module=pyenchant"],
"sources": [
{
"type": "file",
"path": "pip-download",
"dest-filename": "configure"
}
]
},
{
"name": "regex",
"build-options" : {
"build-args": ["--share=network"]
},
"config-opts": ["--module=regex"],
"sources": [
{
"type": "file",
"path": "pip-download",
"dest-filename": "configure"
}
]
},
{
"name": "python-Levenshtein",
"build-options" : {
"build-args": ["--share=network"]
},
"config-opts": ["--module=python-Levenshtein"],
"sources": [
{
"type": "file",
"path": "pip-download",
"dest-filename": "configure"
}
]
},
{
"name": "pypandoc",
"build-options" : {
"build-args": ["--share=network"]
},
"config-opts": ["--module=pypandoc"],
"sources": [
{
"type": "file",
"path": "pandoc-download",
"dest-filename": "configure"
}
]
},
{
"name": "fonts",
"build-options" : {
"build-args": ["--share=network"]
},
"config-opts": [""],
"sources": [
{
"type": "file",
"path": "fonts-download",
"dest-filename": "configure"
}
]
}
]
}

172
setup.py
View File

@ -15,167 +15,61 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
import os
import sys
try:
import DistUtilsExtra.auto
except ImportError:
print >> sys.stderr, 'To build uberwriter you need https://launchpad.net/python-distutils-extra'
sys.exit(1)
assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'
def update_config(libdir, values = {}):
filename = os.path.join(libdir, 'uberwriter_lib/uberwriterconfig.py')
oldvalues = {}
try:
fin = open(filename, 'r', encoding="utf-8")
fout = open(filename + '.new', 'w', encoding="utf-8")
for line in fin:
fields = line.split(' = ') # Separate variable from value
if fields[0] in values:
oldvalues[fields[0]] = fields[1].strip()
line = "%s = %s\n" % (fields[0], values[fields[0]])
fout.write(line)
fout.flush()
fout.close()
fin.close()
os.rename(fout.name, fin.name)
except (OSError, IOError) as e:
print ("ERROR: Can't find %s" % filename)
sys.exit(1)
return oldvalues
def move_desktop_file(root, target_data, prefix):
# The desktop file is rightly installed into install_data. But it should
# always really be installed into prefix, because while we can install
# normal data files anywhere we want, the desktop file needs to exist in
# the main system to be found. Only actually useful for /opt installs.
print("renaming desktop file")
print(root, target_data, prefix)
if root.endswith("/"): root = root[:-1]
print(os.getcwd())
old_desktop_path = root + target_data + 'share/applications'
old_desktop_file = old_desktop_path + '/uberwriter.desktop'
desktop_path = root + prefix + '/share/applications'
desktop_file = desktop_path + '/uberwriter.desktop'
print("OLD: " + old_desktop_file)
if not os.path.exists(old_desktop_file):
print ("ERROR: Can't find", old_desktop_file)
sys.exit(1)
elif target_data != prefix + '/':
# This is an /opt install, so rename desktop file to use extras-
desktop_file = desktop_path + '/extras-uberwriter.desktop'
try:
os.makedirs(desktop_path)
print('renaming to: %s' % desktop_file)
os.rename(old_desktop_file, desktop_file)
os.rmdir(old_desktop_path)
except OSError as e:
print ("ERROR: Can't rename", old_desktop_file, ":", e)
sys.exit(1)
return desktop_file
def update_desktop_file(filename, target_pkgdata, target_scripts):
print("updating deskop file: %s" % filename)
try:
fin = open(filename, 'r', encoding="utf-8")
fout = open(filename + '.new', 'w', encoding="utf-8")
for line in fin:
if 'Icon=' in line:
line = "Icon=%s\n" % (target_pkgdata + 'media/uberwriter.svg')
elif 'Exec=' in line:
cmd = line.split("=")[1].split(None, 1)
line = "Exec=%s" % (target_scripts + 'uberwriter')
if len(cmd) > 1:
line += " %s" % cmd[1].strip() # Add script arguments back
line += "\n"
fout.write(line)
fout.flush()
fout.close()
fin.close()
os.rename(fout.name, fin.name)
except (OSError, IOError) as e:
print ("ERROR: Can't find %s" % filename)
sys.exit(1)
def compile_schemas(root, target_data):
schemadir = os.path.normpath('usr/share/glib-2.0/schemas')
if (os.path.isdir(schemadir) and
os.path.isfile('/usr/bin/glib-compile-schemas')):
os.system('/usr/bin/glib-compile-schemas "%s"' % schemadir)
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
def run(self):
DistUtilsExtra.auto.install_auto.run(self)
target_data = '/' + os.path.relpath(self.install_data, self.root) + '/'
target_pkgdata = target_data + 'share/uberwriter/'
target_scripts = '/' + os.path.relpath(self.install_scripts, self.root) + '/'
values = {'__uberwriter_data_directory__': "'%s'" % (target_pkgdata),
'__version__': "'%s'" % self.distribution.get_version()}
update_config(self.install_lib, values)
desktop_file = move_desktop_file(self.root, target_data, self.prefix)
update_desktop_file(desktop_file, target_pkgdata, target_scripts)
compile_schemas(self.root, target_data)
# TODO:Remove this
#
# try:
# os.remove("/usr/bin/uberwriter")
# os.symlink(target_scripts + "uberwriter", "/usr/bin/uberwriter")
# except:
# print("Couldn't remove old symlink or installing new symlink didn't work.")
##################################################################################
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
##################################################################################
from distutils.core import setup
import os
DistUtilsExtra.auto.setup(
def package_files(directory):
paths = []
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join(path, filename))
return paths
extra_files_ui = package_files('./data/ui')
extra_files_media = package_files('./data/media')
from pprint import pprint
pprint(extra_files_ui)
pprint(extra_files_media)
setup(
name='uberwriter',
version='1.0',
license='GPL-3',
author='Wolf Vollprecht',
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 \
is also required that you choose to install the texlive-luatex package.",
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
is also required that you choose to install the texlive-luatex package.""",
url='https://launchpad.com/uberwriter',
cmdclass={'install': InstallAndUpdateDataDirectory},
# cmdclass={'install': InstallAndUpdateDataDirectory},
package_dir = {
'gtkspellcheck': 'uberwriter_lib/gtkspellcheck',
'pylocales': 'uberwriter_lib/pylocales'
# "": '/opt/uberwriter/'
},
packages=[
"uberwriter_lib.gtkspellcheck",
"uberwriter_lib.pylocales",
"uberwriter_lib.pressagio",
# "uberwriter_lib.pressagio",
"uberwriter_lib",
"uberwriter"
# "uberwriter.plugins"
# "uberwriter.plugins.bibtex"
],
package_data={
'uberwriter_lib.pylocales' : ['locales.db']
'uberwriter_lib.pylocales' : ['locales.db'],
},
data_files=[
('uberwriter_lib/pylocales', ['uberwriter_lib/pylocales/locales.db']),
('/usr/share/glib-2.0/schemas', ['data/glib-2.0/schemas/net.launchpad.uberwriter.gschema.xml'])
#,('/usr/share/icons/hicolor/scalable/apps', ['data/media/uberwriter.svg'])
('bin/', ['bin/uberwriter']),
('share/glib-2.0/schemas', ['data/glib-2.0/schemas/net.launchpad.uberwriter.gschema.xml']),
('share/icons/hicolor/scalable/apps', ['data/media/uberwriter.svg']),
('opt/uberwriter/data/ui', extra_files_ui),
('opt/uberwriter/data/media', extra_files_media)
]
)

View File

@ -55,6 +55,9 @@ def get_data_path():
"""
# Get pathname absolute or relative.
if os.environ.get("IN_FLATPAK"):
return '/app/opt/uberwriter/data/'
path = os.path.join(
os.path.dirname(__file__), __uberwriter_data_directory__)