Users¶
The following is not intended to be a complete enumeration. Be sure to view the development version of this page for an up-to-date listing.
diff --git a/dev/search/search_index.json b/dev/search/search_index.json index 5a5431b..c89e6db 100644 --- a/dev/search/search_index.json +++ b/dev/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"PyApp","text":"CI/CD Docs Project Meta
PyApp is a wrapper for Python applications that bootstrap themselves at runtime.
"},{"location":"#features","title":"Features","text":"PyApp is distributed under the terms of any of the following licenses:
Documentation for specific versions can be chosen by using the dropdown on the top of every page. The dev
version reflects changes that have not yet been released.
Desktop readers can use special keyboard shortcuts:
Keys ActionBefore building your application, you must configure your project at the very least.
After you have done that, your application can be built using a local copy of this repository or via installation with Cargo.
Tip
For a more streamlined workflow, consider using the built-in app build target of Hatch.
"},{"location":"build/#local-repository","title":"Local repository","text":"The recommended method of downloading the repository is via the source
asset archives attached to each release.
The latest release can always be downloaded at the following URLs:
Specific releases may be downloaded at the following URLs, replacing X.Y.Z
with the desired version:
After unpacking the repository, enter the directory and run:
cargo build --release\n
The executable will be located at target/release/pyapp.exe
if on Windows or target/release/pyapp
otherwise. If a particular target has been set (or when cross compiling since one will always be set), then the release
directory will be nested one level deeper under target/<TARGET>
.
Select the directory in which to build the executable with the --root
option and run:
cargo install pyapp --force --root <DIR>\n
The executable will be located at <DIR>/bin/pyapp.exe
if on Windows or <DIR>/bin/pyapp
otherwise.
Specific versions may be chosen with the --version
flag.
Note: If you want to cross compile, this method of building is currently unsupported.
"},{"location":"build/#cross-compilation","title":"Cross compilation","text":"Configuration for cross is validated by CI to ensure all known environment variable options are passed through to the containers.
When embedding the project or the distribution using a local path, you must use the local repository way of building and ensure that the configured files to embed reside within the repository and the options refer to relative paths.
"},{"location":"build/#caveats","title":"Caveats","text":"Some targets like powerpc64le-unknown-linux-gnu
need extra Cargo configuration to build properly. If there exists a file named .cargo/config_<TARGET>.toml
, then you will need to build using the local repository way and rename that file to .cargo/config.toml
before builds.
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
"},{"location":"changelog/#unreleased","title":"Unreleased","text":""},{"location":"changelog/#0120-2023-10-07","title":"0.12.0 - 2023-10-07","text":"Added:
Fixed:
pypy2.7
distributionAdded:
Fixed:
PYAPP_EXEC_SPEC
optionAdded:
PYAPP_EXEC_SCRIPT
option for executing a project using a scriptPYAPP_DISTRIBUTION_PATH
option implicitly enable PYAPP_DISTRIBUTION_EMBED
Fixed:
Changed:
site-packages
directoryAdded:
PYAPP_UPGRADE_VIRTUALENV
option to create virtual environments with virtualenv
rather than the stdlib's venv
bzip2
compressionFixed:
metadata
management command on WindowsAdded:
PYAPP_PIP_EXTERNAL
and PYAPP_PIP_VERSION
optionsPYAPP_PROJECT_DEPENDENCY_FILE
optionFixed:
Changed:
PYAPP_FULL_ISOLATION
optionAdded:
-r
/--restore
flag to the update
commandexecvp
on non-Windows systems--only-binary :all:
)Added:
PYAPP_PROJECT_PATH
option to embed the project for installation at runtimePYAPP_DISTRIBUTION_PATH
option to embed the distribution from a local path rather than fetching the sourceFixed:
Added:
Fixed:
Changed:
PYAPP_STARSHIP_PROMPT
option to PYAPP_METADATA_TEMPLATE
Added:
PYAPP_PIP_EXTRA_ARGS
option to provide extra pip install
argumentsPYAPP_PIP_ALLOW_CONFIG
option to allow runtime configuration of pip
Fixed:
Changed:
PYAPP_DISTRIBUTION_COMPRESSION
option to PYAPP_DISTRIBUTION_FORMAT
Added:
--pre
flag to the self update
command to allow pre-release and development versionsPYAPP_SELF_COMMAND
option to control the name of the management commandPYAPP_SKIP_INSTALL
option to skip project installationFixed:
pip install
commandsThis is the initial public release.
"},{"location":"config/","title":"Configuration","text":"All configuration is done with environment variables.
"},{"location":"config/#project","title":"Project","text":"There are 3 ways to configure runtime installation, none of which will occur when disabled.
The project name and version must be known in all cases.
"},{"location":"config/#package-index","title":"Package index","text":"The desired project name and version are configured with the PYAPP_PROJECT_NAME
and PYAPP_PROJECT_VERSION
options, respectively. The project name must adhere to PEP 508 and will be normalized during builds according to PEP 503.
You may install your project using a dependency file with the PYAPP_PROJECT_DEPENDENCY_FILE
option which should be a local path to the file. In this mode, the project name and version have nothing to do with installation and are just used as metadata.
The following formats are supported:
Extensions Description.txt
.in
This is the requirements file format"},{"location":"config/#project-embedding","title":"Embedding","text":"You may embed the project with the PYAPP_PROJECT_PATH
option which should be a path to a wheel ending in .whl
or a source distribution ending in .tar.gz
.
Note
The project name and version is automatically derived from the metadata files inside.
"},{"location":"config/#execution-mode","title":"Execution mode","text":"The following options are mutually exclusive:
Option DescriptionPYAPP_EXEC_MODULE
This is the name of the module to execute via python -m <MODULE>
PYAPP_EXEC_SPEC
This is an object reference to execute e.g. pkg.foo:cli
PYAPP_EXEC_CODE
This is arbitrary code to run via python -c <CODE>
(the spec option uses this internally) PYAPP_EXEC_SCRIPT
This is a path to a script to embed in the binary and run If none are set then the PYAPP_EXEC_MODULE
option will default to the value of PYAPP_PROJECT_NAME
with hyphens replaced by underscores.
Setting the PYAPP_PYTHON_VERSION
option will determine the distribution used at runtime based on the environment at build time. If unset then the default will be the latest stable minor version of CPython.
3.7
3.8
3.9
3.10
3.11
The source of distributions is the python-build-standalone project.
Some distributions have variants that may be configured with the PYAPP_DISTRIBUTION_VARIANT
option:
v1
v2
v3
(default)v4
shared
(default)static
pypy2.7
pypy3.9
pypy3.10
The source of distributions is the PyPy project.
"},{"location":"config/#custom","title":"Custom","text":"You may explicitly set the PYAPP_DISTRIBUTION_SOURCE
option which overrides the known distribution settings. The source must be a URL that points to an archived version of the desired Python distribution.
Setting this manually may require you to define extra metadata about the distribution that is required for correct runtime behavior.
"},{"location":"config/#format","title":"Format","text":"The following formats are supported for the PYAPP_DISTRIBUTION_FORMAT
option, with the default chosen based on the ending of the source URL:
tar|bzip2
.tar.bz2
.bz2
tar|gzip
.tar.gz
.tgz
tar|zstd
.tar.zst
.tar.zstd
zip
.zip
You may set the relative path to the Python executable after unpacking the archive with the PYAPP_DISTRIBUTION_PYTHON_PATH
option. The default is python.exe
on Windows and bin/python3
on all other platforms.
You may set the relative path to the site-packages
directory after unpacking the archive with the PYAPP_DISTRIBUTION_SITE_PACKAGES_PATH
option. The default is Lib\\site-packages
on Windows and lib/python<ID>/site-packages
on all other platforms where <ID>
is the distribution ID is defined.
You may indicate whether pip is already installed by setting the PYAPP_DISTRIBUTION_PIP_AVAILABLE
option to true
or 1
. This elides the check for installation when upgraded virtual environments are enabled.
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.
These options have no effect when the project installation is disabled.
"},{"location":"config/#externally-managed","title":"Externally managed","text":"You may set the PYAPP_PIP_EXTERNAL
option to true
or 1
to use the standalone versions of pip rather than whatever the distribution provides.
By default, the latest version is used. You may use a specific X.Y.Z
version by setting the PYAPP_PIP_VERSION
option.
Tip
This provides a significant installation speed up when full isolation is not enabled.
"},{"location":"config/#extra-arguments","title":"Extra arguments","text":"You may set the PYAPP_PIP_EXTRA_ARGS
option to provide extra arguments to the pip install
command at runtime when installing or updating the project e.g. --only-binary :all: --index-url URL
.
You may set the PYAPP_PIP_ALLOW_CONFIG
option to true
or 1
to allow the use of environment variables and other configuration at runtime.
You may set the PYAPP_FULL_ISOLATION
option to true
or 1
to provide each installation with a full copy of the distribution rather than a virtual environment.
When full isolation is not enabled, you may set the PYAPP_UPGRADE_VIRTUALENV
option to true
or 1
to create virtual environments with virtualenv rather than the standard library's venv
module.
You may set the PYAPP_SKIP_INSTALL
option to true
or 1
to skip installing the project in the distribution. This allows for entirely predefined distributions and thus no network calls at runtime if used in conjunction with distribution embedding.
The environment variable that is used for detection may be set to the path of the executable at runtime if you set the PYAPP_PASS_LOCATION
option to true
or 1
. This is useful if your application wishes to in some way manage itself.
You may set the PYAPP_SELF_COMMAND
option to override the default name (self
) of the management command group. Setting this to none
effectively disables the use of management commands.
When enabled, the value will be available at runtime as the PYAPP_COMMAND_NAME
environment variable.
You may set a custom template used to output metadata with the PYAPP_METADATA_TEMPLATE
option which supports the following placeholders:
{project}
The normalized project name {version}
The currently installed version of the project The default template is {project} v{version}
if this option is unset.
This is useful for setting custom commands for the Starship prompt. The following example configuration assumes that the built executable has been renamed to foo
:
format = \"\"\"\n...\n${custom.foo}\\\n...\n$line_break\\\n...\n$character\"\"\"\n\n# <clipped>\n\n[custom.foo]\ncommand = \"foo self metadata\"\nwhen = true\n## Windows\n# shell = [\"cmd\", \"/C\"]\n## Other\n# shell = [\"sh\", \"--norc\"]\n
"},{"location":"examples/","title":"Examples","text":"The following examples do not illustrate every possible combination of options but rather some common use cases.
"},{"location":"examples/#single-project-basic","title":"Single project basic","text":"Option ValuePYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
"},{"location":"examples/#single-project-embedded","title":"Single project embedded","text":"Option Value PYAPP_PROJECT_PATH
./proj-X.Y.Z.dev0-py3-none-any.whl
"},{"location":"examples/#dependency-file-basic","title":"Dependency file basic","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_PROJECT_DEPENDENCY_FILE
./requirements.txt
Note
The default execution will be python -m proj
at runtime.
PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_PROJECT_DEPENDENCY_FILE
./requirements.txt
PYAPP_EXEC_SCRIPT
./script.py
"},{"location":"examples/#execution-with-object-reference","title":"Execution with object reference","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_EXEC_SPEC
proj.cli:main
"},{"location":"examples/#specific-known-distribution","title":"Specific known distribution","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_PYTHON_VERSION
3.10
"},{"location":"examples/#custom-remote-distribution-basic","title":"Custom remote distribution basic","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_DISTRIBUTION_SOURCE
https://foo.bar.baz/archive.tar.gz
"},{"location":"examples/#custom-remote-distribution-embedded","title":"Custom remote distribution embedded","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_DISTRIBUTION_SOURCE
https://foo.bar.baz/archive.tar.gz
PYAPP_DISTRIBUTION_EMBED
true
"},{"location":"examples/#custom-embedded-local-distribution","title":"Custom embedded local distribution","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_DISTRIBUTION_PATH
./archive.tar.gz
"},{"location":"examples/#offline-installation","title":"Offline installation","text":"Option Value PYAPP_PROJECT_PATH
./proj-X.Y.Z-py3-none-any.whl
PYAPP_DISTRIBUTION_PATH
./archive.tar.gz
PYAPP_PIP_EXTRA_ARGS
--no-deps
"},{"location":"examples/#reproducible-installation-with-custom-package-index","title":"Reproducible installation with custom package index","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_PROJECT_DEPENDENCY_FILE
./requirements.txt
PYAPP_PIP_EXTRA_ARGS
--only-binary :all: --index-url URL
"},{"location":"runtime/","title":"Runtime behavior","text":""},{"location":"runtime/#initialization","title":"Initialization","text":"Applications will bootstrap themselves on the first run. All subsequent invocations will only check if the installation directory exists and nothing else, to maximize CLI responsiveness.
Note
The following diagram shows the possible behavior at runtime. The nodes with rounded edges are conditions and those with jagged edges are actions.
Most nodes are clickable and will take you to the relevant documentation.
flowchart TD\n INSTALLED([Installed]) -- No --> DISTCACHED([Distribution cached])\n INSTALLED -- Yes --> MNG([Management enabled])\n DISTCACHED -- No --> DISTEMBEDDED([Distribution embedded])\n DISTCACHED -- Yes --> FULLISOLATION([Full isolation])\n DISTEMBEDDED -- No --> DISTSOURCE[[Cache from source]]\n DISTEMBEDDED -- Yes --> DISTEXTRACT[[Cache from embedded data]]\n DISTSOURCE --> FULLISOLATION\n DISTEXTRACT --> FULLISOLATION\n FULLISOLATION -- No --> VENV[[Create virtual environment]]\n FULLISOLATION -- Yes --> UNPACK[[Unpack distribution directly]]\n EXTERNALPIP([External pip]) -- No --> PROJEMBEDDED([Project embedded])\n EXTERNALPIP -- Yes --> PIPCACHED([pip cached])\n PIPCACHED -- No --> DOWNLOADPIP[[Download pip]]\n PIPCACHED -- Yes --> PROJEMBEDDED([Project embedded])\n DOWNLOADPIP --> PROJEMBEDDED\n PROJEMBEDDED -- No --> DEPFILE([Dependency file])\n PROJEMBEDDED -- Yes --> PROJEMBED[[Install from embedded data]]\n DEPFILE -- No --> SINGLEPROJECT[[Install single project]]\n DEPFILE -- Yes --> DEPFILEINSTALL[[Install from dependency file]]\n SINGLEPROJECT --> MNG\n DEPFILEINSTALL --> MNG\n PROJEMBED --> MNG\n VENV --> EXTERNALPIP\n UNPACK --> EXTERNALPIP\n MNG -- No --> EXECUTE[[Execute project]]\n MNG -- Yes --> MNGCMD([Command invoked])\n MNGCMD -- No --> EXECUTE\n MNGCMD -- Yes --> MANAGE[[Run management command]]\n click DISTEMBEDDED href \"../config/#distribution-embedding\"\n click FULLISOLATION href \"../config/#full-isolation\"\n click EXTERNALPIP href \"../config/#externally-managed\"\n click PROJEMBEDDED href \"../config/#project-embedding\"\n click DEPFILE href \"../config/#dependency-file\"\n click SINGLEPROJECT href \"../config/#package-index\"\n click DEPFILEINSTALL href \"../config/#dependency-file\"\n click PROJEMBED href \"../config/#project-embedding\"\n click MNG href \"../config/#management-command\"\n click MNGCMD href \"../config/#management-command\"\n click MANAGE href \"#commands\"\n click EXECUTE href \"../config/#execution-mode\"
"},{"location":"runtime/#execution","title":"Execution","text":"Projects are executed using execvp
on non-Windows systems, replacing the process.
To provide consistent behavior on each user's machine:
A single environment variable called PYAPP
is injected with the value of 1
(by default) when running applications and may be used to detect this mode of installation versus others.
The default location of your application's installation differs based on the operating system and can be overridden at runtime with the PYAPP_INSTALL_DIR_<PROJECT_NAME>
environment variable where <PROJECT_NAME>
is the uppercased version of the project name.
Built applications have a single top-level command group named self
(by default) and all other invocations will be forwarded to your actual execution logic.
These commands are always exposed.
"},{"location":"runtime/#restore","title":"Restore","text":"<EXE> self restore\n
This will wipe the installation and start fresh.
"},{"location":"runtime/#update","title":"Update","text":"<EXE> self update\n
This will update the project to the latest available version in the currently used distribution.
"},{"location":"runtime/#optional","title":"Optional","text":"These commands are hidden by default and each can be individually exposed by setting its corresponding PYAPP_EXPOSE_<COMMAND>
option (e.g. PYAPP_EXPOSE_METADATA
) to true
or 1
.
<EXE> self metadata\n
This displays customized output based on a template.
"},{"location":"runtime/#pip","title":"pip","text":"<EXE> self pip\n
This directly invokes pip with the installed Python.
"},{"location":"runtime/#python","title":"Python","text":"<EXE> self python\n
This directly invokes the installed Python.
"},{"location":"runtime/#python-path","title":"Python path","text":"<EXE> self python-path\n
This outputs the path to the installed Python.
"},{"location":"users/","title":"Users","text":"The following is not intended to be a complete enumeration. Be sure to view the development version of this page for an up-to-date listing.
"},{"location":"users/#projects","title":"Projects","text":"Datadog QA | Hatch
"}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"PyApp","text":"CI/CD Docs Project MetaPyApp is a wrapper for Python applications that bootstrap themselves at runtime.
"},{"location":"#features","title":"Features","text":"PyApp is distributed under the terms of any of the following licenses:
Documentation for specific versions can be chosen by using the dropdown on the top of every page. The dev
version reflects changes that have not yet been released.
Desktop readers can use special keyboard shortcuts:
Keys ActionBefore building your application, you must configure your project at the very least.
After you have done that, your application can be built using a local copy of this repository or via installation with Cargo.
Tip
For a more streamlined workflow, consider using the built-in app build target of Hatch.
"},{"location":"build/#local-repository","title":"Local repository","text":"The recommended method of downloading the repository is via the source
asset archives attached to each release.
The latest release can always be downloaded at the following URLs:
Specific releases may be downloaded at the following URLs, replacing X.Y.Z
with the desired version:
After unpacking the repository, enter the directory and run:
cargo build --release\n
The executable will be located at target/release/pyapp.exe
if on Windows or target/release/pyapp
otherwise. If a particular target has been set (or when cross compiling since one will always be set), then the release
directory will be nested one level deeper under target/<TARGET>
.
Select the directory in which to build the executable with the --root
option and run:
cargo install pyapp --force --root <DIR>\n
The executable will be located at <DIR>/bin/pyapp.exe
if on Windows or <DIR>/bin/pyapp
otherwise.
Specific versions may be chosen with the --version
flag.
Note: If you want to cross compile, this method of building is currently unsupported.
"},{"location":"build/#cross-compilation","title":"Cross compilation","text":"Configuration for cross is validated by CI to ensure all known environment variable options are passed through to the containers.
When embedding the project or the distribution using a local path, you must use the local repository way of building and ensure that the configured files to embed reside within the repository and the options refer to relative paths.
"},{"location":"build/#caveats","title":"Caveats","text":"Some targets like powerpc64le-unknown-linux-gnu
need extra Cargo configuration to build properly. If there exists a file named .cargo/config_<TARGET>.toml
, then you will need to build using the local repository way and rename that file to .cargo/config.toml
before builds.
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
"},{"location":"changelog/#unreleased","title":"Unreleased","text":""},{"location":"changelog/#0120-2023-10-07","title":"0.12.0 - 2023-10-07","text":"Added:
Fixed:
pypy2.7
distributionAdded:
Fixed:
PYAPP_EXEC_SPEC
optionAdded:
PYAPP_EXEC_SCRIPT
option for executing a project using a scriptPYAPP_DISTRIBUTION_PATH
option implicitly enable PYAPP_DISTRIBUTION_EMBED
Fixed:
Changed:
site-packages
directoryAdded:
PYAPP_UPGRADE_VIRTUALENV
option to create virtual environments with virtualenv
rather than the stdlib's venv
bzip2
compressionFixed:
metadata
management command on WindowsAdded:
PYAPP_PIP_EXTERNAL
and PYAPP_PIP_VERSION
optionsPYAPP_PROJECT_DEPENDENCY_FILE
optionFixed:
Changed:
PYAPP_FULL_ISOLATION
optionAdded:
-r
/--restore
flag to the update
commandexecvp
on non-Windows systems--only-binary :all:
)Added:
PYAPP_PROJECT_PATH
option to embed the project for installation at runtimePYAPP_DISTRIBUTION_PATH
option to embed the distribution from a local path rather than fetching the sourceFixed:
Added:
Fixed:
Changed:
PYAPP_STARSHIP_PROMPT
option to PYAPP_METADATA_TEMPLATE
Added:
PYAPP_PIP_EXTRA_ARGS
option to provide extra pip install
argumentsPYAPP_PIP_ALLOW_CONFIG
option to allow runtime configuration of pip
Fixed:
Changed:
PYAPP_DISTRIBUTION_COMPRESSION
option to PYAPP_DISTRIBUTION_FORMAT
Added:
--pre
flag to the self update
command to allow pre-release and development versionsPYAPP_SELF_COMMAND
option to control the name of the management commandPYAPP_SKIP_INSTALL
option to skip project installationFixed:
pip install
commandsThis is the initial public release.
"},{"location":"config/","title":"Configuration","text":"All configuration is done with environment variables.
"},{"location":"config/#project","title":"Project","text":"There are 3 ways to configure runtime installation, none of which will occur when disabled.
The project name and version must be known in all cases.
"},{"location":"config/#package-index","title":"Package index","text":"The desired project name and version are configured with the PYAPP_PROJECT_NAME
and PYAPP_PROJECT_VERSION
options, respectively. The project name must adhere to PEP 508 and will be normalized during builds according to PEP 503.
You may install your project using a dependency file with the PYAPP_PROJECT_DEPENDENCY_FILE
option which should be a local path to the file. In this mode, the project name and version have nothing to do with installation and are just used as metadata.
The following formats are supported:
Extensions Description.txt
.in
This is the requirements file format"},{"location":"config/#project-embedding","title":"Embedding","text":"You may embed the project with the PYAPP_PROJECT_PATH
option which should be a path to a wheel ending in .whl
or a source distribution ending in .tar.gz
.
Note
The project name and version is automatically derived from the metadata files inside.
"},{"location":"config/#execution-mode","title":"Execution mode","text":"The following options are mutually exclusive:
Option DescriptionPYAPP_EXEC_MODULE
This is the name of the module to execute via python -m <MODULE>
PYAPP_EXEC_SPEC
This is an object reference to execute e.g. pkg.foo:cli
PYAPP_EXEC_CODE
This is arbitrary code to run via python -c <CODE>
(the spec option uses this internally) PYAPP_EXEC_SCRIPT
This is a path to a script to embed in the binary and run If none are set then the PYAPP_EXEC_MODULE
option will default to the value of PYAPP_PROJECT_NAME
with hyphens replaced by underscores.
Setting the PYAPP_PYTHON_VERSION
option will determine the distribution used at runtime based on the environment at build time. If unset then the default will be the latest stable minor version of CPython.
3.7
3.8
3.9
3.10
3.11
The source of distributions is the python-build-standalone project.
Some distributions have variants that may be configured with the PYAPP_DISTRIBUTION_VARIANT
option:
v1
v2
v3
(default)v4
shared
(default)static
pypy2.7
pypy3.9
pypy3.10
The source of distributions is the PyPy project.
"},{"location":"config/#custom","title":"Custom","text":"You may explicitly set the PYAPP_DISTRIBUTION_SOURCE
option which overrides the known distribution settings. The source must be a URL that points to an archived version of the desired Python distribution.
Setting this manually may require you to define extra metadata about the distribution that is required for correct runtime behavior.
"},{"location":"config/#format","title":"Format","text":"The following formats are supported for the PYAPP_DISTRIBUTION_FORMAT
option, with the default chosen based on the ending of the source URL:
tar|bzip2
.tar.bz2
.bz2
tar|gzip
.tar.gz
.tgz
tar|zstd
.tar.zst
.tar.zstd
zip
.zip
You may set the relative path to the Python executable after unpacking the archive with the PYAPP_DISTRIBUTION_PYTHON_PATH
option. The default is python.exe
on Windows and bin/python3
on all other platforms.
You may set the relative path to the site-packages
directory after unpacking the archive with the PYAPP_DISTRIBUTION_SITE_PACKAGES_PATH
option. The default is Lib\\site-packages
on Windows and lib/python<ID>/site-packages
on all other platforms where <ID>
is the distribution ID is defined.
You may indicate whether pip is already installed by setting the PYAPP_DISTRIBUTION_PIP_AVAILABLE
option to true
or 1
. This elides the check for installation when upgraded virtual environments are enabled.
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.
These options have no effect when the project installation is disabled.
"},{"location":"config/#externally-managed","title":"Externally managed","text":"You may set the PYAPP_PIP_EXTERNAL
option to true
or 1
to use the standalone versions of pip rather than whatever the distribution provides.
By default, the latest version is used. You may use a specific X.Y.Z
version by setting the PYAPP_PIP_VERSION
option.
Tip
This provides a significant installation speed up when full isolation is not enabled.
"},{"location":"config/#extra-arguments","title":"Extra arguments","text":"You may set the PYAPP_PIP_EXTRA_ARGS
option to provide extra arguments to the pip install
command at runtime when installing or updating the project e.g. --only-binary :all: --index-url URL
.
You may set the PYAPP_PIP_ALLOW_CONFIG
option to true
or 1
to allow the use of environment variables and other configuration at runtime.
You may set the PYAPP_FULL_ISOLATION
option to true
or 1
to provide each installation with a full copy of the distribution rather than a virtual environment.
When full isolation is not enabled, you may set the PYAPP_UPGRADE_VIRTUALENV
option to true
or 1
to create virtual environments with virtualenv rather than the standard library's venv
module.
You may set the PYAPP_SKIP_INSTALL
option to true
or 1
to skip installing the project in the distribution. This allows for entirely predefined distributions and thus no network calls at runtime if used in conjunction with distribution embedding.
The environment variable that is used for detection may be set to the path of the executable at runtime if you set the PYAPP_PASS_LOCATION
option to true
or 1
. This is useful if your application wishes to in some way manage itself.
You may set the PYAPP_SELF_COMMAND
option to override the default name (self
) of the management command group. Setting this to none
effectively disables the use of management commands.
When enabled, the value will be available at runtime as the PYAPP_COMMAND_NAME
environment variable.
You may set a custom template used to output metadata with the PYAPP_METADATA_TEMPLATE
option which supports the following placeholders:
{project}
The normalized project name {version}
The currently installed version of the project The default template is {project} v{version}
if this option is unset.
This is useful for setting custom commands for the Starship prompt. The following example configuration assumes that the built executable has been renamed to foo
:
format = \"\"\"\n...\n${custom.foo}\\\n...\n$line_break\\\n...\n$character\"\"\"\n\n# <clipped>\n\n[custom.foo]\ncommand = \"foo self metadata\"\nwhen = true\n## Windows\n# shell = [\"cmd\", \"/C\"]\n## Other\n# shell = [\"sh\", \"--norc\"]\n
"},{"location":"examples/","title":"Examples","text":"The following examples do not illustrate every possible combination of options but rather some common use cases.
"},{"location":"examples/#single-project-basic","title":"Single project basic","text":"Option ValuePYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
"},{"location":"examples/#single-project-embedded","title":"Single project embedded","text":"Option Value PYAPP_PROJECT_PATH
./proj-X.Y.Z.dev0-py3-none-any.whl
"},{"location":"examples/#dependency-file-basic","title":"Dependency file basic","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_PROJECT_DEPENDENCY_FILE
./requirements.txt
Note
The default execution will be python -m proj
at runtime.
PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_PROJECT_DEPENDENCY_FILE
./requirements.txt
PYAPP_EXEC_SCRIPT
./script.py
"},{"location":"examples/#execution-with-object-reference","title":"Execution with object reference","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_EXEC_SPEC
proj.cli:main
"},{"location":"examples/#specific-known-distribution","title":"Specific known distribution","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_PYTHON_VERSION
3.10
"},{"location":"examples/#custom-remote-distribution-basic","title":"Custom remote distribution basic","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_DISTRIBUTION_SOURCE
https://foo.bar.baz/archive.tar.gz
"},{"location":"examples/#custom-remote-distribution-embedded","title":"Custom remote distribution embedded","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_DISTRIBUTION_SOURCE
https://foo.bar.baz/archive.tar.gz
PYAPP_DISTRIBUTION_EMBED
true
"},{"location":"examples/#custom-embedded-local-distribution","title":"Custom embedded local distribution","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_DISTRIBUTION_PATH
./archive.tar.gz
"},{"location":"examples/#offline-installation","title":"Offline installation","text":"Option Value PYAPP_PROJECT_PATH
./proj-X.Y.Z-py3-none-any.whl
PYAPP_DISTRIBUTION_PATH
./archive.tar.gz
PYAPP_PIP_EXTRA_ARGS
--no-deps
"},{"location":"examples/#reproducible-installation-with-custom-package-index","title":"Reproducible installation with custom package index","text":"Option Value PYAPP_PROJECT_NAME
proj
PYAPP_PROJECT_VERSION
X.Y.Z
PYAPP_PROJECT_DEPENDENCY_FILE
./requirements.txt
PYAPP_PIP_EXTRA_ARGS
--only-binary :all: --index-url URL
"},{"location":"runtime/","title":"Runtime behavior","text":""},{"location":"runtime/#initialization","title":"Initialization","text":"Applications will bootstrap themselves on the first run. All subsequent invocations will only check if the installation directory exists and nothing else, to maximize CLI responsiveness.
Note
The following diagram shows the possible behavior at runtime. The nodes with rounded edges are conditions and those with jagged edges are actions.
Most nodes are clickable and will take you to the relevant documentation.
flowchart TD\n INSTALLED([Installed]) -- No --> DISTCACHED([Distribution cached])\n INSTALLED -- Yes --> MNG([Management enabled])\n DISTCACHED -- No --> DISTEMBEDDED([Distribution embedded])\n DISTCACHED -- Yes --> FULLISOLATION([Full isolation])\n DISTEMBEDDED -- No --> DISTSOURCE[[Cache from source]]\n DISTEMBEDDED -- Yes --> DISTEXTRACT[[Cache from embedded data]]\n DISTSOURCE --> FULLISOLATION\n DISTEXTRACT --> FULLISOLATION\n FULLISOLATION -- No --> VENV[[Create virtual environment]]\n FULLISOLATION -- Yes --> UNPACK[[Unpack distribution directly]]\n EXTERNALPIP([External pip]) -- No --> PROJEMBEDDED([Project embedded])\n EXTERNALPIP -- Yes --> PIPCACHED([pip cached])\n PIPCACHED -- No --> DOWNLOADPIP[[Download pip]]\n PIPCACHED -- Yes --> PROJEMBEDDED([Project embedded])\n DOWNLOADPIP --> PROJEMBEDDED\n PROJEMBEDDED -- No --> DEPFILE([Dependency file])\n PROJEMBEDDED -- Yes --> PROJEMBED[[Install from embedded data]]\n DEPFILE -- No --> SINGLEPROJECT[[Install single project]]\n DEPFILE -- Yes --> DEPFILEINSTALL[[Install from dependency file]]\n SINGLEPROJECT --> MNG\n DEPFILEINSTALL --> MNG\n PROJEMBED --> MNG\n VENV --> EXTERNALPIP\n UNPACK --> EXTERNALPIP\n MNG -- No --> EXECUTE[[Execute project]]\n MNG -- Yes --> MNGCMD([Command invoked])\n MNGCMD -- No --> EXECUTE\n MNGCMD -- Yes --> MANAGE[[Run management command]]\n click DISTEMBEDDED href \"../config/#distribution-embedding\"\n click FULLISOLATION href \"../config/#full-isolation\"\n click EXTERNALPIP href \"../config/#externally-managed\"\n click PROJEMBEDDED href \"../config/#project-embedding\"\n click DEPFILE href \"../config/#dependency-file\"\n click SINGLEPROJECT href \"../config/#package-index\"\n click DEPFILEINSTALL href \"../config/#dependency-file\"\n click PROJEMBED href \"../config/#project-embedding\"\n click MNG href \"../config/#management-command\"\n click MNGCMD href \"../config/#management-command\"\n click MANAGE href \"#commands\"\n click EXECUTE href \"../config/#execution-mode\"
"},{"location":"runtime/#execution","title":"Execution","text":"Projects are executed using execvp
on non-Windows systems, replacing the process.
To provide consistent behavior on each user's machine:
A single environment variable called PYAPP
is injected with the value of 1
(by default) when running applications and may be used to detect this mode of installation versus others.
The default location of your application's installation differs based on the operating system and can be overridden at runtime with the PYAPP_INSTALL_DIR_<PROJECT_NAME>
environment variable where <PROJECT_NAME>
is the uppercased version of the project name.
Built applications have a single top-level command group named self
(by default) and all other invocations will be forwarded to your actual execution logic.
These commands are always exposed.
"},{"location":"runtime/#restore","title":"Restore","text":"<EXE> self restore\n
This will wipe the installation and start fresh.
"},{"location":"runtime/#update","title":"Update","text":"<EXE> self update\n
This will update the project to the latest available version in the currently used distribution.
"},{"location":"runtime/#optional","title":"Optional","text":"These commands are hidden by default and each can be individually exposed by setting its corresponding PYAPP_EXPOSE_<COMMAND>
option (e.g. PYAPP_EXPOSE_METADATA
) to true
or 1
.
<EXE> self metadata\n
This displays customized output based on a template.
"},{"location":"runtime/#pip","title":"pip","text":"<EXE> self pip\n
This directly invokes pip with the installed Python.
"},{"location":"runtime/#python","title":"Python","text":"<EXE> self python\n
This directly invokes the installed Python.
"},{"location":"runtime/#python-path","title":"Python path","text":"<EXE> self python-path\n
This outputs the path to the installed Python.
"},{"location":"users/","title":"Users","text":"The following is not intended to be a complete enumeration. Be sure to view the development version of this page for an up-to-date listing.
"},{"location":"users/#projects","title":"Projects","text":"Datadog QA | Hatch | instawow
"}]} \ No newline at end of file diff --git a/dev/users/index.html b/dev/users/index.html index e1725d1..362001b 100644 --- a/dev/users/index.html +++ b/dev/users/index.html @@ -9,4 +9,4 @@ body[data-md-color-scheme="slate"] .gdesc-inner { background: var(--md-default-bg-color);} body[data-md-color-scheme="slate"] .gslide-title { color: var(--md-default-fg-color);} body[data-md-color-scheme="slate"] .gslide-desc { color: var(--md-default-fg-color);} -The following is not intended to be a complete enumeration. Be sure to view the development version of this page for an up-to-date listing.