python_packed_resources/
lib.rs

1// Copyright 2022 Gregory Szorc.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9/*! Python Packed Resources
10
11This crate defines and implements a data format for storing resources useful
12to the execution of a Python interpreter. We call this data format *Python
13packed resources*.
14
15The idea is that a producer collects Python resources required by a Python
16interpreter - Python module source and bytecode, non-module resource files,
17extension modules, shared libraries, etc - attaches metadata to those
18resources (e.g. whether a Python module is also a package), and then
19serializes all of this out to a binary data structure.
20
21Later, this data structure is parsed back into composite parts. e.g.
22to a mapping of Python module names and their respective data. This
23data structure is then consulted by a Python interpreter to e.g. power
24the module `import` mechanism.
25
26This crate is developed primarily for
27[PyOxidizer](https://gregoryszorc.com/docs/pyoxidizer/stable/pyoxidizer.html). But
28it can be used outside the PyOxidizer project. See the aforementioned docs
29for the canonical specification of this format.
30*/
31
32mod parser;
33mod resource;
34mod serialization;
35mod writer;
36
37pub use crate::{
38    parser::{load_resources, ResourceParserIterator},
39    resource::Resource,
40    serialization::HEADER_V3,
41    writer::write_packed_resources_v3,
42};