Skip to content

Commit

Permalink
Update installation of data files
Browse files Browse the repository at this point in the history
  • Loading branch information
cydanil authored Sep 10, 2020
2 parents d565bf8 + 68a919e commit 1b7fe0e
Show file tree
Hide file tree
Showing 26 changed files with 45 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
pip3 install --upgrade keyrings.alt
if [ -f development.txt ]; then pip3 install -r development.txt; fi
if [ -f requirements.txt ]; then pip3 install -r requirements.txt; fi
- name: Build wheel and Install
- name: Install
run: |
pip3 install .
- name: Build source distribution
Expand All @@ -48,5 +48,5 @@ jobs:
- name: Upload wheel
uses: actions/upload-artifact@v2
with:
name: gourmet.wheel
name: gourmet.whl
path: ./dist/gourmet-*-py3-none-any.whl
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions gourmet/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# The following lines are modified at installation time by setup.py so they
# point to the actual data files installation paths.

base_dir = op.join(op.dirname(__file__), '..')
base_dir = op.abspath(op.join(op.dirname(__file__), '..'))
lib_dir = op.join(base_dir, 'gourmet')
data_dir = op.join(base_dir, 'data')
data_dir = op.join(lib_dir, 'data')

flatpak_ui = "/app/share/gourmet/ui"
ui_base = op.join(op.dirname(__file__), 'ui')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ pygtkspellcheck
reportlab
scrape-schema-recipe
selenium
setuptools
SQLAlchemy
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ xml_files=[
]

[build_icons]
icon_dir=data/icons
icon_dir=gourmet/data/icons

80 changes: 39 additions & 41 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import distutils.command.build_scripts
import distutils.core
from distutils.util import convert_path
import setuptools # noqa: enable wheels distribution
import setuptools


from gourmet import version
Expand Down Expand Up @@ -212,10 +212,10 @@ def initialize_options(self):

def finalize_options(self):
if self.icon_dir is None:
self.icon_dir = os.path.join("data", "icons")
self.icon_dir = os.path.join("gourmet", "data", "icons")

def run(self):
data_files = self.distribution.data_files
data_files = [] # TODO: What the heck is this method doing?

for size in glob.glob(os.path.join(self.icon_dir, "*")):
for category in glob.glob(os.path.join(size, "*")):
Expand Down Expand Up @@ -343,29 +343,6 @@ def copy_scripts(self):
GTK_LOCALE_DATA = op.join("share", "locale")


def data_files():
"""Build list of data files to be installed"""
data_files = []

for root, _, files in os.walk('data'):
if files:
files = [op.join(root, f) for f in files]
data_files.append((op.join('share',
'gourmet',
root[len('data')+1:]),
files))

# files in /usr/share/X/ (not gourmet)
files = []
base = op.join('share', 'gourmet')

files.extend(data_files)
files.extend([(op.join(base, 'ui'), glob.glob(op.join('ui', '*.ui')))])
files.extend([(op.join('share', 'doc', 'gourmet'), ['FAQ', 'LICENSE'])])

return files


if sys.platform == "win32":
from cx_Freeze import setup, Executable, build as build_cxf
import msilib
Expand Down Expand Up @@ -477,31 +454,26 @@ def finalize_options(self):
}
}
)
else:
from distutils.core import setup
build = build_extra
kwargs = dict(
name=version.name,
data_files=data_files(),
scripts=[op.join('bin', 'gourmet')]
)


plugins = []


def crawl(base, basename):
def crawl_plugins(base, basename):
bdir = base
subdirs = filter(lambda x: op.isdir(op.join(bdir, x)),
os.listdir(bdir))
for subd in subdirs:
name = basename + '.' + subd
plugins.append(name)
crawl(op.join(bdir, subd), name)
crawl_plugins(op.join(bdir, subd), name)


crawl_plugins(op.join('gourmet', 'plugins'), 'gourmet.plugins')

crawl('gourmet/plugins', 'gourmet.plugins')

result = setup(
setuptools.setup(
name=version.name,
version=version.version,
description=version.description,
author=version.author,
Expand All @@ -519,13 +491,39 @@ def crawl(base, basename):
] + plugins,
package_data={'gourmet': ['plugins/*/*.ui',
'plugins/*/images/*.png',
'plugins/*/*/images/*.png']
'plugins/*/*/images/*.png',
'ui/*.ui',
'ui/catalog/*',
'data/recipe.dtd',
'data/WEIGHT.txt',
'data/FOOD_DES.txt',
'data/ABBREV.txt',
'data/nutritional_data_sr_version',
'data/images/no_star.png',
'data/images/splash.png',
'data/images/splash.svg',
'data/images/reccard_edit.png',
'data/images/AddToShoppingList.png',
'data/images/half_gold_star.png',
'data/images/gold_star.png',
'data/images/reccard.png',
'data/sound/phone.wav',
'data/sound/warning.wav',
'data/sound/error.wav',
'data/icons/gourmet.ico',
'data/icons/scalable/apps/gourmet.svg',
'data/icons/48x48/apps/gourmet.png',
'data/style/epubdefault.css',
'data/style/default.css',
]
},
cmdclass={'build': build,
include_package_data=True,
cmdclass={'build': build_extra,
'build_i18n': build_i18n,
'build_icons': build_icons,
'build_py': build_py,
'build_scripts': build_scripts,
},
**kwargs

scripts=[op.join('bin', 'gourmet')],
)

0 comments on commit 1b7fe0e

Please sign in to comment.