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

POC: Attempt to package jdaviz in cx_Freeze #1936

Closed
wants to merge 8 commits into from

Conversation

duytnguyendtn
Copy link
Collaborator

@duytnguyendtn duytnguyendtn commented Dec 19, 2022

Description

This PR encompasses the learning lessons I've made to package jdaviz in cx_Freeze. Requires #1890

Some background:
cx_Freeze's dependency identification appears to be much more comprehensive, that is, it just bundles all your packages installed in your environment (I was initially confused why I saw pyinstaller packaged 😅). No guessing, no games, it just includes all your environment packages.

cx_Freeze's approach to building is most similar to the, now deprecated, distutils process; that is it embeds itself into a setup.py and is built by invoking python setup.py build. cx_Freeze actually compiles all .py files in all dependencies into python compiled .pyc files and copies those over to the executable. If packages import modules properly, this is absolutely fine and shouldn't create any issue. But for the packages that directly reference/read the source code and EXPECT the .py file to exist, it breaks entirely tsk tsk. On top of this, the story is similar with #1923 and #1914, where I've had to copy over repos with assets that are loaded manually and not through proper import channels.

Ultimately, I was able to get past these challenges and ALMOST get voila to load, but we run into the issue presented by @bmorris3 in #1729 and the voila templates. Unlike PyInstaller, cx_Freeze does not provide a directory for my_venv/share, where the templates are expected to live. As a result, voila doesn't even know where to search for its templates (returns an empty list in the traceback for expected path locations)

Voila Template Traceback
Traceback (most recent call last):
  File "E:\STScI\gitRepos\jdaviz\envhacking\Lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 138, in run
    module_init.run(name + "__main__")
  File "E:\STScI\gitRepos\jdaviz\envhacking\Lib\site-packages\cx_Freeze\initscripts\console.py", line 16, in run
    exec(code, module_main.__dict__)  # pylint: disable=exec-used
  File "start_jdaviz.py", line 3, in <module>
    main()
  File "E:\STScI\gitRepos\jdaviz\build\exe.win-amd64-3.10\lib\jdaviz\cli.py", line 86, in main
    sys.exit(Voila().launch_instance(argv=[]))
  File "E:\STScI\gitRepos\jdaviz\envhacking\lib\site-packages\traitlets\config\application.py", line 975, in launch_instance
    app.initialize(argv)
  File "E:\STScI\gitRepos\jdaviz\envhacking\lib\site-packages\voila\app.py", line 374, in initialize
    self.setup_template_dirs()
  File "E:\STScI\gitRepos\jdaviz\envhacking\lib\site-packages\voila\app.py", line 380, in setup_template_dirs
    self.template_paths = collect_template_paths(['voila', 'nbconvert'], template_name, prune=True)
  File "E:\STScI\gitRepos\jdaviz\envhacking\lib\site-packages\voila\paths.py", line 24, in collect_template_paths
    return collect_paths(app_names, template_name, include_root_paths=True, prune=prune, root_dirs=root_dirs)
  File "E:\STScI\gitRepos\jdaviz\envhacking\lib\site-packages\voila\paths.py", line 90, in collect_paths
    raise ValueError(
ValueError: No template sub-directory with name 'base' found in the following paths:

(envhacking) PS E:\STScI\gitRepos\jdaviz>

If I hack voila and hardcode the template path, Voila actually successfully loads, but then is missing other templates as well, indicating multiple overrides would be necessary in order to properly masquerade voila's template discovery algorithm.

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@pllim
Copy link
Contributor

pllim commented Feb 10, 2023

I think we agreed that this isn't the installer we were looking for.

@pllim pllim closed this Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants