### Display Poetry Configuration Example Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Provides an example output of the 'poetry config --list' command, showing various configuration settings and their values. ```toml cache-dir = "/path/to/cache/directory" virtualenvs.create = true virtualenvs.in-project = null virtualenvs.options.always-copy = true virtualenvs.options.no-pip = false virtualenvs.options.no-setuptools = false virtualenvs.options.system-site-packages = false virtualenvs.path = "{cache-dir}/virtualenvs" # /path/to/cache/directory/virtualenvs virtualenvs.prefer-active-python = false virtualenvs.prompt = "{project_name}-py{python_version}" ``` -------------------------------- ### Install Dependencies with Poetry (No Root) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Installs project dependencies without installing the root package itself. This is useful when you only need the project's dependencies and not the project code in an editable mode. ```bash poetry install --no-root ``` -------------------------------- ### Install Project Dependencies with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Installs all dependencies defined in the pyproject.toml file for the project. If a poetry.lock file exists, it uses the exact versions specified there; otherwise, it resolves and locks new versions. ```bash poetry install ``` -------------------------------- ### Install Poetry Extras from Command Line Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pyproject.md Demonstrates how to install Poetry packages with specific extras using the `poetry install` command with the `-E` or `--extras` flag. It also shows how to install all available extras. ```bash poetry install --extras "mysql pgsql" poetry install -E mysql -E pgsql poetry install --all-extras ``` -------------------------------- ### Install Poetry Preview Version Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs a preview or development version of Poetry using the POETRY_PREVIEW environment variable or the --preview flag. ```bash curl -sSL https://install.python-poetry.org | python3 - --preview curl -sSL https://install.python-poetry.org | POETRY_PREVIEW=1 python3 - ``` -------------------------------- ### Install Poetry (Windows/PowerShell) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs Poetry on Windows using PowerShell, fetching the installer script and executing it with the Python interpreter. ```powershell (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - ``` -------------------------------- ### Install Poetry Addon Packages Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Ensures all additional packages specified are installed in the current runtime environment, similar to the 'install' command but for Poetry's runtime. ```bash poetry self install --sync ``` -------------------------------- ### Add Dependency to Poetry Project Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Demonstrates how to add a new dependency, like 'pendulum', to a Poetry project using the `add` command. This command automatically updates `pyproject.toml` and installs the package. ```bash poetry add pendulum ``` -------------------------------- ### Install Poetry from Git Repository Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs Poetry directly from a Git repository, allowing installation from specific branches or commits. ```bash curl -sSL https://install.python-poetry.org | python3 - --git https://github.com/python-poetry/poetry.git@master ``` -------------------------------- ### Install Optional Dependency Group Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-dependencies.md Demonstrates the command to install dependencies from an optional group named 'docs' using Poetry's install command with the --with flag. ```bash poetry install --with docs ``` -------------------------------- ### Configure Poetry Installer No Binary Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Configures the policy for package distribution formats, allowing or disallowing binary distributions for all or specific packages. This setting is user-specific and applied during installation, not during lockfile generation. ```bash poetry config --local installer.no-binary :all: ``` ```bash export POETRY_INSTALLER_NO_BINARY=:all: ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/replit/poetry/blob/replit-1.5/docs/contributing.md Installs Poetry's dependencies and runs the test suite to ensure the project is working correctly. This is a crucial step for local development and verifying contributions. ```bash poetry install poetry run pytest ``` -------------------------------- ### Initialize Poetry in Existing Project Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Provides the command to initialize Poetry in a pre-existing project directory, creating a `pyproject.toml` file interactively. ```bash cd pre-existing-project poetry init ``` -------------------------------- ### List All Poetry Configurations Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Shows how to display all current Poetry configuration settings using the --list flag. ```bash poetry config --list ``` -------------------------------- ### Example: Poetry Plugin Registration Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pyproject.md An example of registering the `poetry-plugin-export` using the specified TOML format, linking the plugin name to its Python module and entry point. ```toml [tool.poetry.plugins."poetry.application.plugin"] export = "poetry_plugin_export.plugins:ExportApplicationPlugin" ``` -------------------------------- ### One-liner to Activate Poetry Virtual Environment Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Combines getting the virtual environment path and activating it in a single command for both POSIX and PowerShell shells. ```bash source $(poetry env info --path)/bin/activate ``` ```powershell & ((poetry env info --path) + "\Scripts\activate.ps1") ``` -------------------------------- ### Check Poetry Installation Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Verifies a successful Poetry installation by displaying the installed version. ```bash poetry --version ``` -------------------------------- ### Install Poetry (Linux, macOS, Windows/WSL) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs Poetry using the official installer script via curl and python3. This method isolates Poetry in a new virtual environment. ```bash curl -sSL https://install.python-poetry.org | python3 - ``` -------------------------------- ### Tox Configuration for Poetry Project (Usecase 3) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/faq.md This configuration skips tox's installation step, allowing poetry to install all dependencies and the current package in editable mode, ensuring tests run against local files. ```ini [tox] isolated_build = true [testenv] skip_install = true allowlist_externals = poetry commands_pre = poetry install commands = poetry run pytest tests/ --import-mode importlib ``` -------------------------------- ### Install Specific Extras Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Installs specific extras for the project, such as 'mysql' or 'pgsql'. The --extras or -E option can be used, and any extras not specified will be removed. ```bash poetry install --extras "mysql pgsql" ``` ```bash poetry install -E mysql -E pgsql ``` ```bash poetry install --all-extras ``` ```bash poetry install --extras "A B" ``` -------------------------------- ### Install Poetry with pipx Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs Poetry using pipx, a tool for installing Python CLI applications in isolated virtual environments. pipx manages upgrades and uninstalls. ```bash pipx install poetry ``` -------------------------------- ### Install Extras Using Pip Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pyproject.md Shows how to install extras defined in a Poetry package when using pip directly, following PEP 508 standards for specifying optional dependencies. ```bash pip install awesome[databases] ``` -------------------------------- ### Show Poetry Packages Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Lists all packages installed within the Poetry install environment, similar to the show command. It can also list only addon packages installed via 'self add'. ```bash poetry self show ``` ```bash poetry self show --addons ``` ```bash poetry self show --tree ``` ```bash poetry self show -l ``` ```bash poetry self show -o ``` -------------------------------- ### Poetry Project Configuration (pyproject.toml) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Shows the initial content of the `pyproject.toml` file for a Poetry project. This file defines project metadata, dependencies, and build system configurations. ```toml [tool.poetry] name = "poetry-demo" version = "0.1.0" description = "" authors = ["Sébastien Eustace "] readme = "README.md" packages = [{include = "poetry_demo"}] [tool.poetry.dependencies] python = "^3.7" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" ``` -------------------------------- ### Manual Poetry Installation with pip Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Manually installs Poetry using pip and the venv module. This method is Unix-only and involves creating a virtual environment, upgrading pip and setuptools, and then installing Poetry. ```bash python3 -m venv $VENV_PATH $VENV_PATH/bin/pip install -U pip setuptools $VENV_PATH/bin/pip install poetry ``` -------------------------------- ### Get Poetry Virtual Environment Path Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Retrieves the path to the current Poetry virtual environment, which is needed for manual activation. ```bash poetry env info --path ``` -------------------------------- ### Tox Configuration for Poetry Project (Usecase 2) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/faq.md This configuration uses tox to build and install an sdist package of the project, then uses poetry to install locked dependencies in a fresh environment for testing. ```ini [tox] isolated_build = true [testenv] allowlist_externals = poetry commands_pre = poetry install --no-root --sync commands = poetry run pytest tests/ --import-mode importlib ``` -------------------------------- ### Basic Poetry Install Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Installs dependencies defined in pyproject.toml. Uses poetry.lock if available for exact versions, otherwise resolves and creates a lock file. ```bash poetry install ``` -------------------------------- ### Install Poetry with Custom POETRY_HOME Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs Poetry to a custom directory specified by the POETRY_HOME environment variable, ensuring isolation and control over Poetry's installation location. ```bash curl -sSL https://install.python-poetry.org | POETRY_HOME=/etc/poetry python3 - ``` -------------------------------- ### Initialize Poetry Project in Replit Source: https://github.com/replit/poetry/blob/replit-1.5/README.md Steps to initialize a new Poetry project within a Replit environment, including setting up a virtual environment and installing dependencies. ```bash mkdir proj cd proj poetry init cd .. ./install_poetry_in_venv.sh cd proj ../poetry_env/bin/poetry ... ``` -------------------------------- ### Show Poetry Plugins Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Lists all the currently installed plugins for Poetry. ```bash poetry self show plugins ``` -------------------------------- ### Install specific Poetry version using pip Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Install a specific version of Poetry using pip within a virtual environment. ```bash /path/to/venv/bin/pip install poetry==1.2.0 ``` -------------------------------- ### Install Poetry in CI with Official Installer Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs a specific version of Poetry in a CI environment using the official installer script, setting the POETRY_HOME environment variable for controlled path management. ```bash export POETRY_HOME=/opt/poetry python3 install-poetry.py --version 1.2.0 $POETRY_HOME/bin/poetry --version ``` -------------------------------- ### Install Specific Poetry Versions with pipx Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs specific versions of Poetry using pipx, including parallel installations for testing different versions. It also supports installing from git repositories or pull requests. ```bash pipx install poetry==1.2.0 ``` ```bash pipx install --suffix=@1.2.0 poetry==1.2.0 poetry@1.2.0 --version ``` ```bash pipx install --suffix=@preview --pip-args=--pre poetry poetry@preview --version ``` ```bash pipx install --suffix @master git+https://github.com/python-poetry/poetry.git@master ``` ```bash pipx install --suffix @pr1234 git+https://github.com/python-poetry/poetry.git@refs/pull/1234/head ``` -------------------------------- ### Install Including Optional Dependency Groups Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Installs dependencies including specified optional groups (e.g., test, docs). The --with option is used to include these groups. ```bash poetry install --with test,docs ``` -------------------------------- ### Install Specific Poetry Version Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Installs a specific version of Poetry using the --version flag or the POETRY_VERSION environment variable. ```bash curl -sSL https://install.python-poetry.org | python3 - --version 1.2.0 curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.2.0 python3 - ``` -------------------------------- ### Install Poetry using pip in a virtual environment Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Install Poetry using pip within a virtual environment for maximum control. Requires explicit commands and knowledge of Python packaging. ```bash export POETRY_HOME=/opt/poetry python3 -m venv $POETRY_HOME $POETRY_HOME/bin/pip install poetry==1.2.0 $POETRY_HOME/bin/poetry --version ``` -------------------------------- ### Install Multiple Poetry Versions with Pipx Source: https://github.com/replit/poetry/blob/replit-1.5/docs/contributing.md Demonstrates how to install different versions of Poetry, including specific releases, release candidates, and development branches, using pipx. This allows for easy switching and testing between versions. ```Shell pipx install --suffix @1.2.1 'poetry==1.2.1' pipx install --suffix @1.3.0rc1 'poetry==1.3.0rc1' pipx install --suffix @master 'poetry @ git+https://github.com/python-poetry/poetry' pipx install --suffix @local '/path/to/local/clone/of/poetry' # now you can use any of the chosen versions of Poetry with their configured suffix, e.g. poetry@master --version ``` -------------------------------- ### Install Poetry using pipx Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Install Poetry in an isolated environment using pipx. This is a recommended method for CI environments. ```bash pipx install poetry==1.2.0 ``` -------------------------------- ### Using pyenv with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-environments.md This snippet demonstrates how to integrate Poetry with pyenv for managing Python versions. It shows the workflow of installing a specific Python version, setting it as the local version for a project, and then installing project dependencies using Poetry. ```bash pyenv install 3.9.8 pyenv local 3.9.8 poetry install ``` -------------------------------- ### Poetry Project Structure Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Illustrates the default file and directory structure generated by Poetry for a new project. Highlights the `pyproject.toml` file as the central configuration. ```text poetry-demo ├── pyproject.toml ├── README.md ├── poetry_demo │ └── __init__.py └── tests └── __init__.py ``` -------------------------------- ### Install Dependencies with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-dependencies.md Installs all non-optional dependency groups by default. You can exclude specific groups using the `--without` option. ```bash poetry install poetry install --without test,docs ``` -------------------------------- ### Add Dependencies with Extras and Version Constraints Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Explains how to add packages with optional extras and specific version constraints using Poetry. Includes examples for Git dependencies with extras. ```bash poetry add "requests[security,socks]" poetry add "requests[security,socks]~=2.22.0" poetry add "git+https://github.com/pallets/flask.git@1.1.1[dotenv,dev]" ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/replit/poetry/blob/replit-1.5/docs/contributing.md Sets up the pre-commit framework to automatically run linting and formatting checks before each commit. This helps maintain consistent code style and catch common mistakes. ```bash poetry run pre-commit install ``` -------------------------------- ### Install Specific Dependency Groups with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-dependencies.md Installs only specific dependency groups using the `--only` option. This can be used to install the project's runtime dependencies (`--only main`) or only the project root (`--only-root`). ```bash poetry install --only docs poetry install --only main poetry install --only-root ``` -------------------------------- ### Run Script with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Shows the command to execute a Python script or any command-line tool within the project's virtual environment managed by Poetry. ```bash poetry run python your_script.py ``` ```bash poetry run pytest ``` -------------------------------- ### Skip Root Package Installation Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Skips the installation of the project's own package, focusing only on dependencies. The --no-root option is used for this. ```bash poetry install --no-root ``` -------------------------------- ### Install Only Root Project Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Installs only the root project itself, excluding all its dependencies. The --only-root flag is used for this. ```bash poetry install --only-root ``` -------------------------------- ### Specify Dependency Version in pyproject.toml Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Illustrates how to manually specify a package and its version constraint within the `tool.poetry.dependencies` section of the `pyproject.toml` file. ```toml [tool.poetry.dependencies] pendulum = "^2.1" ``` -------------------------------- ### Install Optional Dependencies with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-dependencies.md Installs optional dependency groups using the `--with` option. When used with `--without`, the `--without` option takes precedence. ```bash poetry install --with docs poetry install --with test,docs --without docs ``` -------------------------------- ### Poetry Python Requirement Compatibility Example Source: https://github.com/replit/poetry/blob/replit-1.5/docs/faq.md Example pyproject.toml showing a Python version requirement and a potential error message when a dependency's Python requirement is incompatible. ```toml [tool.poetry.dependencies] python = "^3.7" ``` -------------------------------- ### Install Only Specific Dependency Groups Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Installs only the specified dependency groups (e.g., test, docs), ignoring others. The --only option is used for this. ```bash poetry install --only test,docs ``` -------------------------------- ### Configure Local Development Dependencies in pyproject.toml Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Illustrates how to specify local dependencies in the `pyproject.toml` file for Poetry, enabling editable installations. ```toml [tool.poetry.dependencies] my-package = {path = "../my/path", develop = true} ``` -------------------------------- ### Install from Git Repository Subdirectory Source: https://github.com/replit/poetry/blob/replit-1.5/docs/dependency-specification.md Installs a package located in a subdirectory within a Git repository. This is analogous to pip's subdirectory support and requires specifying the `subdirectory` option. ```toml [tool.poetry.dependencies] subdir_package = { git = "https://github.com/myorg/mypackage_with_subdirs.git", subdirectory = "subdir" } ``` -------------------------------- ### Configure Poetry Installer Max Workers Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Sets the maximum number of workers for Poetry's parallel installer. This value is capped at the number of CPU cores plus four. It is ignored if parallel installation is disabled. ```bash export POETRY_INSTALLER_MAX_WORKERS= ``` -------------------------------- ### Create New Poetry Project Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Demonstrates the command to create a new project directory structure managed by Poetry. This includes essential files like `pyproject.toml` and basic directory layouts for source code and tests. ```bash poetry new poetry-demo ``` -------------------------------- ### Display Specific Poetry Configuration Setting Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Illustrates how to retrieve the value of a single Poetry configuration setting by specifying its name. ```bash poetry config virtualenvs.path ``` -------------------------------- ### Set Local Poetry Configuration Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Demonstrates how to set a Poetry configuration value specifically for the current project using the --local flag. ```bash poetry config virtualenvs.create false --local ``` -------------------------------- ### Docker Cache Busting Solution for Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/faq.md Demonstrates a Dockerfile strategy to avoid cache invalidation by splitting dependency installation and source code copying into separate layers. ```text FROM python COPY pyproject.toml poetry.lock . RUN pip install poetry && poetry install --no-root --no-directory COPY src/ ./src RUN poetry install --no-dev ``` -------------------------------- ### Get Poetry Version Source: https://github.com/replit/poetry/blob/replit-1.5/docs/contributing.md Command to retrieve the currently installed version of Poetry. This is useful for reporting bugs or checking compatibility. ```shell poetry --version ``` -------------------------------- ### Get Poetry Debug Information Source: https://github.com/replit/poetry/blob/replit-1.5/docs/contributing.md Command to gather detailed debugging information about the Poetry installation and environment. This is crucial for diagnosing issues. ```shell poetry debug info ``` -------------------------------- ### Set Secret Configuration via Environment Variable Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Illustrates setting sensitive configuration values, such as passwords for repositories, using environment variables with the appropriate prefix. ```bash export POETRY_HTTP_BASIC_MY_REPOSITORY_PASSWORD=secret ``` -------------------------------- ### Handle Passwords Starting with Dash Source: https://github.com/replit/poetry/blob/replit-1.5/docs/repositories.md Provides a method to correctly configure credentials when the password begins with a dash, preventing it from being misinterpreted as a command-line option. ```bash poetry config -- http-basic.pypi myUsername -myPasswordStartingWithDash ``` -------------------------------- ### Poetry: Get virtual environment executable path Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-environments.md This command retrieves the path to the Python executable within the currently activated virtual environment. It's particularly useful for running tools like mypy from a global environment without installing them in the virtual environment. ```bash poetry env info --executable ``` -------------------------------- ### Add Local and Subdirectory Dependencies with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Shows how to add local project dependencies or packages from subdirectories within a Git repository using Poetry. Includes examples for tar.gz and wheel files. ```bash poetry add git+https://github.com/myorg/mypackage_with_subdirs.git@main#subdirectory=subdir ``` ```bash poetry add ./my-package/ poetry add ../my-package/dist/my-package-0.1.0.tar.gz poetry add ../my-package/dist/my_package-0.1.0.whl ``` ```bash poetry add --editable ./my-package/ ``` -------------------------------- ### Poetry Pre-commit Configuration Example Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pre-commit-hooks.md This snippet shows a complete `.pre-commit-config.yaml` file demonstrating how to include Poetry's pre-commit hooks. It specifies the repository, revision, and the hooks to be used: `poetry-check`, `poetry-lock`, and `poetry-export` with custom arguments. ```yaml repos: - repo: https://github.com/python-poetry/poetry rev: '' # add version here hooks: - id: poetry-check - id: poetry-lock - id: poetry-export args: ["-f", "requirements.txt", "-o", "requirements.txt"] ``` -------------------------------- ### Install from Git Repository with Tag Source: https://github.com/replit/poetry/blob/replit-1.5/docs/dependency-specification.md Specifies a dependency from a Git repository using a specific tag. This is useful for pinning to a known stable version of a package hosted on Git. ```toml numpy = { git = "https://github.com/numpy/numpy.git", tag = "v0.13.2" } ``` -------------------------------- ### Synchronize Dependencies with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-dependencies.md Synchronizes the environment with the `poetry.lock` file using the `--sync` option with the `install` command. This removes any dependencies not specified in the lock file. It can be combined with group-related options. ```bash poetry install --sync poetry install --without dev --sync poetry install --with docs --sync ``` -------------------------------- ### Add Git Dependencies with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Demonstrates how to add Python packages from Git repositories using Poetry. Supports specifying branches or tags, and installing in editable mode. ```bash poetry add git+ssh://github.com/sdispater/pendulum.git#develop poetry add git+ssh://github.com/sdispater/pendulum.git#2.0.5 ``` ```bash poetry add --editable git+ssh://github.com/sdispater/pendulum.git#develop ``` -------------------------------- ### Manually Activate Poetry Virtual Environment Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Manually activates the virtual environment using source commands specific to the shell. This method requires knowing the path to the virtual environment. ```bash source {path_to_venv}/bin/activate ``` ```powershell {path_to_venv}\Scripts\activate.ps1 ``` -------------------------------- ### Install specific Poetry version using curl and python Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Install a specific version of Poetry using curl and python. This method allows specifying the version during installation. ```bash curl -sSL https://install.python-poetry.org | python3 - --version 1.2.0 # or curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.2.0 python3 - ``` -------------------------------- ### Initialize Poetry Project Interactively Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md The 'poetry init' command interactively guides the user through creating a 'pyproject.toml' file for a new or existing Python project. It prompts for essential package information and allows specifying dependencies. ```bash poetry init ``` -------------------------------- ### Activate Poetry Virtual Environment (Shell) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/basic-usage.md Activates the Poetry virtual environment by creating a nested shell. This is the recommended method for ensuring subsequent commands run within the activated environment. ```bash poetry shell ``` ```powershell poetry shell ``` -------------------------------- ### Uninstall Poetry (Official Installer) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Removes Poetry installed via the official script. It can be uninstalled by running the installer with the --uninstall option or by setting the POETRY_UNINSTALL environment variable. ```bash curl -sSL https://install.python-poetry.org | python3 - --uninstall curl -sSL https://install.python-poetry.org | POETRY_UNINSTALL=1 python3 - ``` ```bash rm -rf "${POETRY_HOME:-~/.poetry}" ``` -------------------------------- ### Configure PyPI Token for Publishing Source: https://github.com/replit/poetry/blob/replit-1.5/docs/repositories.md Sets up an API token for publishing packages to PyPI. This is the recommended method for authentication with PyPI. ```bash poetry config pypi-token.pypi ``` -------------------------------- ### List Package Keywords Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pyproject.md Includes a list of keywords relevant to the package, aiding in discoverability. ```toml keywords = ["packaging", "poetry"] ``` -------------------------------- ### Show Project Dependencies with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Illustrates how to list all project dependencies or details for a specific package using the `poetry show` command. Includes options for filtering and viewing dependency trees. ```bash poetry show poetry show pendulum ``` -------------------------------- ### Configure Poetry Repositories Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Settings for defining and configuring alternative package repositories in Poetry. This includes setting repository URLs, authentication credentials using HTTP basic auth or API tokens, and managing SSL certificates. ```shell POETRY_REPOSITORIES_MYREPO="https://my.package.repo/" POETRY_HTTP_BASIC_MYREPO="username:password" POETRY_PYPI_TOKEN_MYREPO="my-api-token" POETRY_CERTIFICATES_MYREPO_CERT="/path/to/ca.crt" POETRY_CERTIFICATES_MYREPO_CLIENT_CERT="/path/to/client.crt" ``` -------------------------------- ### Configure Publishable Repository Source: https://github.com/replit/poetry/blob/replit-1.5/docs/repositories.md Sets up a repository for publishing packages using Poetry's `config` command. It specifies the repository name and its URL, typically for the Legacy Upload API. ```bash poetry config repositories.testpypi https://test.pypi.org/legacy/ ``` -------------------------------- ### Install Excluding Dependency Groups Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Installs dependencies while excluding specified groups (e.g., test, docs). The --without option is used for this purpose. ```bash poetry install --without test,docs ``` -------------------------------- ### Build Project Archives with Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Explains how to build source and wheel archives for a Poetry project using the `poetry build` command. Mentions support for pure Python wheels. ```bash poetry build ``` ```bash poetry build --format wheel ``` -------------------------------- ### Get Poetry Help and Information Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Provides help and information about Poetry. 'help' displays global help or help for specific commands. 'about' shows global information about Poetry and its core version. 'list' displays all available Poetry commands. ```bash poetry help ``` ```bash poetry help show ``` ```bash poetry show --help ``` ```bash poetry about ``` ```bash poetry list ``` -------------------------------- ### Configure Project Package Source Source: https://github.com/replit/poetry/blob/replit-1.5/docs/repositories.md Adds a package source to a project's configuration, which is typically managed within the `pyproject.toml` file. This command allows specifying the source name, URL, and priority. ```bash poetry source add foo https://foo.bar/simple/ ``` -------------------------------- ### Configure Poetry Virtual Environments Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Options to control the creation and behavior of virtual environments in Poetry. This includes disabling pip and setuptools, allowing access to system site packages, setting the virtual environment path, and customizing the activation prompt. ```shell POETRY_VIRTUALENVS_OPTIONS_NO_PIP=true POETRY_VIRTUALENVS_OPTIONS_NO_SETUPTOOLS=true POETRY_VIRTUALENVS_OPTIONS_SYSTEM_SITE_PACKAGES=true POETRY_VIRTUALENVS_PATH="/path/to/venvs" POETRY_VIRTUALENVS_PREFER_ACTIVE_PYTHON=true POETRY_VIRTUALENVS_PROMPT="{project_name}-py{python_version}" ``` -------------------------------- ### Specify Dependency with Environment Markers Source: https://github.com/replit/poetry/blob/replit-1.5/docs/dependency-specification.md Applies environment markers to a dependency to control its installation based on specific conditions, such as Python version or operating system. This allows for fine-grained control over dependency installation. ```toml [tool.poetry.dependencies] pathlib2 = { version = "^2.2", markers = "python_version <= '3.4' or sys_platform == 'win32'" } ``` -------------------------------- ### Depend on Local Directory Package (Non-Editable) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/dependency-specification.md Specifies a dependency on a local package located in a directory, installed in non-editable mode. The `develop = false` attribute ensures it's installed like a regular package. ```toml [tool.poetry.dependencies] my-package = { path = "../my-package/", develop = false } ``` -------------------------------- ### Build Poetry Bundle for Python Nix Modules Source: https://github.com/replit/poetry/blob/replit-1.5/README.md Commands to build a Poetry bundle for Replit's Python Nix modules, ensuring correct Python and Pip versions, and then uploading the bundle. ```bash build-bundle.sh ``` -------------------------------- ### Poetry: Display environment information Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-environments.md This shows how to retrieve information about the currently activated virtual environment for a Poetry project. It includes details like the Python version, implementation, and the path to the virtual environment. ```bash poetry env info ``` ```text Virtual environment Python: 3.7.1 Implementation: CPython Path: /path/to/poetry/cache/virtualenvs/test-O3eWbxRl-py3.7 Valid: True System Platform: darwin OS: posix Python: /path/to/main/python ``` -------------------------------- ### Include Project Packages Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pyproject.md Specifies which packages and modules to include in the distribution. This is useful for non-standard project structures. Paths are relative to `pyproject.toml`. ```toml [tool.poetry] # ... packages = [ { include = "my_package" }, { include = "extra_package/**/*.py" }, ] ``` ```toml [tool.poetry] # ... packages = [ { include = "my_package", from = "lib" }, ] ``` -------------------------------- ### Uninstall Poetry with pipx Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Uninstalls Poetry when it was installed using pipx. ```bash pipx uninstall poetry ``` -------------------------------- ### Project Configuration Snippet for Package Source Source: https://github.com/replit/poetry/blob/replit-1.5/docs/repositories.md Illustrates the TOML configuration snippet generated in `pyproject.toml` when adding a new package source. It defines the source name, URL, and its priority. ```toml [[tool.poetry.source]] name = "foo" url = "https://foo.bar/simple/" priority = "primary" ``` -------------------------------- ### Update Poetry with pipx Source: https://github.com/replit/poetry/blob/replit-1.5/docs/_index.md Updates Poetry to the latest version when installed using pipx. ```bash pipx upgrade poetry ``` -------------------------------- ### Remove Poetry Addon Package Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Removes an installed addon package from the Poetry runtime environment. ```bash poetry self remove poetry-plugin-export ``` -------------------------------- ### Configure PEP-517 Build System in Poetry Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pyproject.md Shows the standard `pyproject.toml` configuration for specifying Poetry as the build system backend, adhering to PEP-517 standards for Python project builds. ```toml [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" ``` -------------------------------- ### Define Dev Dependencies (Pre-1.2.0 Compatibility) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-dependencies.md Illustrates the older syntax for defining development dependencies using `[tool.poetry.dev-dependencies]`, which is still understood by Poetry for backward compatibility but is being deprecated in favor of the group notation. ```toml # Poetry pre-1.2.x style, understood by Poetry 1.0–1.2 [tool.poetry.dev-dependencies] pytest = "^6.0.0" pytest-mock = "*" ``` -------------------------------- ### Inequality Version Requirements Source: https://github.com/replit/poetry/blob/replit-1.5/docs/dependency-specification.md Provides examples of inequality requirements for specifying version ranges or exact versions for dependencies in Poetry. ```text >= 1.2.0 > 1 < 2 != 1.2.3 ``` ```text >= 1.2, < 1.5 ``` -------------------------------- ### Configure tox for Poetry Projects Source: https://github.com/replit/poetry/blob/replit-1.5/docs/faq.md This snippet shows how to configure tox to work with Poetry projects using isolated builds. It includes the necessary `[build-system]` configuration in `pyproject.toml` and a sample `tox.ini` file for setting up test environments with dependencies like pytest. ```toml [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" ``` ```ini [tox] isolated_build = true [testenv] deps = pytest commands = pytest tests/ --import-mode importlib ``` -------------------------------- ### Define Package Description Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pyproject.md Provides a short description of the package. This field is required. ```toml description = "A short description of the package." ``` -------------------------------- ### Remove Poetry Configuration Setting Source: https://github.com/replit/poetry/blob/replit-1.5/docs/configuration.md Explains how to unset a Poetry configuration setting, reverting it to its default value, using the --unset flag. ```bash poetry config virtualenvs.path --unset ``` -------------------------------- ### Specify Project Homepage URL Source: https://github.com/replit/poetry/blob/replit-1.5/docs/pyproject.md Provides an optional URL to the project's website. ```toml homepage = "https://python-poetry.org/" ``` -------------------------------- ### Poetry: Combining Git/URL/Path Dependencies with Source Repositories Source: https://github.com/replit/poetry/blob/replit-1.5/docs/dependency-specification.md Demonstrates how direct origin dependencies (git, url, path) can satisfy requirements even with mutually exclusive markers. It also shows how to explicitly use a specific source (like 'pypi') for a dependency, falling back to other sources when needed. ```toml foo = [ { platform = "darwin", url = "https://example.com/example-1.0-py3-none-any.whl" }, { platform = "linux", version = "^1.0" }, ] ``` ```toml foo = [ { platform = "darwin", url = "https://example.com/foo-1.0.0-py3-none-macosx_11_0_arm64.whl" }, { platform = "linux", version = "^1.0", source = "pypi" }, ] ``` -------------------------------- ### Poetry: List project environments Source: https://github.com/replit/poetry/blob/replit-1.5/docs/managing-environments.md This command lists all virtual environments that Poetry has associated with the current project. It can display just the names or the full paths to these environments. ```bash poetry env list ``` ```text test-O3eWbxRl-py3.6 test-O3eWbxRl-py3.7 (Activated) ``` ```bash poetry env list --full-path ``` -------------------------------- ### Configure Package Source in pyproject.toml (TOML) Source: https://github.com/replit/poetry/blob/replit-1.5/docs/repositories.md This TOML snippet shows how a package's source is configured within the `pyproject.toml` file. It links a specific package version to a named source, overriding the default search behavior. ```toml [tool.poetry.dependencies] ... httpx = { version = "^0.22", source = "internal-pypi" } ``` -------------------------------- ### Lock Poetry Dependencies Source: https://github.com/replit/poetry/blob/replit-1.5/docs/cli.md Reads the Poetry installation's system pyproject.toml file and locks the system dependencies in the corresponding poetry.lock file. ```bash poetry self lock ```