-
-
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 a Deb packaging backend #1081
Conversation
Now I'm getting what might be some python version confusion. When I run |
Sounds like you might have an old version of pip? PEP517 editable installs need a fairly recent version (22.something, I think?)
Oops - thanks; I've corrected the example.
Ah - ok; that's a good clarification. If you build in Docker, all the system requirements (
Hrm - I can't see an obvious cause for this in the logs; my best guess is that something about the error you got with pycairo got the app into a weird state.
If toga is in the |
Success!
|
@flowerncsu Awesome - thanks for that testing! |
My high-level thoughts so far: Install Location:
|
Thanks for this feedback - it's really helpful.
Yeah - and that was what I was following by picking
Yes, but I'm definitely open for debate on the topic. Here's my reasoning:
The alternatives I can see would be:
To my mind, "use the system Python" is the best of a bunch of bad options. Deadsnakes could even be added as an option on top of the current implementation; By default, package for the system python; but with an opt-in option on DEB configs ( Looking to #1063 and #1064 for related concerns: On Redhat (and variants) there are more options (RHEL8 provides Python3.6, 3.8 and 3.9 for example), but there's no analog of deadsnakes (that I'm aware of); Arch et al provide source packages for everything, so I'm fairly certain you can reference a specific version in package dependencies.
Ummm.... because all the online tutorials I found used dkpg-deb? What's the alternative?
Yeah - I wasn't aware of Lintian until after I asked publicly for feedback (the same tutorials that told me about dpkg-deb neglected to mention it 😄) Most of these should be fairly straightforward to accomodate; moving to
Yeah - this is definitely something that needs to be corrected... as soon as I can work out what "correct" is 😄 |
So, from everything I've read, Honestly, though, this feels a bit like when I started using Python and first attempted to create a package for PyPI. You find all these tools for managing the whole life cycle of your project and it isn't really clear what's the best option. |
I don't have a particularly strong conviction we shouldn't use the System Python. I sympathize with the "integrated system" approach and am aligned on the principle. However, IMO, when the rubber hits the road for distro-shipped Python...it introduces a layer of limitations for the developer that are really quite artificial. (e.g. Ubuntu 20.04 LTS doesn't run out until 2030 but its Python is done in 20 months :/). On the other hand, I think any future state should allow users to disable including a whole Python in their app when they know the System Python addresses their needs; so, if this potentially ends up just being the first version of deb support, I'm on board. On the third hand, this may be a good use case for Greg's standalone Python... p.s. i did find these folks advertising support for bundling python in a deb....just as doc of prior art. |
Absolutely. From my non-linux-user perspective, I don't understand how Debian/Ubuntu considers this situation tenable. I hope they enjoy taking responsibility for backporting all the security patches (they are backporting security patches, right...?). But - not my circus, not my monkeys... :-)
How about this as a proposal: we introduce a
My inclination is to use This does mean we need to test 3 versions of the deb app,
Interesting... I'll check it out to see if there's something we can use/adapt/copy. |
I asked my friend (who it turns out wrote a bunch of omnibus) - and it turns out it won't help us that much. Firstly, that repo is "last modified 10 years ago"; secondly, Omnibus isn't really doing much more than we're doing right now. Omnibus is a tool for building a bunch of packages once you've already sorted out the "how to lay out your project on the filesystem" problem. From a packaging perspective, it's wrapping fpm which might be a marginal helper around building deb and rpm packages, but adding a dependency on a third party tool to avoid writing a single metadata file (losing the direct control over that file in the process) and invoking |
I like this idea. I think
:)
whoops....how did i miss that, haha
Agreed; it looks like if we can get these control files populated properly, building the actual |
Ok - I'll update the PR to head in this direction. As an aside - it occurs to me that converging on standalone would benefit both the AppImage backend (since we no longer need to maintain the Python-linux-support repo), and the Flatpak backend (as we would no longer need a full CPython source build, which is a significant part of the Flatpak build time). Sharing a common Linux build resource across all three would also be a nice from an architectural point of view. Windows is already using an "official" embedded install; so I don't think there's a whole lot to be gained by switching there; Greg's macOS builds aren't universal, so they're not an option (at least until macOS drops x86_64 support). Plus, we'll have to maintain the Apple build chain for iOS anyway, as that's a platform he doesn't support at present. |
Yes, they are, and I think this is one of the main motivations for their rule of only having one copy of each component on the system. Once they release a security update for Python, they can be confident that every Python-based package on the system immediately benefits from it. It's very good for stability, but not so good for being able to run fast-moving projects like BeeWare. If we follow our usual principle that the Python version of the app matches the version the user is running Briefcase with, then maybe we can detect the situation where that doesn't match the version supported by the distribution they're targeting, and suggest that they use the standalone mode instead. |
In the current "always use system" implementation, there's already a warning in place advising that the python being used for packaging doesn't match the briefcase python; it definitely makes sense to extend that message to include the tip that using standalone/deadsnakes is also an option. In terms of exposure to this particular bug:
Given that we're going to need to advise people to build multiple DEBs, one for each distro (Debian {10, 11} and Ubuntu {20.04, 22.04, ...}) then warnings are going to be mostly inevitable for the |
I've now audited the output of the deb package with lintian; it's now runnining clean for me. I've also added in support for deadsnakes as a Python source. Still no tests yet, but feedback welcome. |
I can see this mentioned in the doucmentation, but is there an implementation yet? Last time I checked, deadsnakes was only compatible with Ubuntu. There were some similar unofficial Python backports for Debian, but they weren't being updated so consistently. So instead of hardcoding deadsnakes, how about allowing the user to specify an arbitrary repository address, and including instructions in the documentation for how to point this at deadsnakes? |
Cancel that: "large diffs are not rendered by default" strikes again. |
Oh bother - you're right. I had forgotten that it was an Ubuntu-specific thing.
I guess we could do that... but what other repository address are people going to use? Is there another repo of Python installs that Debian users are likely to know and trust? And - more importantly - one where the only change required is replacing I guess we could modify the code to accept any source starting with We can then focus on adding support for python-standalone as a "real" alternative. I was originally thinking of landing this PR with just "system" and "deadsnakes", and then tackle introducing python-standalone as a separate feature that all the Linux backends can benefit from; perhaps it's worth rolling standalone into this PR, and treat extending standalone into appImage and flatpak as follow-on work. |
The original point of this PR was to allow developers to build packages that are trivial for an end-user to install, and "add this extra package repository to your system configuration" doesn't achieve that. So maybe the whole deadsnakes option is more trouble than it's worth, and we should just provide system and standalone. |
@mhsmith I guess this is the point where I don't have enough practical experience as a Linux user to say for certain. My impression is that Linux native app packaging is always a bit eldritch. Linux users have already accepted a level of system administration responsibility that is higher than your average macOS/Windows user, but adding a PPA is (at least in the Ubuntu world) a not entirely unheard of as a practice. The DEB distribution process is already going to involve picking from multiple binaries. Having 1-2 extra sysadmin lines to add a PPA as a pre-requisite - something that end users may have already done if they're actively using Python - doesn't seem that onerous given the headaches that seem to exist with distributing packages in general. From our end, the implementation is fairly straightforward - the same 2 sysadmin lines and one extra Overall - my impression is that deadsnakes support is something that enough users could find useful, and the implementation isn't that complex to maintain. I agree we should add standalone as well, but I don't think the situation is bad enough that we should strip deadsnakes. |
Speaking as someone who's used a Linux system primarily for over a decade, my feeling tends to be that if I really need/want a given app, and I need to add a package repo to do it, I'll do it, but I definitely look for an alternative before doing that. On average I'd say I install something that needs one about once a year. So it may make sense to include as an option for the occasional use case where it matters, but I'm not sure if the feature maintenance is worth the small category of edge cases where system python wouldn't do. It might be good to nudge app creators towards figuring out how to work with system python instead. |
Thanks for that data point @flowerncsu. Reading between the lines - is the implication that as a Python user, your general strategy for ensuring you have an up-to-date user-space Python is "update your distro", rather than "use Deadsnakes" - and that Deadsnakes is more of a cover-all for CI-type situations where you need to test against different Python versions? |
Yes, typically I just install python from the standard package repo. It tends to lag about a version behind the most current stable python version but is plenty sufficient the majority of the time. I don't think I've ever put deadsnakes on my personal computer, though I've used it for work before. |
I've done some experimentation with python-standalone, and I'm not convinced it's actually a way forward - at least, not for native system packages. Firstly, it's not quite as "standalone" as I thought it was. The Linux binaries appear to have lots of hard-coded paths that assume it's going to be installed in Secondly - and this is perhaps the bigger issue - packaging an embedded Python interpreter seems to cause the DFSG guidelines a minor hernia. Running lintian on a standalone-based package causes all manner of It also throws This comes back to the "Debian really wants you to build an integrated system" argument - and my impression is that if we try to fight that, we're going to end up with a package that doesn't actually meet the expectations of Debian users - even if that does mean violating expectations they might have a Briefcase users. To that end - I think Briefcase is the one that has to blink in this game of chicken. We're trying to follow the "when in Rome" philosophy, and build packages that appear "as native as possible"; in this case, I get the distinct impression that trying to do the Briefcase thing of adhering to a constant Python version will get us identified as tourists :-) To be clear - I think it's still work adding standalone support for AppImage and Flatpak (and not that much effort, either); in both those situations, the Python interpreter is working in a sandbox, so the /usr/lib environment is at least closer to the actual runtime location (and to the extent it isn't, it's not competing with a system python). |
Hmm....this seems to contradict a lot of the purpose of the standalone python project. Although, discussing this is probably moot given the rest of the post.
Or at least, this is unlikely to meet the expectations of a Debian administrator....albeit that's arguably just pedantic semantics. At any rate, if one continues following Greg's path after python-build-standalone, we'll find PyOxidizer which he offered an explanation for and of....ultimately arguing that bundling Python is the most correct solution....even when a "system python" is available. While the "integrated system" debate remains, I wonder if Python (or perhaps any interpreter) could be reasonably considered external to the debate. Nonetheless, we're already wearing togas, so why not also use the local thermae :) It seems most likely the majority of Briefcase projects targeting recent distro releases won't have terrible compatibility issues. Additionally, I can't find good evidence that bundling Python (whether for pure python projects or otherwise) is more popular than leveraging a system python. Personally, I run most things in a docker container....which I guess is nearly the opposite of integrated system in many ways. p.s. This additionally makes we wonder if just creating a fat binary with pyinstaller or pyoxidizer to have |
I've now got test coverage for a "system + dead snakes" version of this PR. The latest update has also done some refactoring, pulling out some common parts of the "running in Docker" code (mostly so I have less tests to write :-)
|
Yeah - this is an extension of the "system python is not your python" debate; but I think our case is a little different, because what we're shipping is a binary app that uses the standard library, but none of the system-installed packages. We're just using the system Python for its interpreter.
This, for me, is the biggest reason why I don't see a huge issue with matching system Python, rather than Briefcase python.
FWIW: They are :-) |
Closing this in favour of #1106. |
Adds a .deb packaging backend. Fixes #1062.
This is a work in progress. It doesn't currently have any tests, and there's a lot of refactoring that can be done to share pieces between the AppImage and Deb backends (as they're both docker builds; an RPM backend will likely also share this infrastructure). However, it's at the point where community feedback would be useful.
To test a Toga app named
togatest
, check out this PR branch and install it (pip install -e path/to/checkout
), runbriefcase new
to generate a new project with an app name oftogatest
, then add the following to your project's pyproject.toml:system_requires
are the packages needed to build your app;system_runtime_requires
are the packages that need to exist at runtime. If you're building a non-Toga app, or you have dependencies that aren't provided as manylinux wheels, you'll likely need to update both these settings. Manylinux wheels should work without any need to update either setting.There is a
deb
branch on briefcase-template, plus a new briefcase-linux-deb-template. The deb template should be picked up without any additional configuration; you'll need to clone the briefcase-template locally if you want to test that one.If you're on a Debian-derived operating system, you can build and run the app natively:
If you're on macOS, or any Linux, and you have Docker:
will produce a
.deb
file in thelinux
folder.ubuntu:jammy
is the vendor and codename of any Debian-derived distribution that has a Docker image (so -debian:bullseye
andubuntu:focal
will also work). If you're on the target platform, you can then runsudo apt install <name of deb pkg>
to install the app. On installation, the app should appear in your desktop menus.Some questions for testers:
system_requires
andsystem_runtime_requires
?PR Checklist: