Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom directory structure #268

Open
rainman110 opened this issue Mar 4, 2022 · 2 comments · May be fixed by #269
Open

Custom directory structure #268

rainman110 opened this issue Mar 4, 2022 · 2 comments · May be fixed by #269

Comments

@rainman110
Copy link

rainman110 commented Mar 4, 2022

This is probably asked already, but I could not find it here in the issue tracker.

Is there any plan to support a customized directory structure?

Currently, adding FBS to a already existing app needs a complete restructuring of the app, whose new structure does not comply to regular python projects. This seems to be very intrusive for me. A build system / packing system should not require this.

Ideally, the directory structure could be configured with a lets say json file.

By the way, I am willing to support coding - maybe just need some hints where the directory structure is defined etc...

@rainman110
Copy link
Author

rainman110 commented Mar 4, 2022

Implementation hints to myself:

  • The default settings are stored in _defaults/src/build/settings. In particular the base.json file seems to be a good candidate for storing the default paths.
  • the function path from __init__.py allows to query paths that are stored in the settings using the syntax ${my_path}
  • The custom path configuration must be stored in a new file (e.g. fbs_directories.json), that replaces the custom paths if defined. This file path cannot be configured though but must be fixed.

The code for importing the settings need to be altered though:

  • Currently, since the settings paths are fixed, the paths are generated via get_settings_paths, which uses a fixed array of potential setting paths
  • With the proposed change, this needs to be changed such that:
    • Load default (path) settings
    • Load and overwrite paths settings from fbs_directories.json if available
    • Use the imported settings path to read the remaining user settings.
  • The change affects the following functions:
    • activate_profile from fbs/__init__.py
    • load_build_settings from fbs_runtime/_source.py

rainman110 added a commit to rainman110/fbs that referenced this issue Mar 7, 2022
This PR implements a custom directory structure for fbs.
Note: the previous directory structure is still used by default.

Implementation details
----------------------

A customized directory structure is implemented as follows:
 - Default directories are configured in _defaults/src/build/settings/base.json
 - If the file `fbs_directories.json` in the root directory exists
   it will be read by fbs. Here, custom paths can be set, with the following options
    - python_dir : Directory of the python code
    - icons_dir : Directory of the icons
    - resources_dir: Directory of other resources.py
    - settings_dir: Directory of the fbs settings
    - freeze_config_dir: Configuration files for the freeze command
 - Eventually, the remaining fbs settings are read
   (either from the default or user configured path)

I had to alter the check for the root directory, as it assumed a fixed
directory structure. Now, it will check for the default settings path
or the existence of the fbs_directories.json file.

Testing
-------

I tested the functionality on the fbs test app, that is created by the
fbs tutorial. I tested the commands `run`, `freeze` and `installer`
successfully. I tested only on windows though. Mac and Linux are
yet untested.

Closes mherrmann#268
@rainman110 rainman110 linked a pull request Mar 7, 2022 that will close this issue
@jason-SEMCdev
Copy link

What is the syntax for adding custom directories under main/python? How do we specify the directories where we can import scripts from that work in frozen versions of the application?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants