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

MAINT: Use bundle_tools_3 and fix various bugs #195

Merged
merged 64 commits into from
Sep 6, 2023
Merged

Conversation

larsoner
Copy link
Member

@larsoner larsoner commented Jul 13, 2023

A naive attempt at conda/constructor#474 (comment)

Closes #204
Closes #191
Closes #190
Closes #182
Closes #181
Closes #131

@jaimergp
Copy link

Btw I am uploading a new constructor beta so re-run the CI in ~30min to 1h to use it. It contains a fix for permission escalation.

@larsoner
Copy link
Member Author

@jaimergp can you remind me how to make the step more verbose so we can see why Windows fails as the NSIS step?

https://github.com/mne-tools/mne-installers/actions/runs/5543849246/jobs/10120455858?pr=195#step:8:605

@larsoner
Copy link
Member Author

No dice with constructor -vvv --debug, still got something not very informative:

INFO:constructor.winexe:Calling: ['C:\\Users\\runneradmin\\micromamba-root\\envs\\constructor-env\\NSIS\\makensis.exe', '/V4', 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpa7np722l\\main.nsi']
Traceback (most recent call last):
  File "C:\Users\runneradmin\micromamba-root\envs\constructor-env\Scripts\constructor-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\runneradmin\micromamba-root\envs\constructor-env\lib\site-packages\constructor\main.py", line 361, in main
    main_build(dir_path, output_dir=out_dir, platform=args.platform,
  File "C:\Users\runneradmin\micromamba-root\envs\constructor-env\lib\site-packages\constructor\main.py", line 185, in main_build
    create(info, verbose=verbose)
  File "C:\Users\runneradmin\micromamba-root\envs\constructor-env\lib\site-packages\constructor\winexe.py", line 429, in create
    process.check_returncode()
  File "C:\Users\runneradmin\micromamba-root\envs\constructor-env\lib\subprocess.py", line 457, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['C:\\Users\\runneradmin\\micromamba-root\\envs\\constructor-env\\NSIS\\makensis.exe', '/V4', 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpa7np722l\\main.nsi']' returned non-zero exit status 1.

@jaimergp
Copy link

I ran it locally and got this:

Name: "MNE-Python 1.4.2_0 (64-bit)"
OutFile: "C:\Users\JaimeRodriguez-Guerr\Downloads\mne-installers-bt3\mne-installers-bt3\MNE-Python-1.4.2_0-Windows.exe"
ShowInstDetails: hide
ShowUninstDetails: hide
SetCompress: off
VIAddVersionKey: "ProductName" "MNE-Python 1.4.2_0 (64-bit)"
VIAddVersionKey: "FileVersion" "1.4.2_0"
VIAddVersionKey: "ProductVersion" "1.4.2_0"
VIAddVersionKey: "CompanyName" "MNE-Python Developers"
VIAddVersionKey: "LegalCopyright" "(c) MNE-Python Developers"
VIAddVersionKey: "FileDescription" "MNE-Python Installer"
VIAddVersionKey: "Comments" "Created by constructor 0+unknown"
BrandingText: "MNE-Python Developers"
!define: "MUI_ICON"="C:\Users\JAIMER~1\AppData\Local\Temp\tmpt2a8qp5w\icon.ico"
!define: "MUI_UNICON"="C:\Users\JAIMER~1\AppData\Local\Temp\tmpt2a8qp5w\icon.ico"
!define: "MUI_HEADERIMAGE"=""
!define: "MUI_HEADERIMAGE_BITMAP"="C:\Users\JAIMER~1\AppData\Local\Temp\tmpt2a8qp5w\header.bmp"
!define: "MUI_HEADERIMAGE_UNBITMAP"="C:\Users\JAIMER~1\AppData\Local\Temp\tmpt2a8qp5w\header.bmp"
!define: "MUI_ABORTWARNING"=""
!define: "MUI_FINISHPAGE_NOAUTOCLOSE"=""
!define: "MUI_UNFINISHPAGE_NOAUTOCLOSE"=""
!define: "MUI_WELCOMEFINISHPAGE_BITMAP"="C:\Users\JAIMER~1\AppData\Local\Temp\tmpt2a8qp5w\welcome.bmp"
!define: "MUI_UNWELCOMEFINISHPAGE_BITMAP"="C:\Users\JAIMER~1\AppData\Local\Temp\tmpt2a8qp5w\welcome.bmp"
!define: "MUI_PAGE_CUSTOMFUNCTION_PRE"="SkipPageIfUACInnerInstance"
!insertmacro: MUI_PAGE_WELCOME
!insertmacro: end of MUI_PAGE_WELCOME
!define: "MUI_PAGE_CUSTOMFUNCTION_PRE"="SkipPageIfUACInnerInstance"
!insertmacro: MUI_PAGE_LICENSE
!insertmacro: end of MUI_PAGE_LICENSE
Page: Custom (creator:InstModePage_Create) (leave:InstModePage_Leave)
!define: "MUI_PAGE_CUSTOMFUNCTION_PRE"="DisableBackButtonIfUACInnerInstance"
!define: "MUI_PAGE_CUSTOMFUNCTION_LEAVE"="OnDirectoryLeave"
!insertmacro: MUI_PAGE_DIRECTORY
!insertmacro: end of MUI_PAGE_DIRECTORY
Page: Custom (creator:mui_AnaCustomOptions_Show)
!insertmacro: MUI_PAGE_INSTFILES
!insertmacro: end of MUI_PAGE_INSTFILES
'
DEBUG:constructor.winexe:makensis stderr:
'Invalid command: "{\rtf1\ansi\ansicpg1252\cocoartf2636"
Error in script "C:\Users\JAIMER~1\AppData\Local\Temp\tmpt2a8qp5w\main.nsi" on line 148 -- aborting creation process
'
Traceback (most recent call last):
  File "C:\Users\JaimeRodriguez-Guerr\devel\conda\devenv\Windows\envs\devenv-3.8-c\envs\constructor-dev\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\JaimeRodriguez-Guerr\devel\conda\devenv\Windows\envs\devenv-3.8-c\envs\constructor-dev\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\JaimeRodriguez-Guerr\devel\conda\devenv\Windows\envs\devenv-3.8-c\envs\constructor-dev\Scripts\constructor.exe\__main__.py", line 7, in <module>
  File "C:\Users\JaimeRodriguez-Guerr\devel\constructor\constructor\main.py", line 351, in main
    main_build(dir_path, output_dir=out_dir, platform=args.platform,
  File "C:\Users\JaimeRodriguez-Guerr\devel\constructor\constructor\main.py", line 175, in main_build
    create(info, verbose=verbose)
  File "C:\Users\JaimeRodriguez-Guerr\devel\constructor\constructor\winexe.py", line 439, in create
    process.check_returncode()
  File "C:\Users\JaimeRodriguez-Guerr\devel\conda\devenv\Windows\envs\devenv-3.8-c\envs\constructor-dev\lib\subprocess.py", line 457, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['C:\\Users\\JaimeRodriguez-Guerr\\devel\\conda\\devenv\\Windows\\envs\\devenv-3.8-c\\envs\\constructor-dev\\NSIS\\makensis.exe', '/V4', 'C:\\Users\\JAIMER~1\\AppData\\Local\\Temp\\tmpt2a8qp5w\\main.nsi']' returned non-zero exit status 1.

It looks like it doesn't like the RTF files for some weird reason? 🤔

@larsoner
Copy link
Member Author

Awesome -- maybe/probably because there is unicode... I'll try opening it in Windows and re-saving it. If that doesn't work I'll remove the unicode and try again!

@larsoner
Copy link
Member Author

None of the unicode rendered well in Windows except for one folder icon, so I just deleted the unicode business and re-saved them. Looks like all files got smaller. 🤞

@jaimergp
Copy link

Mm, no I think it's a bug introduced in this release (probably this line). conclusion_file can also be a NSI script, and in that case it gets inlined. I can see locally that RTF contents were dumped directly in the script.

I think the only workaround for now is to disable the custom conclusion file on Windows installers. I'll open a PR on constructor next week.

Can you open an issue to track this in conda/constructor? Thanks 🙏

@hoechenberger
Copy link
Member

@larsoner Can you revert the change to the RTF file please?

@larsoner
Copy link
Member Author

Have you checked to see if they render on Windows? Only one worked when I loaded it in WordPad and Word for me, all other Unicode characters rendered as weird vertical lines. f you haven't checked I will, and if they don't show on Windows we can either have two sets of files or (my preference) live with not having Unicode anywhere...

@larsoner
Copy link
Member Author

@jaimergp looks like that was the bug on Windows! For macOS now we get an error on installation:

2023-07-13 20:39:37+00 Mac-1689278542280 installer[2912]: install:didFailWithError:Error Domain=PKInstallErrorDomain Code=501 "The package is attempting to install content to the system volume." UserInfo={NSLocalizedDescription=The package is attempting to install content to the system volume.}

and on Linux we have a post-install script meant to fix the .desktop files but it looks like they are no longer produced in $HOME/.local/share/applications:

ℹ️ Fixing menu shortcuts.

sed: can't read ./MNE-Python*.desktop: No such file or directory
ERROR: executing post_install.sh failed

Any thoughts on these?

@hoechenberger
Copy link
Member

hoechenberger commented Jul 14, 2023

@larsoner We're applying a number of patches, maybe they need modification…
For example:
https://github.com/mne-tools/mne-installers/blob/main/assets/constructor_macOS_common.patch

Edit: Then again, this is just for post-install…

@larsoner
Copy link
Member Author

@larsoner We're applying a number of patches,...
Edit: Then again, this is just for post-install…

Actually I don't see these used anywhere other than /tools/build_local.sh, which is not used by CIs. Even worse, build_local.sh references a patch_constructor.sh file that doesn't exist. So I don't think these patches are even used anymore!

$ git grep patch
.github/workflows/build.yml:  workflow_dispatch:
.github/workflows/build.yml:            # … and patched to work around a bug in menuinst
README.md:3. Run `./tools/build_local.sh` (which will patch the constructor on macOS if needed).
assets/constructor_macOS_arm64.patch:diff -Naur constructor-orig/osxpkg.py constructor-patched/osxpkg.py
assets/constructor_macOS_arm64.patch:+++ constructor-patched/osxpkg-patched.py  2022-06-02 23:31:41.000000000 +0200
assets/constructor_macOS_common.patch:diff -Naur constructor-orig/osx/post_extract.sh constructor-patched/osx/post_extract.sh
assets/constructor_macOS_common.patch:+++ constructor-patched/osx/post_extract.sh       2022-03-19 20:28:13.000000000 +0100
assets/constructor_macOS_common.patch:diff -Naur constructor-orig/osxpkg.py constructor-patched/osxpkg.py
assets/constructor_macOS_common.patch:+++ constructor-patched/osxpkg.py 2022-03-19 20:15:12.000000000 +0100
assets/constructor_macOS_i386.patch:diff -Naur constructor-orig/osxpkg.py constructor-patched/osxpkg.py
assets/constructor_macOS_i386.patch:+++ constructor-patched/osxpkg-patched.py   2022-06-02 23:31:41.000000000 +0200
tools/build_local.sh:${SCRIPT_DIR}/patch_constructor.sh

Notably the patch_constructor.sh does not even exist anymore, so we should probably just remove some or all of that stuff as it appears to be cruft (or reintegrate it properly, which you would probably have to do @hoechenberger ).

So the macOS install failure seems new and relevant with bundle_tools_3, and the Linux .desktop files missing also seems relevant @jaimergp !

@jaimergp
Copy link

I would list the contents of the directory. They should be there, but maybe I think the names are now "slugified" so it'd be all lowercase, no spaces etc.

Also, I will fix the .desktop True/true problem on menuinst. Let me know if you find something else!

@jaimergp
Copy link

Also, I will fix the .desktop True/true problem on menuinst. Let me know if you find something else!

Turns out this had been done a while ago too.

@larsoner
Copy link
Member Author

larsoner commented Sep 1, 2023

FYI I set the data retention period to 5 days for this repo directly in main. I then removed the purge-artifacts action that ran daily since I don't think it's necessary anymore -- the repo-level actions retention applies to both CI runs and artifacts (and had already been set at 1 day) so I don't think it's needed anymore -- I think it came from before the artifacts were part of the retention period.

Hopefully the latest commit I pushed is the last one I'll need, and I'll update the URL above to have the latest artifact link once it finishes!

@larsoner larsoner changed the title MAINT: Use bundle_tools_3 MAINT: Use bundle_tools_3 and fix various bugs Sep 1, 2023
:: This is used to initialize the bash prompt on Windows.
@ECHO OFF

call %/home/conda/feedstock_root/build_artifacts/mne-python_1692127656949/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_%\Scripts\Activate.bat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think that the hack of doing menuinst ourselves will not work. Either menuinst or constructor must do something magical here. I'll revert for now but c5dfc2a seems close to what we want

This reverts commit c5dfc2a.
@cbrnr
Copy link
Collaborator

cbrnr commented Sep 2, 2023

I am still debugging Windows a bit but the macOS installers seem to work locally for me on M1 in both single-user mode (but only puts it in ~/Applications, which I guess is the best we can do) and system-wide mode

Quick question, what is the difference between single-user and system-wide modes? Many apps install into ~/Applications when installed as non-root.

Do we mention what exactly happens when running our installers? I'm always concerned with installers modifying stuff that cannot be easily reverted, so if we describe what we're actually doing (e.g. creating which folder) for both modes that would be a great way for people like me to try out our installers.

@larsoner
Copy link
Member Author

larsoner commented Sep 2, 2023

It would be a good idea to add a note about that to the installers page of the MNE-Python docs after we merge this, especially since on Linux and macOS there is no uninstaller so you have to remove things manually

@larsoner
Copy link
Member Author

larsoner commented Sep 2, 2023

... actually I don't like how macOS installs stuff to /Library and /Applications currently. Most applications I have just live in /Applications and if I want them gone I drag them to the trash. I'm going to install to /Applications/MNE-Python/1.5.0_1 instead, which has multiple advantages:

  • allows people to multiple versions installed safely
  • is consistent with other platforms
  • allows the Python distribution to live in /Applications/MNE-Python/1.5.0_1/.mne-python, which is hidden but therefore...
  • ...allows them to uninstall everything just by dragging the 1.5.0_1 or MNE-Python directories to the trash

Then macOS and Windows both uninstall the way users would expect (I think), and Linux is the only annoying one (.desktop files need to be manually removed). I'll push a commit shortly...

@larsoner
Copy link
Member Author

larsoner commented Sep 2, 2023

@jaimergp
Copy link

jaimergp commented Sep 3, 2023

The choice for Library vs Applications was that some users expect things under Applications to be self-contained relocatable, which is not always the case in conda-based installations.

@cbrnr
Copy link
Collaborator

cbrnr commented Sep 3, 2023

The choice for Library vs Applications was that some users expect things under Applications to be self-contained relocatable, which is not always the case in conda-based installations.

But with the changes @larsoner made in this PR, this is now the case, or no? I like that everything is contained in a single folder, which makes uninstalling everything a trivial task.

@larsoner
Copy link
Member Author

larsoner commented Sep 3, 2023

But with the changes @larsoner made in this PR, this is now the case, or no?

I now put everything in Applications, which has the advantage of easy uninstallation but will break if people move things around.

@cbrnr
Copy link
Collaborator

cbrnr commented Sep 3, 2023

Move what around? There's just one folder - it breaks when they move it? If that's the issue, we can document this behavior and tell people to uninstall and then reinstall in the desired location. Or point out that the folder cannot be moved, which is OK, because it is in the expected standard location.

Can you explain the difference between system-wide and user installation?

@larsoner
Copy link
Member Author

larsoner commented Sep 3, 2023

If you try the installer it will probably become clear. But by single user I mean installing to ~/Applications and by system wide I mean to /Applications

@larsoner
Copy link
Member Author

larsoner commented Sep 6, 2023

Okay I added some basic set of dev dependencies (I couldn't even run pytest with the previous version!) and new artifacts are here:

https://github.com/mne-tools/mne-installers/actions/runs/6091167620?pr=195#artifacts

Unless anyone objects I'll merge tomorrow to keep things moving and we can deal with other stuff in follow-up PRs.

@larsoner larsoner merged commit 98d7873 into mne-tools:main Sep 6, 2023
@larsoner larsoner deleted the bt3 branch September 6, 2023 17:51
@larsoner larsoner mentioned this pull request Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants