Skip to content

Commit

Permalink
Use _conf_data
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmayo committed Jul 17, 2023
1 parent 839ea2d commit 75660ef
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
2 changes: 2 additions & 0 deletions _conf_data.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
APP_DATADIR = "@app_datadir@"
VERSION = "@version@"
9 changes: 6 additions & 3 deletions fract4d/fractconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import os
import sys

try:
from ._conf_data import APP_DATADIR
except ImportError:
APP_DATADIR = ".."

CONFIG_FILE = "~/.gnofract4d"


Expand Down Expand Up @@ -132,9 +137,7 @@ def ensure_contains(self, section, required_item):
def get_data_path(subpath=""):
# find where data files are present.
# use share path one level up from module location
moduledir = os.path.dirname(sys.modules[__name__].__file__)
path = os.path.normpath(os.path.join(
moduledir, "../../../../share/gnofract4d", subpath))
path = os.path.join(APP_DATADIR, subpath)
#print("Looking in %s" % path)
return path

Expand Down
6 changes: 4 additions & 2 deletions fract4d/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import sys
from . import fractal as fract4d_fractal

# version of Gnofract 4D
VERSION = '4.3'
try:
from ._conf_data import VERSION
except ImportError:
VERSION = "dev"

POSITION_ARGUMENTS = ("xcenter", "ycenter", "zcenter", "wcenter",
"xyangle", "xzangle", "xwangle", "yzangle", "ywangle", "zwangle",
Expand Down
18 changes: 18 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ foreach p : packages
)
endforeach

conf_data = configuration_data()
conf_data.set('app_datadir', get_option('prefix') / project_datadir)
conf_data.set('version', meson.project_version())
conf_file = configure_file(input : '_conf_data.py.in',
output : '_conf_data.py',
configuration : conf_data,
install : true,
install_dir: py.get_install_dir() / 'fract4d',
)

# Application Data

install_subdir('help',
Expand Down Expand Up @@ -114,6 +124,14 @@ custom_target('cp_gresource',
build_by_default : true,
depends: gresource,
)
custom_target('cp_confdata',
command : [cp,
conf_file,
meson.project_source_root() / 'fract4d/',
],
output : 'none3',
build_by_default : true,
)

test('testing',
find_program('pytest'),
Expand Down

0 comments on commit 75660ef

Please sign in to comment.