Skip to content
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

Fix distribution embeds and update docs #80

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ Cargo.lock
# Documentation
/.cache/
/site/

# Editor configs
.vscode/
7 changes: 6 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ fn set_distribution() {
let mut file = File::open(&embed_path).unwrap();
std::io::copy(&mut file, &mut hasher).unwrap();

"".to_string()
local_path
} else if is_enabled("PYAPP_DISTRIBUTION_EMBED") {
let distribution_source = get_distribution_source();
let bytes = reqwest::blocking::get(&distribution_source)
Expand Down Expand Up @@ -572,6 +572,11 @@ fn set_python_path(distribution_source: &str) {
let python_path = env::var(distribution_variable).unwrap_or_default();
let relative_path = if !python_path.is_empty() {
python_path
} else if !env::var("PYAPP_DISTRIBUTION_PATH")
.unwrap_or_default()
.is_empty()
{
panic!("\n\nThe following option must be set when embedding a custom distribution: {distribution_variable}\n\n");
} else if distribution_source.starts_with(DEFAULT_CPYTHON_SOURCE) {
if get_python_version() == "3.7" {
if on_windows {
Expand Down
6 changes: 4 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Setting the `PYAPP_PYTHON_VERSION` option will determine the distribution used a
| `3.10` |
| `3.11` |

The source of distributions is the [python-build-standalone](https://github.com/indygreg/python-build-standalone) project.
The source for pre-built distributions is the [python-build-standalone](https://github.com/indygreg/python-build-standalone) project.

Some distributions have [variants](https://gregoryszorc.com/docs/python-build-standalone/main/running.html) that may be configured with the `PYAPP_DISTRIBUTION_VARIANT` option:

Expand Down Expand Up @@ -110,7 +110,9 @@ You may indicate whether pip is already installed by setting the `PYAPP_DISTRIBU

### Embedding ### {: #distribution-embedding }

You may set the `PYAPP_DISTRIBUTION_EMBED` option to `true` or `1` to embed the distribution in the executable at build time to avoid fetching it at runtime. You can set the `PYAPP_DISTRIBUTION_PATH` option to use a local path rather than fetching the source, which implicitly enables embedding.
You may set the `PYAPP_DISTRIBUTION_EMBED` option to `true` or `1` to embed the distribution in the executable at build time to avoid fetching it at runtime.

You can set the `PYAPP_DISTRIBUTION_PATH` option to use a local path rather than fetching the source, which implicitly enables embedding. The local archive should be similar to the [default distributions](#python-distribution) in that there should be a Python interpreter ready for use.

## pip

Expand Down
Loading