-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
Add support for console apps #1781
Conversation
|
||
try: | ||
icon_filename = self.base_path / f"{app.installer_icon}.icns" | ||
# Console apps are installed in /Library/Formal Name, and include the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't console apps also be installed in ~/Library/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ~/Library
installation location is an option if you enable user-specific installs. This implementation doesn't support creating user-specific installers, because there's no reliable user-space analog of /usr/local/bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't you soft link /usr/local/bin/app
to the ~/Library/app
executable in the postinstall
the same way it does now? i guess come to think of it couldn't you just soft link straight to /Applications/app
?
just asking because it seems like most of my installed apps are working with ~/Library
via Application Support/
etc. instead of the system wide /Library
and apple is only getting more and more strict about what is allowed to ever touch system wide stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That approach won't work if there's more than one user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Anthropic statement of work says we would install to /Applications
. That seems to make more sense, because regardless of whether it's a console app or not, it is still an application and not a library.
If this changes, the postinstall script will need to be updated to match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I picked the /Library
location because macOS will surface any .app
that exist in /Applications
or /Users/xxx/Applications
in the Launchpad, and while you would be able to launch a command line app, it wouldn't display a terminal as a result of being launched, so it would look like a no-op.
Putting console apps in /Library
seemed broadly consistent with how tools like Xcode handle console-only tooling. It's a location that is clearly a "system" location; but doesn't result in command line apps surfacing in GUI representations.
It's also worth noting that the install location varies depending on the type of app. A GUI app will install into /Applications
; a console app installs into /Library
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this also applies to subdirectories of /Applications
– for example, the official Python installer creates a directory /Applications/Python 3.x
containing IDLE.app
and Python Launcher.app
, both of which appear in the Launchpad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that makes sense, but since it's a change to the spec, let's remember to mention it to Anthropic next time we send them an update.
i think you may just need to change the line (installer_path / "resources").mkdir(exist_ok=True) to add the edit: changing that line fixed my issue. (installer_path / "resources").mkdir(exist_ok=True, parents=True) |
If you generated the project before you added the The difference between |
|
nevermind - i sorted this out with |
is there any mechanism for injecting custom build options into
If I could somehow specify that in the briefcase config so that |
The PR description does say this:
There's no mechanism to directly manipulate the |
Why not VisualStudio in step 2? |
It's a chicken and egg thing. The VisualStudio template requires the UUID change in this PR, so we can't land the template change without also landing this Briefcase branch. The same problem doesn't exist for the Xcode template because that template doesn't depend on any new Briefcase features. If it would help, I could extract the UUID piece into a standalone PR; it's nicely self contained, and would then allow running the Visual Studio template against a mainline Briefcase. |
Co-authored-by: Malcolm Smith <smith@chaquo.com>
I've opened #1850 to include just the UUID piece; I've modified the landing instructions to reflect the extra step of landing that PR. |
def package_pkg( | ||
self, | ||
app: AppConfig, | ||
notarize_app: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This argument is never used, and the .pkg is never notarized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True - that's a leftover of a feature that I started looking at, then backed out of.
It is possible to sign and notarise installers; however, the signing process requires a separate signing identity to the app distribution signing identity.
This is a solvable problem - one that we should open as a feature ticket as soon as this PR lands - but it's a little fiddly, and AFAICT, it's not needed to use the installer in practice
My inclination is to leave the argument in, even though it isn't used, because it should be used; but I won't argue too hard if you think it should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's keep it but leave a comment in the code explaining the situation.
To test this, we agreed that you'll sign a pkg and send it to me to make sure I can install it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the sudden realization that I have a son with an M1 laptop (🤦), so I’ve just tested the installer on his machine. It works, but it triggers the “unknown developer” handling. It’s installable, but you’ve got to do the “explicit allow” dance through the Settings panel. So, it would appear that notarisation is a necessary step. Any preferences on rolling that change into this PR, vs a follow up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've finished testing on all three platforms and found no other problems, so let's start merging now and do it as a follow-up. I've approved the Xcode and VisualStudio PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it would appear that notarisation is a necessary step.
FWIW technically i don't think this is called "notarization"... that's a whole other process with a whole other developer certificate that you do before submitting to the app store. to get the installer to work without "unknown developer" issues (or at least none beyond right click -> install anyway) you can just run pkgbuild
with the --sign "Developer ID Installer: Nasir Jones (XYZXYZXYZ)"
(note that the Developer ID Installer
is indeed a different certificate from the Apple Development
certificate, as @freakboy3742 said).
my understanding - which is not 100% but i did manage to get a briefcase app into an installer successfully - is that there may be certificate types that can be used for both packaging and notarizing but there are definitely certificate types that will only do one or the other.
edit notarizing is actually a step done by apple - you submit your installer to them and they (somehow) notarize the installer to prep for submission to the app store. my understanding is that this is an optional but encouraged step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok - technically signing is a required step; Notarization is an extra step that you might as well do once you're signing (especially given that we've got notarization ready to go).
However, the key detail is that you can't use the "Developer ID Application" certificate to sign (and thus notarize) the pkg
archive, so additional certificate/identity handling is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this issue has some more of the details on the difference between signing and notarizing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the key detail is that you can't use the "Developer ID Application" certificate to sign
correct
Notarization is an extra step that you might as well do once you're signing
it could very well be but tbh i'm not sure... as far as i can tell (and i could be wrong) to get an app notarized requires sending it to apple and getting something back from them. i don't know if there are any kind of limits on how many packages an app developer can get notarized but i'd be a bit wary of just automatically submitting to apple for notarization every time the package is built (at least not without fully understanding the apple notarization process).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it involves sending code to Apple and getting a response back. Briefcase already manages this process.
And yes, there is a rate limit. You don't want to put notarisation in a daily/every commit CI process, but there's no issue with having lots of apps, as long as you don't try to notarise them all on the same day.
With the macOS app template,
I added
There are at least two problems here:
|
With the Windows app template,
|
Apologies - I had those modifications locally, but managed to not commit them. They're in the template now.
Looks like I forgot to add
Agreed - I've added this to the app template, and opened beeware/briefcase-windows-VisualStudio-template#32 to add the same change to the VS project.
Fixed. |
Adds support for packaging console apps with Briefcase.
In order to support console apps, it is also necessary to introduce a
.pkg
app packaging format for macOS. This generates an installer that is able to perform the post-installation step of adding a symlink to/usr/local/bin
. The PKG format is the default and only packaging format allowed for macOS console apps.This PR also renames the macOS
app
packaging format tozip
- this is for consistency with Windows, to match the actual output format, and to avoid confusion about "packaging an app as an app that is a zip" descriptions.To facilitate easier refactoring of the PKG format, the handling of signing identities on macOS has been modified to introduce a single
SigningIdentity
object that incorporates the id, identity name and team ID into a single object.To enable generation of product GUIDs on Windows, a new
dns_uuid5
template filter has been added. This will convert a domain name likefeature.appname.example.com
into a GUID using the UUID5 algorithm in the DNS namespace.When running console apps (with
dev
orrun
), any output streaming is disabled. This is so that the user gets raw, unbuffered stdout - and especially stdin - access. However, when running a console app in test mode, streaming is enabled, as we need to be able to process test output looking for the sentinel.This branch also adds a
BRIEFCASE_DEBUG
environment variable to the runtime environment if running in debug (i.e.,-vv
mode. One of the major changes to the stub binaries is that they no longer generate the "preamble" console output (detailing the PYTHONPATH etc) unlessBRIEFCASE_DEBUG
is enabled. This allows us to generate console apps that only generate output that the user actually requests, while retaining the ability to get deep debugging information if necessary.Lastly, a new bootstrap (and a testing bootstrap) for console apps has been added.
This code can be tested with the macOS Xcode backend, the windows VisualStudio backend, the linux System backend the Flatpak backend. It requires template modifications to generate console-compatible apps. To test this branch, add:
to your
pyproject.toml
, and run briefcase with:The macOS App template and Windows App template have been partially updated. The logic to generate and handle 2 stub binaries has been added; however, those PRs cannot be completed until the macOS Xcode and Windows VisualStudio template changes have been merged. Inadvertently, this also fixes #1729; by moving the process of renaming the stub from the create step to the build step, we're able to clearly identify if the a build has been performed.
The landing strategy for this:
As an aside: This PR increases the need to address #993, as the app repos have just doubled the number of binaries that are stored. See #1849 for the in-progress work to extract the stub binaries.
briefcase run
fails afterbriefcase create
when using stub app templates #1729Update: 4 Jun
The Xcode template updates have been landed, so
briefcase run macOS Xcode
andbriefcase run Windows VisualStudio
will work without thetemplate_branch
setting.The app templates have been updated with new stub binaries, so
briefcase run
will work as long as thetemplate_branch = "console-app"
setting exists.PR Checklist: