Add new artifact sgr-osx-x86_64.tgz to releases, compiled with pyinstaller --onedir, and default to it in install.sh on Darwin#656
Conversation
- Pass `--onedir` argument intead of `-F` when calling pyinstaller Since spec file is just a Python file, add conditional logic to use Python to create the appropriate `EXE()` and `COLLECT()` TOCs in the spec file based on presence of `--onedir` flag. Existing behavior is retained by default and will always build a single-file executable, except when the `--onedir` flag is contained in `sys.argv` of the `pyinstaller` command that is processing the spec.
- Add steps to `osx_binary` stage to build multi-file executable after also building the single-file executable, and also upload that new artifact to the release To support debugging, add pragma to workflow to build artifacts even if no tag This will build all artifacts, but unless the commit is a tag, it will not create a release or otherwise publish anything. To enable this, also change `.ci/build_wheel.sh` to add support for a `NO_PUBLISH` flag. When the `NO_PUBLISH` environment variable is a non-empty value, do not error if PyPi credentials are not included, and just run `poetry build`
- Default to downloading release at `sgr-osx-x86_64.tgz` when on OS X. This downloads a tarball of the multi-file executable creatd with `pyinstaller --onedir`, which means a directory that includes the `sgr` executable and its dependencies. This performs better than executables generated with `--onefile` on OS X. - Allow overriding and reverting to previous behavior (i.e., downloading the single-file executable which is still addressable at `sgr-osx-x86_64` in the release bundle) with `FORCE_ONEFILE` flag - Unzip the package to `~/.splitgraph/pkg/sgr` (overwrite if exists), then symlink `~/.splitgraph/sgr -> ~/.splitgraph/pkg/sgr/sgr`, in order to keep compatibility with existing scripts - Note: The self-upgrade (`sgr upgrade`) code might still need to be changed.
2bf62d7 to
a8ddd1e
Compare
|
I rebased and cleaned up the commits. If it passes, I'd like to merge it into master. Then I'll follow-up with a separate PR for any changes that might be required for |
sgr-osx-x86_64.tgz to releases, compiled with pyinstaller --onedir, and default to it in install.sh on Darwinsgr-osx-x86_64.tgz to releases, compiled with pyinstaller --onedir, and default to it in install.sh on Darwin
|
The build has passed. You may download the generated artifacts from the actions summary page. Note that all issues described in the description with I have removed the I will now continue with the operation of merging this pull request into the master branch. |
todo:
follow-up PR:
sgr upgradeworks with multi-file executable mode (preferably in a backwards compatible way so existing OS X installations can move seamlessly from single-file to multi-file exec)install.shscript works end to endSummary
sgr-osx-x86_64.tgzsgr, shared libraries, and resourcesDarwinOS,install.shwill:sgr-osx-x86_64.tgzunless$FORCE_ONEFILEis non-empty~/.splitgraph/pkg/sgr(overwrite if exist)~/.splitgraph/sgr -> ~/.splitgraph/pkg/sgr/sgrinstall.sh[artifacts]to build all artifacts but not release themWhy
The single-file executable performs poorly on Mac OS. Most noticeably,
every invocation of a single-file
sgrstarts with a 6-10 second delaywhile Apple verifies the binary (I think with
gatekeeper). Whereaswith a multi-file
sgr, only the first invocation has this delay,and all subsequent invocations are
< 1000mswithout any verificationoverhead.
The reason for this is because the act of verifying the binary
changes its headers in such a way that it needs to be re-verified
before the next invocation. At least, that's what I read in a GitHub
issue in one of the browser tabs that I've since closed.
How
osx_binaryworkflow stage, add steps to build artifactsgr-osx/sgr.tgzupload_releaseworkflow stage, releasesgr-osx/sgr.tgzartifact assgr-osx-x86_64.tgzsplitgraph.spec, when--onediris specified, use theCOLLECTION()targetAlso
NO_PUBLISHflag to.ci/build_wheel.shto not configure any PyPi parametersbuild_and_testworkflow stage, add step to build wheel without publishNote on using
pyinstallerlocally on Mac withpyenvIf developing
splitgraph.specand iterating withpyinstaller, it helpsto have a local environment setup to closely simulate the CI environment,
so in general, try to match whatever steps the workflow is doing. Basically,
this is a summary of the gotchas:
bin/sgrbin/sgr--enable-framework--enable-framework, not--enable-sharedHere is a rough set of post-hoc notes of the commands I used to get
this working locally. It might be missing some details – make sure
after each time switching a virtualenv, that you're in the right one:
You can make sure that your Python installation was compiled with
the correct configuration flags by running the correct
python3-configfor your environment (unfortunately not exposed as
python3-configbypyenv):~/.pyenv/versions/3.7.12/bin/python3.7-config --cflagsThe output should contain an include path that looks like:
Note on gatekeeper
Problem
If you download an artifact from Mac using a web browser, then
you will not be able to execute the artifact, whether downloaded
directly as
sgr-osx-x86_64or extracted fromsgr-osx-x86_64.tgz.This restriction does not apply when downloading a file with
curl.Resolution
Since it only affects files downloaded from web browsers, it does not
affect the
install.shscript, so that continues to be the recommendedinstallation method.
We could change
install.shto remove thecom.apple.quarantineflagfrom the downloaded binary if it exists, but we don't expect it to
exist when downloading via
curl, so it wouldn't make sense.We could join the Apple Developer Program and pay for the privilege
of signing executables with a certificate they will sign too.
We should add a note to each release, and should update the installation
documentation to warn about downloading binaries from a web browser.
Background
Background: On Mac, some files have "extra attributes" set. The
xattrcommand can inspect and modify them. One of these attributes
is
com.apple.quarantine, which web browsers set for any downloaded file.So if you use your web browser to download
sgr-osx-x86_64fromthe releases page, then even after
chmod +x, you will not beable to execute it. Attempts to execute the file will cause the OS
to render a pop-up window refusing to allow it.
Troubleshooting
com.apple.quarantineand gatekeeperTo check if a file has the
com.apple.quarantinebit set, runxattr $filename,for example, to check the
sgrexecutable in the local directory. If yousee
com.apple.quarantine, it's set:You can remove it with the
-dflag. If you remove the flag from a.tgzarchive,then none of the extracted files will have it set. If you do not remove it, then
all of the extracted files will each have it set:
You can recursively remove the flag on all files in a directory:
You can also inspect it further: