Ein .mojopkg erstellen
Bündeln Sie ein Paket zur Wiederverwendung.
Ein .mojopkg erstellen ist eine kostenlose Mojo Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Mojo Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Mojo Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
From Files to a Package
Sharing loose files is fragile. Mojo lets you bundle a folder of modules into one tidy package artifact. 📦
A Package Is a Folder
A package is a directory of related modules treated as a single importable unit, much like a folder of files.
The __init__ Marker
A folder becomes a package when it holds an __init__.mojo file. That file marks the directory as importable.
Bundle It Up
The mojo package command compiles that folder into one distributable file you can hand to others.
mojo package mypkg -o mypkg.mojopkgThe .mojopkg File
The result is a .mojopkg file. It is a compiled bundle of your modules, ready to share or ship.
Import the Package
Anyone with your .mojopkg on the import path can use it just like a normal module they wrote themselves.
from mypkg import addFolder or File, Same Import
The same import works whether the package is a source folder or a compiled .mojopkg. You can switch freely.
Why Compile a Package
A packaged build is one compiled file instead of many sources, so it loads fast and is simpler to distribute.
Set the Output Name
The -o flag picks the output filename. Without it, the package keeps its directory name with a .mojopkg suffix.
Finding the Package
Mojo looks for imports on its import path. Place the .mojopkg where your project searches and the import resolves.
Share With Confidence
A single .mojopkg is the clean way to give your library to a teammate or another project. 🚀
Quick Check
Let us nail down how a folder becomes a package.
Recap
A package is a folder of modules with __init__.mojo. Run mojo package to compile it into one shareable .mojopkg. 🎯
Häufig gestellte Fragen
Ist die Lektion „Ein .mojopkg erstellen“ kostenlos?
Ja — der vollständige Text von „Ein .mojopkg erstellen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Mojo Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Mojo Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Ein .mojopkg erstellen“?
Bündeln Sie ein Paket zur Wiederverwendung. Du übst Mojo Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Mojo Academy zu starten?
Keine Vorkenntnisse erforderlich. Mojo Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.
Wie lange dauert die Lektion „Ein .mojopkg erstellen“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Mojo Academy-Lektion Code schreiben und ausführen?
Ja. Jede Mojo Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Module und Imports
- Ein .mojopkg erstellen
- Öffentliche APIs und Struktur
- Bewährte Projektstruktur