### Project Setup with Virtual Environment Source: https://github.com/python/peps/blob/main/peps/pep-0773.rst Guidance for setting up a project by creating a virtual environment and installing packages using pip. This example shows cross-platform commands for environment activation. ```text To install and use our application, first install Python following the guidance for your operating system at https://docs.python.org/using/. Then, create a virtual environment and use 'pip' to install. ``python3 -m venv .venv`` ``source .venv/bin/activate`` or ``.venv\Scripts\Activate`` (on Windows) ``python -m pip install OurAwesomePackage`` ... ``` -------------------------------- ### Pip Install Command Examples Source: https://github.com/python/peps/blob/main/peps/pep-0771.rst Demonstrates how pip handles default extras with explicit installations. ```console $ pip install package ``` ```console $ pip install package[extra2] ``` ```console $ pip install package[non-existent-extra] ``` -------------------------------- ### Bootstrap package installation via command line Source: https://github.com/python/peps/blob/main/peps/pep-0365.rst Example of using the proposed pkg_resources module to download and install a package from PyPI. ```bash python -m pkg_resources SomePackage==1.2 ``` -------------------------------- ### Configure installer backend in pyproject.toml Source: https://github.com/python/peps/blob/main/peps/pep-0650.rst Example configuration for registering an installer backend in a project's pyproject.toml file. ```toml [install-system] #Eg : pipenv requires = ["pep650pip", "pip"] install-backend = "pep650pip:main" ``` -------------------------------- ### Suggest external dependencies for installation Source: https://github.com/python/peps/blob/main/peps/pep-0804.rst Example of improved error messaging suggesting installation commands. ```bash The following external dependencies are needed to install the package mentioned above. You may need to install them with `apt`: g++ zlib1g zlib1g-dev ``` -------------------------------- ### Install Dependency Groups via CLI Source: https://github.com/python/peps/blob/main/peps/pep-0735.rst Example commands for installing dependency groups using a hypothetical tool and pip. ```shell $TOOL install-dependency-group test pip install -e . ``` ```shell $TOOL install-dependency-group docs ``` ```shell pip install --dependency-groups=test,typing ``` -------------------------------- ### Example config_settings dictionary Source: https://github.com/python/peps/blob/main/peps/pep-0517.rst Shows the resulting config_settings dictionary structure that a build frontend might pass to a build backend, based on the example pip install command. This dictionary allows for arbitrary configuration options. ```json { "CC": "gcc", "--global-option": ["--some-global-option"], "--build-option": ["--build-option1", "--build-option2"] } ``` -------------------------------- ### Example pyproject.toml Install System Configuration Source: https://github.com/python/peps/blob/main/peps/pep-0650.rst Defines the 'install-system' table in pyproject.toml, specifying required dependencies and the install backend entry point. This configuration is used by the universal installer. ```toml #pyproject.toml [install-system] #Eg : pipenv requires = ["pipenv"] install-backend = "pipenv.api:main" ``` -------------------------------- ### Provenance Assertion Syntax Examples Source: https://github.com/python/peps/blob/main/peps/pep-0752.rst Examples of proposed command-line syntax for verifying package provenance during installation. ```bash pip install "azure-loganalytics from microsoft" ``` ```bash pip install "google-cloud-compute from cloud.google.com" ``` ```bash pip install "aws-cdk-lib from contact@amazon.com" ``` -------------------------------- ### Install and use the say module Source: https://github.com/python/peps/blob/main/peps/pep-0502.rst Example of using the 'say' library for string interpolation via a callable interface. ```python > pip install say from say import say nums = list(range(4)) say("Nums has {len(nums)} items: {nums}") ``` -------------------------------- ### Example pip install command with package config Source: https://github.com/python/peps/blob/main/peps/pep-0517.rst Illustrates how pip might translate command-line arguments into a config_settings dictionary for a build backend. Users must ensure options are compatible with the specific build backend and package. ```shell pip install \ --package-config CC=gcc \ --global-option="--some-global-option" \ --build-option="--build-option1" \ --build-option="--build-option2" ``` -------------------------------- ### Specify Install-Paths-To metadata Source: https://github.com/python/peps/blob/main/peps/pep-0491.rst Example of declaring files in the WHEEL metadata that should be updated with installation paths. ```text Install-Paths-To: wheel/_paths.py Install-Paths-To: wheel/_paths.json ``` -------------------------------- ### Basic argparse Setup for Command Line Interface Source: https://github.com/python/peps/blob/main/peps/pep-0389.rst An example of setting up an ArgumentParser with basic arguments for output and verbosity. This snippet illustrates a more concise way to achieve a command-line interface compared to the getopt module. ```python import argparse if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('-o', '--output') parser.add_argument('-v', dest='verbose', action='store_true') args = parser.parse_args() # ... do something with args.output ... # ... do something with args.verbose .. ``` -------------------------------- ### Running a Module from __pypackages__ Source: https://github.com/python/peps/blob/main/peps/pep-0582.rst Illustrates how to run a module installed in the __pypackages__ directory using the -m flag. This example assumes 'bottle' is installed locally. ```bash foo> python -m bottle ``` -------------------------------- ### Example Extension Module File Names Source: https://github.com/python/peps/blob/main/peps/pep-3149.rst Illustrates potential file names for an extension module 'foo' installed on a system, showing version-specific tagging. ```text /usr/lib/python/foo.cpython-32m.so /usr/lib/python/foo.cpython-33m.so ``` -------------------------------- ### Basic Python Logging Setup Source: https://github.com/python/peps/blob/main/peps/pep-0282.rst This snippet demonstrates a simple setup for logging within a Python module. It shows how to get a logger instance and log a debug message. ```python --------- mymodule.py ------------------------------- import logging log = logging.getLogger("MyModule") def doIt(): log.debug("Doin' stuff...") #do stuff... raise TypeError, "Bogus type error for testing" ----------------------------------------------------- ``` -------------------------------- ### Example RECORD file entry Source: https://github.com/python/peps/blob/main/peps/pep-0376.rst Illustrates the format of an entry in the RECORD file, which lists installed files, their hashes, and sizes. The RECORD file itself is not hashed. ```text /etc/myapp/config.ini,md5=gLfd6IANquzGLhOkW4Mfgg,9544 ``` -------------------------------- ### RECORD File Format Example Source: https://github.com/python/peps/blob/main/peps/pep-0376.rst Illustrates the CSV format of the RECORD file, detailing installed files, their relative paths, MD5 hashes, and sizes. Note that generated files like .pyc do not have hashes. ```text lib/python2.6/site-packages/docutils/__init__.py,md5=nWt-Dge1eug4iAgqLS_uWg,9544 lib/python2.6/site-packages/docutils/__init__.pyc,, ``` -------------------------------- ### Initialize Python with Configuration Source: https://github.com/python/peps/blob/main/peps/pep-0741.rst Demonstrates creating an initialization configuration, setting various option types, and initializing the Python interpreter. ```c int init_python(void) { PyInitConfig *config = PyInitConfig_Create(); if (config == NULL) { printf("PYTHON INIT ERROR: memory allocation failed\n"); return -1; } // Set an integer (dev mode) if (PyInitConfig_SetInt(config, "dev_mode", 1) < 0) { goto error; } // Set a list of UTF-8 strings (argv) char *argv[] = {"my_program", "-c", "pass"}; if (PyInitConfig_SetStrList(config, "argv", Py_ARRAY_LENGTH(argv), argv) < 0) { goto error; } // Set a UTF-8 string (program name) if (PyInitConfig_SetStr(config, "program_name", L"my_program") < 0) { goto error; } // Initialize Python with the configuration if (Py_InitializeFromInitConfig(config) < 0) { goto error; } PyInitConfig_Free(config); return 0; error: // Display the error message const char *err_msg; (void)PyInitConfig_GetError(config, &err_msg); printf("PYTHON INIT ERROR: %s\n", err_msg); PyInitConfig_Free(config); return -1; } ``` -------------------------------- ### Initialize Python in two phases Source: https://github.com/python/peps/blob/main/peps/pep-0587.rst Demonstrates how to initialize the Python core, execute custom code, and then complete the main initialization. ```c void init_python(void) { PyStatus status; PyConfig config; PyConfig_InitPythonConfig(&config); config._init_main = 0; /* ... customize 'config' configuration ... */ status = Py_InitializeFromConfig(&config); PyConfig_Clear(&config); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } /* Use sys.stderr because sys.stdout is only created by _Py_InitializeMain() */ int res = PyRun_SimpleString( "import sys; " "print('Run Python code before _Py_InitializeMain', " "file=sys.stderr)"); if (res < 0) { exit(1); } /* ... put more configuration code here ... */ status = _Py_InitializeMain(); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } } ``` -------------------------------- ### Example pip freeze output Source: https://github.com/python/peps/blob/main/peps/pep-0771.rst This example shows the typical output of `pip freeze` when a package with default extras is installed. Note that only explicitly installed packages and their direct dependencies are listed, not the dependencies pulled in by default extras. ```console $ pip freeze > requirements.txt requirements.txt will contain e.g.:: package==1.0.2 numpy==2.1.0 ``` -------------------------------- ### Install command with custom installer Source: https://github.com/python/peps/blob/main/peps/pep-0376.rst Demonstrates using the 'install' command with the '--installer' option to specify a custom installation tool. Defaults to 'distutils' if not provided. ```bash python setup.py install --installer=pkg-system ``` -------------------------------- ### CentOS/RHEL Install Command Source: https://github.com/python/peps/blob/main/peps/pep-0804.rst Example of yum install command for SciPy's external build dependencies on CentOS/RHEL systems. ```bash sudo yum install gcc-gfortran python3-devel openblas-devel lapack-devel pkgconfig ``` -------------------------------- ### Defining metadata in setup.cfg Source: https://github.com/python/peps/blob/main/peps/pep-0390.rst Example of the proposed [metadata] section structure within a setup.cfg file. ```ini [metadata] name = Distribute version = 0.6.4 ``` -------------------------------- ### Fedora Install Command Source: https://github.com/python/peps/blob/main/peps/pep-0804.rst Example of dnf install command for SciPy's external build dependencies on Fedora systems. ```bash sudo dnf install gcc-gfortran python3-devel openblas-devel lapack-devel pkgconfig ``` -------------------------------- ### Initialize Python with Custom Configuration Source: https://github.com/python/peps/blob/main/peps/pep-0587.rst Demonstrates how to initialize Python with a custom configuration, including setting program name, reading configuration, appending to sys.path, overriding the executable, and cleaning up resources. ```c PyStatus init_python(const char *program_name) { PyStatus status; PyConfig config; PyConfig_InitPythonConfig(&config); /* Set the program name before reading the configuration (decode byte string from the locale encoding). Implicitly preinitialize Python. */ status = PyConfig_SetBytesString(&config, &config.program_name, program_name); if (PyStatus_Exception(status)) { goto done; } /* Read all configuration at once */ status = PyConfig_Read(&config); if (PyStatus_Exception(status)) { goto done; } /* Append our custom search path to sys.path */ status = PyWideStringList_Append(&config.module_search_paths, L"/path/to/more/modules"); if (PyStatus_Exception(status)) { goto done; } /* Override executable computed by PyConfig_Read() */ status = PyConfig_SetString(&config, &config.executable, L"/path/to/my_executable"); if (PyStatus_Exception(status)) { goto done; } status = Py_InitializeFromConfig(&config); done: PyConfig_Clear(&config); return status; } ``` -------------------------------- ### Debian/Ubuntu Install Command Source: https://github.com/python/peps/blob/main/peps/pep-0804.rst Example of apt install command for SciPy's external build dependencies on Debian/Ubuntu systems. ```bash sudo apt install -y gcc g++ gfortran libopenblas-dev liblapack-dev pkg-config python3-pip python3-dev ``` -------------------------------- ### Example Project File Layout Source: https://github.com/python/peps/blob/main/peps/pep-0338.rst A directory structure demonstrating a package hierarchy for testing module imports. ```text devel/ pkg/ __init__.py moduleA.py moduleB.py test/ __init__.py test_A.py test_B.py ``` -------------------------------- ### Define InstallPath with Executables Source: https://github.com/python/peps/blob/main/peps/pep-0514.rst Example of an InstallPath key including executable paths and arguments. ```registry HKEY_CURRENT_USER\Software\Python\ExampleCorp\examplepy\InstallPath (Default) = "C:\ExampleDistro30" ExecutablePath = "C:\ExampleDistro30\ex_python.exe" ExecutableArguments = "--arg1" WindowedExecutablePath = "C:\ExampleDistro30\ex_pythonw.exe" WindowedExecutableArguments = "--arg1" ``` -------------------------------- ### Define configuration as text Source: https://github.com/python/peps/blob/main/peps/pep-0741.rst Example of how configuration options might be represented as text for initialization. ```text # integer bytes_warning = 2 # string filesystem_encoding = "utf8" # comment # list of strings argv = ['python', '-c', 'code'] ``` -------------------------------- ### macOS Homebrew Install Command Source: https://github.com/python/peps/blob/main/peps/pep-0804.rst Example of brew install command for SciPy's external build dependencies on macOS using Homebrew. ```bash brew install gfortran openblas pkg-config ``` -------------------------------- ### Arch Linux Install Command Source: https://github.com/python/peps/blob/main/peps/pep-0804.rst Example of pacman install command for SciPy's external build dependencies on Arch Linux systems. ```bash sudo pacman -S gcc-fortran openblas pkgconf ``` -------------------------------- ### Get Distribution Information Source: https://github.com/python/peps/blob/main/peps/pep-0376.rst Retrieve a Distribution object for a given package name to access its metadata and installed files. Requires the package to be installed. ```python from pkgutil import get_distribution, get_file_users, distinfo_dirname dist = get_distribution('docutils') dist.name 'docutils' dist.metadata.version '0.5' ``` -------------------------------- ### Example pyproject.toml for setuptools Source: https://github.com/python/peps/blob/main/peps/pep-0518.rst This TOML file specifies that 'setuptools' is a required build dependency. Build tools will use this to ensure the build system can be executed. ```toml [build-system] # Minimum requirements for the build system to execute. requires = ["setuptools"] # PEP 508 specifications. ``` -------------------------------- ### Configure stub file installation in setup.py Source: https://github.com/python/peps/blob/main/peps/pep-0484.rst Use data_files in setup.py to specify the installation path for third-party stub files. ```python ... data_files=[ ( 'shared/typehints/python{}.{}'.format(*sys.version_info[:2]), ``` -------------------------------- ### Circular Buffer Contract Example Source: https://github.com/python/peps/blob/main/peps/pep-0316.rst Example of pre- and post-conditions for a circular buffer's get method, demonstrating access to `__old__` and `__return__`. ```python class circbuf: def get(self): """Pull an entry from a non-empty circular buffer. pre: not self.is_empty() post[self.g, self.len]: __return__ == self.buf[__old__.self.g] self.len == __old__.self.len - 1 """ ``` -------------------------------- ### Create virtual environment and install requirements Source: https://github.com/python/peps/blob/main/peps/docs/build.rst Initializes the local environment for PEP rendering. ```shell make venv ``` ```ps1con PS> python -m venv .venv PS> .\ .venv\Scripts\activate (venv) PS> python -m pip install --upgrade pip (venv) PS> python -m pip install -r requirements.txt ``` -------------------------------- ### GET /position Source: https://github.com/python/peps/blob/main/peps/pep-0482.rst Retrieves the current distance of the vehicle from the starting point. ```APIDOC ## GET /position ### Description Returns the current accumulated distance from the start. ### Method GET ### Endpoint /position ### Response #### Success Response (200) - **position** (number) - The current distance from the start. ``` -------------------------------- ### Cloning and Setting Up Local Branches Source: https://github.com/python/peps/blob/main/peps/pep-0103.rst Initialize a local repository and configure tracking branches for development. ```bash $ git clone https://git.python.org/python.git $ cd python $ git branch v1 origin/v1 ``` ```bash $ git clone -b v1 https://git.python.org/python.git $ cd python $ git checkout --track origin/master ``` -------------------------------- ### Example Python Registry Structure Source: https://github.com/python/peps/blob/main/peps/pep-0514.rst This section illustrates the typical structure of registry keys created by a 'just-for-me' installation of 64-bit Python 3.6.0. It shows keys for the core installation, version-specific details, help documentation, and installation paths. ```plaintext HKEY_CURRENT_USER\Software\Python\PythonCore (Default) = (value not set) DisplayName = "Python Software Foundation" SupportUrl = "http://www.python.org/" HKEY_CURRENT_USER\Software\Python\PythonCore\3.6 (Default) = (value not set) DisplayName = "Python 3.6 (64-bit)" SupportUrl = "http://www.python.org/" Version = "3.6.0" SysVersion = "3.6" SysArchitecture = "64bit" HKEY_CURRENT_USER\Software\Python\PythonCore\3.6\Help\Main Python Documentation (Default) = "C:\Users\Me\AppData\Local\Programs\Python\Python36\Doc\python360.chm" DisplayName = "Python 3.6.0 Documentation" HKEY_CURRENT_USER\Software\Python\PythonCore\3.6\InstallPath (Default) = "C:\Users\Me\AppData\Local\Programs\Python\Python36\" ExecutablePath = "C:\Users\Me\AppData\Local\Programs\Python\Python36\python.exe" WindowedExecutablePath = "C:\Users\Me\AppData\Local\Programs\Python\Python36\pythonw.exe" ``` -------------------------------- ### Implement installer backend with pip Source: https://github.com/python/peps/blob/main/peps/pep-0650.rst A reference implementation of an installer backend using pip and requirements files. ```python import subprocess import sys def invoke_install(path, *, dependency_group=None, **kwargs): try: return subprocess.run( [ sys.executable, "-m", "pip", "install", "-r", dependency_group or "requirements.txt", ], cwd=path, ).returncode except subprocess.CalledProcessError as e: return e.returncode ``` -------------------------------- ### Variant Environment Marker Examples Source: https://github.com/python/peps/blob/main/peps/pep-0817.rst Examples demonstrating how to use variant environment markers in dependency specifications. These markers are evaluated against the variant properties stored in the wheel being installed. ```python dep1; "foo" in variant_namespaces dep2; "foo :: bar" in variant_features dep3; "foo :: bar :: baz" in variant_properties ``` ```python dep4; variant_label == "foobar" dep5; variant_label != "null" dep6; variant_label == "" ``` -------------------------------- ### Initialize configuration using text in C Source: https://github.com/python/peps/blob/main/peps/pep-0741.rst Demonstrates a hypothetical PyInit_SetConfig function that accepts configuration settings as a formatted string. ```c void stable_abi_init_demo(int set_path) { PyInit_SetConfig( "isolated = 1\n" "argv = ['python', '-c', 'code']\n" "filesystem_encoding = 'utf-8'\n" ); if (set_path) { PyInit_SetConfig("pythonpath = '/my/path'"); } } ``` -------------------------------- ### Simple threaded application example Source: https://github.com/python/peps/blob/main/peps/pep-0371.rst This example demonstrates a basic threaded application using the `threading` module. It defines a function to be executed in a separate thread and then starts and joins the thread. ```python from threading import Thread as worker def afunc(number): print number * 3 t = worker(target=afunc, args=(4,)) t.start() t.join() ``` -------------------------------- ### Setup Debug Hooks Source: https://github.com/python/peps/blob/main/peps/pep-0445.rst Installs debug hooks on all memory block allocators. This function can be called multiple times, but hooks are only installed once. It has no effect if Python is not compiled in debug mode. ```c void PyMem_SetupDebugHooks(void) ``` -------------------------------- ### State Transition Example Source: https://github.com/python/peps/blob/main/peps/pep-0275.rst Demonstrates a basic state transition loop. ```python print "middle state" state = next_state(state) ``` -------------------------------- ### Simulate build failure output Source: https://github.com/python/peps/blob/main/peps/pep-0804.rst Example of error output when external dependencies are missing during installation. ```bash $ pip install . ... × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. This package has the following external dependencies, if those are missing on your system they are likely to be the cause of this build failure: dep:virtual/compiler/cxx dep:generic/zlib ``` -------------------------------- ### Example LINKS File Format Source: https://github.com/python/peps/blob/main/peps/pep-0778.rst This example demonstrates the format of the LINKS metadata file, specifying source and target paths for symlinks. ```text my_package/libfoo.so.3.1.4,my_package/libfoo.so.3 my_package/libfoo.so.3,my_package/libfoo.so ``` -------------------------------- ### Basic Python Usage with Install Manager Source: https://github.com/python/peps/blob/main/peps/pep-0773.rst Instructions for launching the Python interpreter, installing versions, listing installs, and managing virtual environments using the 'py' command. ```text Python installs on Windows are managed using an installer tool. After it has been installed, you can run ``python`` to launch the interpreter, and it will choose the best version already installed, available online, or referenced by the script you are launching (if any). If you have a preference for a particular version, you can specify it with ``py -V:`` followed by the rest of your command. To install a version of Python without running any command, use ``py install ``. You can see all of your installs with ``py list`` and remove them with ``py uninstall ``. Run ``py help`` to see all the options that are available. Because each version of Python will be shared by all your projects, we recommend using virtual environments. This will usually be created for a particular Python version by running ``py -V: -m venv .venv``, and activated with ``.venv\Scripts\Activate``. Now, rather than the install manager, ``python`` or ``py`` will always launch your virtual environment, and any packages you install are only available while this environment is active. To get access to the manager again, you can ``deactivate`` the environment, or use ``py ``. ``` -------------------------------- ### Direct URL JSON for Local Directory Source: https://github.com/python/peps/blob/main/peps/pep-0610.rst Example of direct_url.json for a package installed from a local directory. ```json { "url": "file:///home/user/project", "dir_info": {} } ``` -------------------------------- ### Display build.py help Source: https://github.com/python/peps/blob/main/peps/docs/build.rst Shows available command-line options for the build script. ```shell python build.py --help ``` -------------------------------- ### Install and use the interpy module Source: https://github.com/python/peps/blob/main/peps/pep-0502.rst Example of using the 'interpy' library to implement Ruby-style interpolation in Python. ```python > pip install interpy # coding: interpy location = 'World' print("Hello #{location}.") ``` -------------------------------- ### Project URLs Example Source: https://github.com/python/peps/blob/main/peps/pep-0459.rst Example of project URLs, including recommended labels for documentation, home, repository, and issue tracker. ```json "project_urls": { "Documentation": "https://distlib.readthedocs.org", "Home": "https://bitbucket.org/pypa/distlib", "Repository": "https://bitbucket.org/pypa/distlib/src", "Tracker": "https://bitbucket.org/pypa/distlib/issues" } ``` -------------------------------- ### Incorrect Indentation Examples Source: https://github.com/python/peps/blob/main/peps/pep-0008.rst Illustrates common indentation mistakes that violate the PEP 8 style guide. ```python # Wrong: # Arguments on first line forbidden when not using vertical alignment. foo = long_function_name(var_one, var_two, var_three, var_four) # Further indentation required as indentation is not distinguishable. def long_function_name( var_one, var_two, var_three, var_four): print(var_one) ``` -------------------------------- ### Example: Running Python Code Between Initialization Phases Source: https://github.com/python/peps/blob/main/peps/pep-0587.rst An example demonstrating how to run Python code between the 'Core' and 'Main' initialization phases using the private provisional API. ```APIDOC ## Example: Running Python Code Between Initialization Phases ### Description This C code example shows how to use `Py_InitializeFromConfig()` with `_init_main = 0` to stop at the 'Core' initialization phase, execute some Python code, and then proceed to the 'Main' phase using `_Py_InitializeMain()`. ### Method C API calls ### Endpoint N/A (C code example) ### Request Example ```c void init_python(void) { PyStatus status; PyConfig config; PyConfig_InitPythonConfig(&config); config._init_main = 0; /* ... customize 'config' configuration ... */ status = Py_InitializeFromConfig(&config); PyConfig_Clear(&config); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } /* Use sys.stderr because sys.stdout is only created by _Py_InitializeMain() */ int res = PyRun_SimpleString( "import sys; " "print('Run Python code before _Py_InitializeMain', " "file=sys.stderr)"); if (res < 0) { exit(1); } /* ... put more configuration code here ... */ status = _Py_InitializeMain(); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } } ``` ### Response #### Success Response (200) N/A (C code example) #### Response Example N/A (C code example) ``` -------------------------------- ### Invalid Wheel Filename Example (Variant Label Misinterpretation) Source: https://github.com/python/peps/blob/main/peps/pep-0817.rst This example shows how a wheel filename with only a variant label can be considered invalid because the Python tag might be misinterpreted as a build number, which must start with a digit. ```text numpy-2.3.2-cp313-cp313t-musllinux_1_2_x86_64-x86_64_v3.whl ^^^^^ ``` -------------------------------- ### Runtime Environment Management API Source: https://github.com/python/peps/blob/main/peps/pep-0722.rst Example of using a hypothetical environment manager library to install dependencies at runtime. ```python env_mgr.install("rich") env_mgr.install("click") import rich import click ... ``` -------------------------------- ### Define conditional metadata in setup.py Source: https://github.com/python/peps/blob/main/peps/pep-0496.rst Include platform-specific dependencies in setup configuration. ```python setup( install_requires=["pywin32 > 1.0 : sys.platform == 'win32'"], setup_requires=["pywin32 > 1.0 : sys.platform == 'win32'"] ) ``` -------------------------------- ### Deselect default extras via pip Source: https://github.com/python/peps/blob/main/peps/pep-0771.rst Command-line examples for disabling default extras during package installation using pip. ```console $ pip install package --no-default-extras ``` ```console $ pip install package --no-default-extras :all: ``` -------------------------------- ### Pre-populate Interpreter with Libraries Source: https://github.com/python/peps/blob/main/peps/pep-0554.rst Illustrates how to initialize a subinterpreter with necessary libraries and setup code before handling subsequent requests. This is useful for preparing an environment for specific tasks. ```python interp = interpreters.create() interp.exec(tw.dedent(""" import some_lib import an_expensive_module some_lib.set_up() """)) wait_for_request() interp.exec(tw.dedent(""" some_lib.handle_request() """ ``` -------------------------------- ### Generate Lockfiles via CLI Source: https://github.com/python/peps/blob/main/peps/pep-0735.rst Example commands for a hypothetical tool to lock and install dependencies based on defined groups. ```shell $TOOL lock --dependency-group=test $TOOL install --dependency-group=test --use-locked ```