3 ms·
djngo.com is the culmination of years of effort, creating a single file python executable that runs on all platforms. This project is based on APE (https://just
by jart 4y ago
djngo.com is the culmination of years of effort, creating a single file python executable that runs on all platforms. This project is based on APE (https://justine.lol/ape.html https://justine.lol/ape.html) and in the past few days, our Python APE port (called python.com) became good enough to run Django. So we put Django inside the executable too, and called it djngo.com. The djngo.com executable will just work on the following platforms:
- Apple x86_64 and ARM64
- Linux running x86_64 or ARM64 (Raspberry Pi)
- Windows running x86_64 and possibly ARM64 too
- FreeBSD, NetBSD, and OpenBSD running x86_64
It does not require that Python be installed beforehand. It's a native Python executable. It does not require Rosetta or Qemu be installed either, in order to run ARM64 platforms. It does not require Cygwin or MSYS2 runtimes in order to run on WIN32. It only depends on KERNEL32. It has an embedded JIT VM called Blink (https://github.com/jart/blink https://github.com/jart/blink) which it pulls out on non-x86 platforms to emulate itself. All its dependencies are bundled inside using a zip polyglot, including the Python standard library:
unzip -vl djngo.com
...
5588 Defl:N 1707 70% 02-23-2023 16:06 26fb04f6 .python/django/shortcuts.py
0 Stored 0 0% 02-23-2023 16:05 00000000 .python/ctypes/
34 Stored 34 0% 02-23-2023 16:05 1b5bb9b2 .python/ctypes/__init__.py
-------- ------- --- -------
35075517 11728493 67% 7171 files
You can put your app's assets inside the djngo.com file too, using the standard zip tool. You can then rename the file, and insert a `.args` file that supplies default args for launching your white-labeled app.
This means that if you're a Django app developer, you can now easily share your apps with others wanting to run it locally. It's almost as easy for anyone on any platform to use, as if you productionized it onto a website. Rather than a hyperlink away, it's a single file download and CLI invocation away. You won't need to explain things like, "here's how you install Python on Windows" or "here's how you install Docker and setup a Linux distro, in order to run my app." Your users will be in full control of the app, granting maximum privacy and control over data, and zero operations toil for you!
- mushufasa 4y agoWhy Django 2.2? That version is no longer supported, and I'm guessing there's some technical reason you are using the obsolete version? (Production Django is now on major version 4)
- ingenieroariel 4y agoThe technical reason for choosing Python 3.6 no longer applies due to how quickly cosmo has advanced in the past months (in particular thread support). jart and ahgamut were the ones who made it happen, I am only a python.com user. But if you want Django 4 and Python 3.11, here is some info copied from the website: 3. Newer Python and newer Django? It is possible to have a djngo.com with Django 4 and Python 3.11. Solved by aghgamut who was the first to port Python to Cosmopolitan. Please note that this Python and the one that djngo.com use are different, the later has been heavily optimized by jart to run well on cosmo, the former is as close as upstream as you can get. Choose your destiny. curl -O https://djngo.com/djngo4-py311.com https://djngo.com/djngo4-py311.com
- jart 4y agoThe cosmo monorepo currently vendors Python 3.6, since cosmo originally didn't have threads support and that was the last version before threads became mandatory. I'm pretty happy with the old version since I've been using Django since the 2000's. I put a lot of work into enhancing monorepo cosmo python with things like a better REPL that works across platforms. It may not be supported by the Python team, but it's supported by me. However the future will probably be building Python w/ Cosmo outside the monorepo. See the other comments for details on how to use APE + Python 3.11 for a modern experience.
- ahgamut 4y agohttps://github.com/ahgamut/cpython/tree/cosmo-djngo https://github.com/ahgamut/cpython/tree/cosmo-djngo Python 3.11.0rc1, Django 4.1.7. I think ingenieroariel also has a binary available on the website. It's a proof-of-concept (because I wrote it just a few hours back), but it shows that we could have the latest version of Python+Django packaged in a single-file executable. Someone could definitely improve upon the build process (like it was done for Python3.6) and add more packages if they wanted.
- deleted 4y ago[deleted]
- ahgamut 4y agoFWIW I imagine we could have added Django to `python.com` sometime last September, which is when I ported Python 3.11.0rc1 (with threads!) to Cosmopolitan Libc: https://github.com/ahgamut/cpython/tree/cosmo_py311 https://github.com/ahgamut/cpython/tree/cosmo_py311 Making Django work on Py3.11 involved the following steps (see commit history for https://github.com/ahgamut/cpython/tree/cosmo_djngo https://github.com/ahgamut/cpython/tree/cosmo_djngo): - add django + deps to the Lib/ folder - add sqlite3 and zlib to the build system - run quick tests and small examples to check the build works I expect there's a bunch of packages like django which can be ported similarly. If anyone's interested, this is a fun area to explore.