django-native 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_native/__init__.py +6 -0
- django_native/__main__.py +4 -0
- django_native/analysis/__init__.py +106 -0
- django_native/analysis/resources.py +65 -0
- django_native/application/__init__.py +163 -0
- django_native/backends/__init__.py +71 -0
- django_native/backends/nuitka.py +87 -0
- django_native/cli/__init__.py +0 -0
- django_native/cli/app.py +202 -0
- django_native/configuration/__init__.py +193 -0
- django_native/diagnostics/__init__.py +71 -0
- django_native/django_app/__init__.py +1 -0
- django_native/django_app/apps.py +7 -0
- django_native/django_app/management/__init__.py +0 -0
- django_native/django_app/management/commands/__init__.py +0 -0
- django_native/django_app/management/commands/native.py +56 -0
- django_native/environments/__init__.py +54 -0
- django_native/packaging/__init__.py +103 -0
- django_native/planning/__init__.py +98 -0
- django_native/plugins/__init__.py +31 -0
- django_native/project/__init__.py +220 -0
- django_native/resources/__init__.py +0 -0
- django_native/runtime/__init__.py +75 -0
- django_native/validation/__init__.py +44 -0
- django_native-0.2.0.dist-info/METADATA +764 -0
- django_native-0.2.0.dist-info/RECORD +29 -0
- django_native-0.2.0.dist-info/WHEEL +4 -0
- django_native-0.2.0.dist-info/entry_points.txt +5 -0
- django_native-0.2.0.dist-info/licenses/LICENSE +0 -0
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: django-native
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Build Django. Compile. Package. Distribute.
|
|
5
|
+
Project-URL: Homepage, https://github.com/django-native/django-native
|
|
6
|
+
Project-URL: Documentation, https://django-native.readthedocs.io
|
|
7
|
+
Project-URL: Source, https://github.com/django-native/django-native
|
|
8
|
+
Project-URL: Changelog, https://github.com/django-native/django-native/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/django-native/django-native/issues
|
|
10
|
+
Author: Django Native Contributors
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: compiler,distribution,django,nuitka,packaging
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Framework :: Django
|
|
16
|
+
Classifier: Framework :: Django :: 4.2
|
|
17
|
+
Classifier: Framework :: Django :: 5.0
|
|
18
|
+
Classifier: Framework :: Django :: 5.1
|
|
19
|
+
Classifier: Framework :: Django :: 5.2
|
|
20
|
+
Classifier: Intended Audience :: Developers
|
|
21
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
22
|
+
Classifier: Operating System :: OS Independent
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Typing :: Typed
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Requires-Dist: click>=8.1
|
|
31
|
+
Requires-Dist: tomli>=2.0; python_version < '3.11'
|
|
32
|
+
Provides-Extra: compile
|
|
33
|
+
Requires-Dist: nuitka>=2.0; extra == 'compile'
|
|
34
|
+
Requires-Dist: ordered-set>=4.1; extra == 'compile'
|
|
35
|
+
Requires-Dist: zstandard>=0.22; extra == 'compile'
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: django>=4.2; extra == 'dev'
|
|
39
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
40
|
+
Requires-Dist: pytest-cov>=4.1; extra == 'dev'
|
|
41
|
+
Requires-Dist: pytest>=7.4; extra == 'dev'
|
|
42
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
43
|
+
Requires-Dist: twine>=4.0; extra == 'dev'
|
|
44
|
+
Provides-Extra: django
|
|
45
|
+
Requires-Dist: django>=4.2; extra == 'django'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# Django Native
|
|
49
|
+
|
|
50
|
+
> **Build Django. Compile. Package. Distribute.**
|
|
51
|
+
|
|
52
|
+
[](https://pypi.org/project/django-native/)
|
|
53
|
+
[](https://pypi.org/project/django-native/)
|
|
54
|
+
[](https://www.djangoproject.com/)
|
|
55
|
+
[](https://github.com/django-native/django-native/actions/workflows/tests.yml)
|
|
56
|
+
[](https://github.com/django-native/django-native/actions/workflows/lint.yml)
|
|
57
|
+
[](https://github.com/django-native/django-native/actions/workflows/security.yml)
|
|
58
|
+
[](LICENSE)
|
|
59
|
+
|
|
60
|
+
**Django Native** is an open-source, Python-first toolkit for building Django projects, analysing their dependencies and resources, generating versioned build plans, compiling applications to native binaries, and packaging the result as distributable, validatable artifacts.
|
|
61
|
+
|
|
62
|
+
It is designed for developers who want to **ship Django applications as standalone executables, portable bundles, or deployable artifacts** — without leaving the Python ecosystem.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Table of contents
|
|
67
|
+
|
|
68
|
+
- [What Django Native is](#what-django-native-is)
|
|
69
|
+
- [What Django Native is not](#what-django-native-is-not)
|
|
70
|
+
- [Who it's for](#who-its-for)
|
|
71
|
+
- [Features](#features)
|
|
72
|
+
- [Installation](#installation)
|
|
73
|
+
- [Quick start](#quick-start)
|
|
74
|
+
- [The workflow](#the-workflow)
|
|
75
|
+
- [CLI reference](#cli-reference)
|
|
76
|
+
- [Django management command](#django-management-command)
|
|
77
|
+
- [Configuration](#configuration)
|
|
78
|
+
- [Build manifest](#build-manifest)
|
|
79
|
+
- [Runtime profiles](#runtime-profiles)
|
|
80
|
+
- [Compiler backends](#compiler-backends)
|
|
81
|
+
- [Plugin system](#plugin-system)
|
|
82
|
+
- [Compatibility](#compatibility)
|
|
83
|
+
- [Project status](#project-status)
|
|
84
|
+
- [Development](#development)
|
|
85
|
+
- [Architecture](#architecture)
|
|
86
|
+
- [Contributing](#contributing)
|
|
87
|
+
- [Security](#security)
|
|
88
|
+
- [License](#license)
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## What Django Native is
|
|
93
|
+
|
|
94
|
+
Django Native is a **workflow layer** on top of Django and Nuitka. It provides:
|
|
95
|
+
|
|
96
|
+
- **Project scaffolding** — `django-native init` creates a standard Django project with a `django-native.toml` configuration file.
|
|
97
|
+
- **Project intelligence** — `django-native inspect` analyses your project: distributions, imports, dynamic imports, installed apps, templates, static files, migrations, translations.
|
|
98
|
+
- **Build planning** — `django-native plan` produces a versioned, hashable, inspectable **build manifest** describing exactly what will be compiled and packaged.
|
|
99
|
+
- **Native compilation** — `django-native build` invokes a compiler backend (Nuitka by default) to produce a native binary.
|
|
100
|
+
- **Runtime generation** — a launcher is generated that boots your Django app under a chosen runtime profile (`local`, `server`, `portable`).
|
|
101
|
+
- **Packaging** — `django-native package` assembles compiled output + resources into a distributable directory and `.zip` with checksums.
|
|
102
|
+
- **Validation** — `django-native test` verifies that the packaged artifact actually launches and responds, not just that compilation returned exit code 0.
|
|
103
|
+
|
|
104
|
+
Django Native never rewrites your Django settings, never monkey-patches Django internals, and never requires you to change how you develop locally. **A project that runs with `python manage.py runserver` today is a project Django Native can compile tomorrow** — subject to the compatibility scope documented below.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## What Django Native is not
|
|
109
|
+
|
|
110
|
+
To set accurate expectations:
|
|
111
|
+
|
|
112
|
+
| Not this | Reason |
|
|
113
|
+
|----------|--------|
|
|
114
|
+
| A replacement for Django | Django is a dependency; Django Native wraps it. |
|
|
115
|
+
| A replacement for Python | Compilation targets are Python applications. |
|
|
116
|
+
| A compiler written in Go or Rust | Compilation is delegated to Nuitka. |
|
|
117
|
+
| A replacement for Nuitka | Nuitka is the default backend; others are pluggable. |
|
|
118
|
+
| A hosting provider | Distribution is left to you. |
|
|
119
|
+
| A magic bullet for every app | Dynamic imports, native extensions, and some third-party packages require explicit configuration. |
|
|
120
|
+
|
|
121
|
+
**Django Native does not guarantee** that *every* Django application can be compiled without modification. It guarantees that **applications within the documented compatibility scope will compile, package, and validate** — and that anything outside it will be reported explicitly, not silently.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Who it's for
|
|
126
|
+
|
|
127
|
+
- Django developers shipping internal tools as desktop-like apps.
|
|
128
|
+
- Agencies delivering portable client applications.
|
|
129
|
+
- Businesses distributing compiled Django backends to servers.
|
|
130
|
+
- Developers building specialised compiler or packaging integrations.
|
|
131
|
+
- Anyone who wants to test whether their Django project is compilable.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Features
|
|
136
|
+
|
|
137
|
+
| Category | Command | Status |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| Project creation | `django-native init` | ✅ Stable |
|
|
140
|
+
| Project inspection | `django-native inspect` | ✅ Stable |
|
|
141
|
+
| Dependency analysis | (via `inspect`) | ✅ Stable |
|
|
142
|
+
| Resource analysis | (via `inspect`) | ✅ Stable |
|
|
143
|
+
| Build planning | `django-native plan` | ✅ Stable |
|
|
144
|
+
| Environment checks | `django-native doctor` | ✅ Stable |
|
|
145
|
+
| Native compilation | `django-native build` | ⚗️ Experimental |
|
|
146
|
+
| Runtime launcher generation | (via `package`) | ⚗️ Experimental |
|
|
147
|
+
| Packaging | `django-native package` | ⚗️ Experimental |
|
|
148
|
+
| Artifact validation | `django-native test` | ⚗️ Experimental |
|
|
149
|
+
| Plugin discovery | `django-native plugin list` | ✅ Stable |
|
|
150
|
+
| Backend discovery | `django-native backend list` | ✅ Stable |
|
|
151
|
+
| Configuration override | `django-native config` | ✅ Stable |
|
|
152
|
+
| Cleanup | `django-native clean` | ✅ Stable |
|
|
153
|
+
|
|
154
|
+
Additional capabilities — compiler plugins, CI/CD integrations, installer generation for Windows/Linux/macOS, container build adapters, remote build environments — are planned and tracked in the [roadmap](#project-status).
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Installation
|
|
159
|
+
|
|
160
|
+
Django Native requires **Python 3.10+**.
|
|
161
|
+
|
|
162
|
+
### Base install (project creation, inspection, planning)
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pip install django-native
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### With compilation support (adds Nuitka)
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pip install "django-native[compile]"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Compilation additionally requires a **C/C++ toolchain** on your system:
|
|
175
|
+
|
|
176
|
+
- **Windows** — Visual Studio Build Tools (MSVC) or MinGW-w64.
|
|
177
|
+
- **Linux** — `gcc` / `clang` and `python3-dev`.
|
|
178
|
+
- **macOS** — Xcode Command Line Tools.
|
|
179
|
+
|
|
180
|
+
Run `django-native doctor` to verify all prerequisites.
|
|
181
|
+
|
|
182
|
+
### With uv (recommended for development)
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
uv add django-native
|
|
186
|
+
# or:
|
|
187
|
+
uv pip install django-native
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Quick start
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# 1. Create a new Django project
|
|
196
|
+
django-native init inventory
|
|
197
|
+
cd inventory
|
|
198
|
+
|
|
199
|
+
# 2. Run it normally — nothing about your Django project has changed
|
|
200
|
+
python manage.py runserver
|
|
201
|
+
|
|
202
|
+
# 3. Inspect what Django Native sees
|
|
203
|
+
django-native inspect
|
|
204
|
+
|
|
205
|
+
# 4. Produce a build plan (JSON manifest, no compilation)
|
|
206
|
+
django-native plan --output build-plan.json
|
|
207
|
+
|
|
208
|
+
# 5. Compile to a native binary
|
|
209
|
+
django-native build
|
|
210
|
+
|
|
211
|
+
# 6. Package the compiled output with resources
|
|
212
|
+
django-native package
|
|
213
|
+
|
|
214
|
+
# 7. Validate the resulting artifact
|
|
215
|
+
django-native test
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
A successful run produces:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
dist/
|
|
222
|
+
└── inventory/
|
|
223
|
+
├── inventory.exe # or `inventory` on POSIX
|
|
224
|
+
├── launcher.py
|
|
225
|
+
├── resources/
|
|
226
|
+
│ ├── templates/
|
|
227
|
+
│ ├── static/
|
|
228
|
+
│ ├── migrations/
|
|
229
|
+
│ └── translations/
|
|
230
|
+
├── package-manifest.json
|
|
231
|
+
├── checksums.txt
|
|
232
|
+
└── data/ # persistent runtime data
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## The workflow
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
┌─────────────────┐
|
|
241
|
+
│ Django project │ python manage.py runserver works today
|
|
242
|
+
└────────┬────────┘
|
|
243
|
+
│
|
|
244
|
+
▼
|
|
245
|
+
┌─────────────────┐
|
|
246
|
+
│ inspect │ → distributions, imports, apps, resources
|
|
247
|
+
└────────┬────────┘
|
|
248
|
+
│
|
|
249
|
+
▼
|
|
250
|
+
┌─────────────────┐
|
|
251
|
+
│ plan │ → build-plan.json (versioned, hashable)
|
|
252
|
+
└────────┬────────┘
|
|
253
|
+
│
|
|
254
|
+
▼
|
|
255
|
+
┌─────────────────┐
|
|
256
|
+
│ build │ → native binary (via Nuitka backend)
|
|
257
|
+
└────────┬────────┘
|
|
258
|
+
│
|
|
259
|
+
▼
|
|
260
|
+
┌─────────────────┐
|
|
261
|
+
│ package │ → dist/<app>/ + dist/<app>.zip + checksums
|
|
262
|
+
└────────┬────────┘
|
|
263
|
+
│
|
|
264
|
+
▼
|
|
265
|
+
┌─────────────────┐
|
|
266
|
+
│ test │ → PASS / FAIL on the *actual artifact*
|
|
267
|
+
└─────────────────┘
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Every stage is **deterministic and inspectable**. The build manifest from `plan` is the contract that `build` and `package` both consume.
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## CLI reference
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
django-native [OPTIONS] COMMAND [ARGS]...
|
|
278
|
+
|
|
279
|
+
Commands:
|
|
280
|
+
init NAME Create a new Django project
|
|
281
|
+
inspect Inspect the current Django project
|
|
282
|
+
plan Produce a build manifest without compiling
|
|
283
|
+
build Compile the current project
|
|
284
|
+
package Package compiled output into a distributable artifact
|
|
285
|
+
test Validate the packaged application
|
|
286
|
+
doctor Check the local environment
|
|
287
|
+
config Show the effective configuration
|
|
288
|
+
clean Remove build artifacts
|
|
289
|
+
|
|
290
|
+
backend list List available compiler backends
|
|
291
|
+
plugin list List installed plugins
|
|
292
|
+
|
|
293
|
+
Options:
|
|
294
|
+
-V, --version Show version and exit
|
|
295
|
+
-h, --help Show this message and exit
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Common options
|
|
299
|
+
|
|
300
|
+
| Flag | Applies to | Purpose |
|
|
301
|
+
|---|---|---|
|
|
302
|
+
| `--json` | `inspect`, `plan` | Emit machine-readable JSON |
|
|
303
|
+
| `--output PATH` | `plan` | Write the manifest to a file |
|
|
304
|
+
| `--directory PATH` | `init` | Create the project inside `PATH` |
|
|
305
|
+
| `--force` | `init` | Allow creating inside a non-empty directory |
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Django management command
|
|
310
|
+
|
|
311
|
+
The same underlying services are exposed as a Django management command, so you can run Django Native operations without leaving `manage.py`:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
python manage.py native inspect
|
|
315
|
+
python manage.py native plan --output build-plan.json
|
|
316
|
+
python manage.py native build
|
|
317
|
+
python manage.py native package
|
|
318
|
+
python manage.py native test
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Enable the command by adding `django_native.django_app` to `INSTALLED_APPS`:
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
INSTALLED_APPS = [
|
|
325
|
+
# …
|
|
326
|
+
"django_native.django_app",
|
|
327
|
+
]
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Both interfaces call the same `django_native.application` services. There is no behavioural drift between the CLI and the management command.
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Configuration
|
|
335
|
+
|
|
336
|
+
Configuration lives in `django-native.toml` at the project root. It is generated by `django-native init` and validated on every command.
|
|
337
|
+
|
|
338
|
+
```toml
|
|
339
|
+
[project]
|
|
340
|
+
name = "inventory"
|
|
341
|
+
settings = "inventory.settings"
|
|
342
|
+
|
|
343
|
+
[compiler]
|
|
344
|
+
backend = "nuitka"
|
|
345
|
+
mode = "standalone"
|
|
346
|
+
|
|
347
|
+
[build]
|
|
348
|
+
output = "dist"
|
|
349
|
+
clean = true
|
|
350
|
+
jobs = 4
|
|
351
|
+
|
|
352
|
+
[target]
|
|
353
|
+
platform = "native"
|
|
354
|
+
architecture = "native"
|
|
355
|
+
|
|
356
|
+
[resources]
|
|
357
|
+
collect_static = true
|
|
358
|
+
include_templates = true
|
|
359
|
+
include_migrations = true
|
|
360
|
+
include_translations = true
|
|
361
|
+
|
|
362
|
+
[runtime]
|
|
363
|
+
profile = "local"
|
|
364
|
+
host = "127.0.0.1"
|
|
365
|
+
port = 8000
|
|
366
|
+
open_browser = true
|
|
367
|
+
migrations_on_startup = false
|
|
368
|
+
|
|
369
|
+
[database]
|
|
370
|
+
strategy = "persistent"
|
|
371
|
+
|
|
372
|
+
[analysis]
|
|
373
|
+
strict = false
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Precedence
|
|
377
|
+
|
|
378
|
+
When the same value is defined in multiple places, the highest wins:
|
|
379
|
+
|
|
380
|
+
1. **Explicit CLI arguments** — `--output dist2`, etc.
|
|
381
|
+
2. **Environment overrides** — `DJANGO_NATIVE_RUNTIME_PORT=9000`
|
|
382
|
+
3. **Project configuration** — `django-native.toml`
|
|
383
|
+
4. **Built-in defaults**
|
|
384
|
+
|
|
385
|
+
### Environment override format
|
|
386
|
+
|
|
387
|
+
```
|
|
388
|
+
DJANGO_NATIVE_<SECTION>_<FIELD>=value
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Examples:
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
export DJANGO_NATIVE_RUNTIME_PORT=9000
|
|
395
|
+
export DJANGO_NATIVE_COMPILER_MODE=onefile
|
|
396
|
+
export DJANGO_NATIVE_BUILD_CLEAN=false
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Booleans accept `1`, `0`, `true`, `false`, `yes`, `no`, `on`, `off`.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Build manifest
|
|
404
|
+
|
|
405
|
+
`django-native plan` produces a **versioned, hashable JSON document** describing exactly what will be built. It is the contract between analysis and compilation.
|
|
406
|
+
|
|
407
|
+
```json
|
|
408
|
+
{
|
|
409
|
+
"schema_version": "1.0",
|
|
410
|
+
"project": {
|
|
411
|
+
"name": "inventory",
|
|
412
|
+
"settings": "inventory.settings",
|
|
413
|
+
"package": "inventory"
|
|
414
|
+
},
|
|
415
|
+
"environment": {
|
|
416
|
+
"python": "3.12.4",
|
|
417
|
+
"platform": "linux",
|
|
418
|
+
"platform_name": "linux",
|
|
419
|
+
"architecture": "x86_64"
|
|
420
|
+
},
|
|
421
|
+
"compiler": {
|
|
422
|
+
"backend": "nuitka",
|
|
423
|
+
"mode": "standalone"
|
|
424
|
+
},
|
|
425
|
+
"resources": {
|
|
426
|
+
"templates": true,
|
|
427
|
+
"static": true,
|
|
428
|
+
"migrations": true,
|
|
429
|
+
"translations": true,
|
|
430
|
+
"counts": { "templates": 12, "static": 45, "migrations": 8, "translations": 2 }
|
|
431
|
+
},
|
|
432
|
+
"runtime": {
|
|
433
|
+
"profile": "local",
|
|
434
|
+
"host": "127.0.0.1",
|
|
435
|
+
"port": 8000,
|
|
436
|
+
"database": "persistent"
|
|
437
|
+
},
|
|
438
|
+
"analysis": {
|
|
439
|
+
"distributions": 18,
|
|
440
|
+
"dynamic_imports": ["inventory.plugins.optional"],
|
|
441
|
+
"missing": [],
|
|
442
|
+
"installed_apps": ["inventory", "accounts", "products"]
|
|
443
|
+
},
|
|
444
|
+
"created_at": "2026-01-15T10:42:11+00:00",
|
|
445
|
+
"plan_hash": "sha256:9f3a8e…",
|
|
446
|
+
"status": "planned"
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
The `plan_hash` is computed over the canonical JSON serialisation. Two runs of `plan` on the same project produce the same hash — which means build caching, CI diffing, and reproducibility reports are all free.
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## Runtime profiles
|
|
455
|
+
|
|
456
|
+
A profile is a **preset**, not hidden configuration. Every value can be overridden per project.
|
|
457
|
+
|
|
458
|
+
| Profile | Bind | Browser | Migrations | Typical use |
|
|
459
|
+
|---|---|---|---|---|
|
|
460
|
+
| `local` | `127.0.0.1` | opens | manual | Desktop-like apps |
|
|
461
|
+
| `server` | `0.0.0.0` | never | manual (recommended: pre-deploy) | VPS / cloud deployment |
|
|
462
|
+
| `portable` | `127.0.0.1` | optional | on first start | USB / offline / air-gapped |
|
|
463
|
+
|
|
464
|
+
Persistent data — SQLite databases, uploaded media, logs, runtime state — **always** lives outside any temporary extraction directory:
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
<package>/data/
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
This makes upgrades safe: replace the executable, keep the data.
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## Compiler backends
|
|
475
|
+
|
|
476
|
+
Django Native ships with a **Nuitka backend** by default. Backends implement a documented interface:
|
|
477
|
+
|
|
478
|
+
```python
|
|
479
|
+
class CompilerBackend(ABC):
|
|
480
|
+
name: str
|
|
481
|
+
|
|
482
|
+
@abstractmethod
|
|
483
|
+
def check_environment(self) -> BackendCheckResult: ...
|
|
484
|
+
|
|
485
|
+
@abstractmethod
|
|
486
|
+
def get_version(self) -> str | None: ...
|
|
487
|
+
|
|
488
|
+
@abstractmethod
|
|
489
|
+
def compile(self, build_plan: BuildManifest, project_root: Path) -> CompileResult: ...
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
Backends are discovered via Python entry points:
|
|
493
|
+
|
|
494
|
+
```toml
|
|
495
|
+
[project.entry-points."django_native.backends"]
|
|
496
|
+
nuitka = "django_native.backends.nuitka:NuitkaBackend"
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
This means third-party backends (alternative compilers, remote build services, containerised builds) can be installed like any Python package — no forking Django Native required.
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
503
|
+
## Plugin system
|
|
504
|
+
|
|
505
|
+
Django Native exposes four extension points:
|
|
506
|
+
|
|
507
|
+
| Entry point group | Extension type |
|
|
508
|
+
|---|---|
|
|
509
|
+
| `django_native.backends` | Compiler backends |
|
|
510
|
+
| `django_native.resources` | Specialised resource handlers |
|
|
511
|
+
| `django_native.runtimes` | Custom runtime profiles and launchers |
|
|
512
|
+
| `django_native.packagers` | Packaging adapters (installers, archives, containers) |
|
|
513
|
+
|
|
514
|
+
Plugins are **opt-in, version-checked, and isolated**. `django-native plugin list` reports all installed plugins and their entry points.
|
|
515
|
+
|
|
516
|
+
See the plugin development guide (in `docs/plugins.md`) for the full contract and a working example.
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
## Compatibility
|
|
521
|
+
|
|
522
|
+
### Supported Python versions
|
|
523
|
+
|
|
524
|
+
- 3.10
|
|
525
|
+
- 3.11
|
|
526
|
+
- 3.12
|
|
527
|
+
- 3.13
|
|
528
|
+
|
|
529
|
+
### Supported Django versions
|
|
530
|
+
|
|
531
|
+
- 4.2 LTS
|
|
532
|
+
- 5.0
|
|
533
|
+
- 5.1
|
|
534
|
+
- 5.2
|
|
535
|
+
|
|
536
|
+
### Supported platforms
|
|
537
|
+
|
|
538
|
+
| Platform | Status |
|
|
539
|
+
|---|---|
|
|
540
|
+
| Linux x86_64 | ✅ Tested |
|
|
541
|
+
| Linux arm64 | ✅ Tested |
|
|
542
|
+
| macOS x86_64 | ✅ Tested |
|
|
543
|
+
| macOS arm64 | ✅ Tested |
|
|
544
|
+
| Windows x86_64 | ✅ Tested |
|
|
545
|
+
| Windows arm64 | ⚗️ Experimental |
|
|
546
|
+
|
|
547
|
+
### Known limitations
|
|
548
|
+
|
|
549
|
+
These are **reported explicitly** by `inspect` and `plan`, never hidden:
|
|
550
|
+
|
|
551
|
+
- **Dynamic imports with non-literal arguments** cannot be statically resolved. They are listed in the build manifest under `analysis.dynamic_imports` and must be added to `analysis.include` in the configuration.
|
|
552
|
+
- **Native C extensions** from third-party packages may require additional packaging rules. The Nuitka backend reports these as it encounters them.
|
|
553
|
+
- **Cross-compilation** is not supported. Django Native builds for the host platform only. Cross-platform binaries must be built on each target.
|
|
554
|
+
- **Application migrations of production databases** are never run silently. `migrations_on_startup` defaults to `false` for a reason.
|
|
555
|
+
- **Media files** are treated as runtime data, not bundled resources.
|
|
556
|
+
|
|
557
|
+
If your application falls outside the scope, `django-native inspect` tells you *before* you spend 20 minutes waiting for a compiler.
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
## Project status
|
|
562
|
+
|
|
563
|
+
Django Native is currently at **0.2.0**, focused on **project creation, intelligence, and build planning**. The compilation pipeline is implemented and being hardened against real-world applications.
|
|
564
|
+
|
|
565
|
+
| Version | Focus | State |
|
|
566
|
+
|---|---|---|
|
|
567
|
+
| 0.1.0 | Installable package, CLI skeleton | ✅ Released |
|
|
568
|
+
| **0.2.0** | **Init, inspect, plan — first real milestone** | **🚧 Current** |
|
|
569
|
+
| 0.3.0 | Compilation pipeline hardening | ⏳ Planned |
|
|
570
|
+
| 0.4.0 | Runtime and packaging | ⏳ Planned |
|
|
571
|
+
| 0.5.0 | Validation and reporting | ⏳ Planned |
|
|
572
|
+
| 0.6.0 | Plugin and extension interfaces | ⏳ Planned |
|
|
573
|
+
| 0.8.0 | Expanded platform support | ⏳ Planned |
|
|
574
|
+
| **1.0.0** | **Stable public API** | ⏳ Planned |
|
|
575
|
+
|
|
576
|
+
The distinction between *designed* and *implemented* matters. A component is only marked complete when its acceptance tests pass in CI — not when the code exists.
|
|
577
|
+
|
|
578
|
+
---
|
|
579
|
+
|
|
580
|
+
## Development
|
|
581
|
+
|
|
582
|
+
Django Native uses **[uv](https://docs.astral.sh/uv/)** for environment management, building, and publishing.
|
|
583
|
+
|
|
584
|
+
### Set up a development environment
|
|
585
|
+
|
|
586
|
+
```bash
|
|
587
|
+
git clone https://github.com/django-native/django-native.git
|
|
588
|
+
cd django-native
|
|
589
|
+
uv sync --extra dev
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
This creates `.venv/` with all runtime and development dependencies.
|
|
593
|
+
|
|
594
|
+
### Run tests
|
|
595
|
+
|
|
596
|
+
```bash
|
|
597
|
+
uv run pytest -q # all tests
|
|
598
|
+
uv run pytest -q tests/unit # unit tests only
|
|
599
|
+
uv run pytest -q -k planning # targeted
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### Lint and type-check
|
|
603
|
+
|
|
604
|
+
```bash
|
|
605
|
+
uv run ruff check .
|
|
606
|
+
uv run ruff format --check .
|
|
607
|
+
uv run mypy src/django_native
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
### Build distributions
|
|
611
|
+
|
|
612
|
+
```bash
|
|
613
|
+
uv run python scripts/build.py
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
Produces `dist/django_native-X.Y.Z-py3-none-any.whl`, `dist/django_native-X.Y.Z.tar.gz`, and a `BUILD-REPORT.txt` with checksums.
|
|
617
|
+
|
|
618
|
+
### Run the compatibility matrix
|
|
619
|
+
|
|
620
|
+
```bash
|
|
621
|
+
uv run python scripts/compatibility.py # full matrix
|
|
622
|
+
uv run python scripts/compatibility.py --list # plan only
|
|
623
|
+
uv run python scripts/compatibility.py --python 3.12 --django 5.2
|
|
624
|
+
uv run python scripts/compatibility.py --json compat.json
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
Each cell runs in an **isolated `uv` environment** — your project `.venv` is never touched.
|
|
628
|
+
|
|
629
|
+
### Release
|
|
630
|
+
|
|
631
|
+
```bash
|
|
632
|
+
uv run python scripts/release.py --dry-run # verify everything without publishing
|
|
633
|
+
uv run python scripts/release.py --test # publish to TestPyPI
|
|
634
|
+
uv run python scripts/release.py --confirm # publish to PyPI and tag
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
`--dry-run`, `--test`, and `--confirm` cover the three release modes. `--ci` runs non-interactively (used by the `release.yml` GitHub Actions workflow).
|
|
638
|
+
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
## Architecture
|
|
642
|
+
|
|
643
|
+
Django Native is organised as a set of **cooperating subsystems**, each with a single responsibility and a documented interface.
|
|
644
|
+
|
|
645
|
+
```
|
|
646
|
+
┌──────────────────────────────────────────────────────────┐
|
|
647
|
+
│ CLI (click) │
|
|
648
|
+
│ ┌────────────────────────────────────────────────────┐ │
|
|
649
|
+
│ │ Django management command (manage.py native) │ │
|
|
650
|
+
│ └────────────────────────────────────────────────────┘ │
|
|
651
|
+
└──────────────────────────┬───────────────────────────────┘
|
|
652
|
+
│ both call
|
|
653
|
+
▼
|
|
654
|
+
┌──────────────────────────────────────────────────────────┐
|
|
655
|
+
│ Application services (orchestration) │
|
|
656
|
+
└──────────────────────────┬───────────────────────────────┘
|
|
657
|
+
│
|
|
658
|
+
┌───────────────────┼───────────────────┬───────────┐
|
|
659
|
+
▼ ▼ ▼ ▼
|
|
660
|
+
┌─────────┐ ┌───────────┐ ┌────────┐ ┌────────┐
|
|
661
|
+
│ project │ │ analysis │ │planning│ │environ-│
|
|
662
|
+
│ (disco- │ │ (imports, │ │(mani- │ │ments │
|
|
663
|
+
│ very) │ │ resources)│ │ fest) │ │ │
|
|
664
|
+
└─────────┘ └───────────┘ └────────┘ └────────┘
|
|
665
|
+
│ │
|
|
666
|
+
▼ ▼
|
|
667
|
+
┌───────────┐ ┌────────────┐
|
|
668
|
+
│ backends │◄─────│ compiler │
|
|
669
|
+
│ (Nuitka) │ │ registry │
|
|
670
|
+
└─────┬─────┘ └────────────┘
|
|
671
|
+
│
|
|
672
|
+
┌──────────┼──────────┐
|
|
673
|
+
▼ ▼ ▼
|
|
674
|
+
┌─────────┐ ┌────────┐ ┌──────────┐
|
|
675
|
+
│ runtime │ │package │ │validation│
|
|
676
|
+
│launcher │ │assembly│ │ (report)│
|
|
677
|
+
└─────────┘ └────────┘ └──────────┘
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
### Source layout
|
|
681
|
+
|
|
682
|
+
```
|
|
683
|
+
src/django_native/
|
|
684
|
+
├── cli/ # click-based CLI
|
|
685
|
+
├── application/ # shared orchestration services
|
|
686
|
+
├── configuration/ # TOML loading, validation, precedence
|
|
687
|
+
├── project/ # project scaffolding and discovery
|
|
688
|
+
├── analysis/ # imports, distributions, resources
|
|
689
|
+
├── planning/ # build manifest generation
|
|
690
|
+
├── environments/ # build environment detection
|
|
691
|
+
├── backends/ # compiler backend interface + Nuitka
|
|
692
|
+
├── resources/ # resource collection helpers
|
|
693
|
+
├── runtime/ # launcher generation
|
|
694
|
+
├── packaging/ # artifact assembly
|
|
695
|
+
├── validation/ # artifact validation
|
|
696
|
+
├── diagnostics/ # structured errors and reports
|
|
697
|
+
├── plugins/ # entry-point discovery
|
|
698
|
+
└── django_app/ # Django management command bridge
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
Every module has a test file under `tests/unit/` or `tests/integration/`. Coverage is enforced in CI.
|
|
702
|
+
|
|
703
|
+
---
|
|
704
|
+
|
|
705
|
+
## Contributing
|
|
706
|
+
|
|
707
|
+
Contributions are welcome. Please read [`CONTRIBUTING.md`](CONTRIBUTING.md) before opening a pull request.
|
|
708
|
+
|
|
709
|
+
High-level expectations:
|
|
710
|
+
|
|
711
|
+
- **Commits** follow Conventional Commits (`feat:`, `fix:`, `docs:`…).
|
|
712
|
+
- **PRs** must pass `tests`, `lint`, and `security` workflows.
|
|
713
|
+
- **New features** require tests and a changelog entry.
|
|
714
|
+
- **Breaking changes** require a design discussion issue first.
|
|
715
|
+
- **Documentation** is part of the deliverable, not an afterthought.
|
|
716
|
+
|
|
717
|
+
By participating, you agree to abide by the [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
|
|
718
|
+
|
|
719
|
+
### Good first issues
|
|
720
|
+
|
|
721
|
+
Look for the [`good first issue`](https://github.com/django-native/django-native/labels/good%20first%20issue) label. Documentation improvements, additional example projects, and compatibility reports from real applications are especially valuable.
|
|
722
|
+
|
|
723
|
+
### Reporting a compatibility issue
|
|
724
|
+
|
|
725
|
+
If your Django project fails to compile, that's a bug in Django Native. Open an issue with:
|
|
726
|
+
|
|
727
|
+
1. The output of `django-native inspect --json`
|
|
728
|
+
2. The output of `django-native plan --json`
|
|
729
|
+
3. The failing `django-native build` log
|
|
730
|
+
4. The relevant parts of `django-native.toml`
|
|
731
|
+
|
|
732
|
+
This gives maintainers enough to reproduce the problem without asking twice.
|
|
733
|
+
|
|
734
|
+
---
|
|
735
|
+
|
|
736
|
+
## Security
|
|
737
|
+
|
|
738
|
+
Please **do not** open public issues for security problems. See [`SECURITY.md`](SECURITY.md) for the disclosure process.
|
|
739
|
+
|
|
740
|
+
Highlights of the security model:
|
|
741
|
+
|
|
742
|
+
- **Build inputs are validated** — paths, settings, and manifests are checked before they touch the filesystem or subprocess calls.
|
|
743
|
+
- **Subprocesses use argument lists** — never string-interpolated shell commands.
|
|
744
|
+
- **Project configuration is read, not executed** — `django-native.toml` is parsed as data.
|
|
745
|
+
- **Packages ship with checksums** — every artifact includes `checksums.txt` and `package-manifest.json`.
|
|
746
|
+
- **Secrets are never bundled** — `.env`, credentials, and development configs are excluded from packages by default.
|
|
747
|
+
- **Publishing uses trusted publishing** — PyPI releases go through GitHub Actions OIDC, not long-lived API tokens.
|
|
748
|
+
|
|
749
|
+
---
|
|
750
|
+
|
|
751
|
+
## License
|
|
752
|
+
|
|
753
|
+
Django Native is released under the [MIT License](LICENSE).
|
|
754
|
+
|
|
755
|
+
Django is licensed under the BSD 3-Clause License. Nuitka is licensed under the Apache License 2.0. Django Native preserves and redistributes nothing that would alter those terms; compiled applications remain subject to the licences of the packages they include. See `SECURITY.md` and the documentation site for the full licensing review.
|
|
756
|
+
|
|
757
|
+
---
|
|
758
|
+
|
|
759
|
+
<p align="center">
|
|
760
|
+
<strong>Django Native</strong> — Build Django. Compile. Package. Distribute.
|
|
761
|
+
<br>
|
|
762
|
+
<sub>Made with care by the Django Native contributors.</sub>
|
|
763
|
+
</p>
|
|
764
|
+
```
|