Poetry plugin to bundle projects into various formats

Overview

Poetry bundle plugin

This package is a plugin that allows the bundling of Poetry projects into various formats.

Installation

The easiest way to install the bundle plugin is via the plugin add command of Poetry.

poetry plugin add poetry-bundle-plugin

If you used pipx to install Poetry you can add the plugin via the pipx inject command.

pipx inject poetry poetry-bundle-plugin

Otherwise, if you used pip to install Poetry you can add the plugin packages via the pip install command.

pip install poetry-bundle-plugin

Usage

The plugin introduces a bundle command namespace that regroups commands to bundle the current project and its dependencies into various formats. These commands are particularly useful to deploy Poetry-managed applications.

bundle venv

bundle venv

The bundle venv command bundles the project and its dependencies into a virtual environment.

The following command

poetry bundle venv /path/to/environment

will bundle the project in the /path/to/environment directory by creating the virtual environment, installing the dependencies and the current project inside it. If the directory does not exist, it will be created automatically.

By default, the command uses the current Python executable to build the virtual environment. If you want to use a different one, you can specify it with the --python/-p option:

poetry bundle venv /path/to/environment --python /full/path/to/python
poetry bundle venv /path/to/environment -p python3.8
poetry bundle venv /path/to/environment -p 3.8

Note

If the virtual environment already exists, two things can happen:

  • The python version of the virtual environment is the same as the main one: the dependencies will be synced (updated or removed).
  • The python version of the virtual environment is different: the virtual environment will be recreated from scratch.

You can also ensure that the virtual environment is recreated by using the --clear option:

poetry bundle venv /path/to/environment --clear
Comments
  • 1.2.0a2: `installer.remove_untracked` -> adds installer.requires_synchronization(True)

    1.2.0a2: `installer.remove_untracked` -> adds installer.requires_synchronization(True)

    the function has been moved to Solver

    fixes error

    
      AttributeError
    
      'Installer' object has no attribute 'remove_untracked'
    
      at ~/.asdf/installs/python/3.8.5/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry_bundle_plugin/bundlers/venv_bundler.py:133 in bundle
          129│             poetry.locker,
          130│             poetry.pool,
          131│             poetry.config,
          132│         )
        → 133│         installer.remove_untracked()
          134│         installer.use_executor(poetry.config.get("experimental.new-installer", False))
          135│
          136│         return_code = installer.run()
          137│         if return_code:
    
    opened by jtzero 7
  • Add support for dependency groups

    Add support for dependency groups

    By making BundleCommand inherit from poetry's GroupCommand, and passing the detected groups through to the venv bundler.

    Fixes https://github.com/python-poetry/poetry-plugin-bundle/issues/8

    opened by tofay 4
  • "Could not find a matching version of package poetry-plugin-bundle" on install

    Hi,

    Thanks for putting together this useful tool. I don't seem to be able to install it though, and get the following error.

    `$ poetry --version Poetry (version 1.2.0b1) $ poetry plugin add poetry-plugin-bundle

    Could not find a matching version of package poetry-plugin-bundle `

    Any ideas on how to resolve it?

    Thanks,

    opened by drone-ah 3
  • Bundle doesn't add all the internal packages

    Bundle doesn't add all the internal packages

    Hi I've encountered an issue where when using the plugin it does work with internal packages (packages I import as: lib1 = {path = "../../../poetry/lib1", develop = true} for example).

    The issue is that when lib1 himself is importing another internal package, for example: lib2 = {path = "../lib2", develop = true}

    the output bundle doesn't contain lib2. So it seems the plugin only works on the first level of internal packages, is it possible to add the ability to bundle all the project packages?

    opened by OceanManOne 2
  • Temporary directory import errors

    Temporary directory import errors

    Hey all.

    After some strugle trying to find the correct versions that supports the commands needed to install poetry-plugin-bundle, I'm still finding some issues.

    Using 1.1.14

    curl -sSL https://install.python-poetry.org | python3 -
    poetry --version
    # Poetry version 1.1.14
    poetry self add poetry-plugin-bundle
    

    Using 1.2.0b3

    curl -sSL https://install.python-poetry.org | python3 - --preview
    # Poetry (version 1.2.0b3)
    poetry self add poetry-plugin-bundle
    #
    # Could not find a matching version of package poetry-plugin-bundle
    

    Using 1.2.0b3, accounting for #17

    poetry self add poetry-bundle-plugin
    # Using version ^0.1.0 for poetry-bundle-plugin
    # 
    # Updating dependencies
    # Resolving dependencies... (1.1s)
    # 
    # Writing lock file
    # 
    # Package operations: 1 install, 0 updates, 0 removals
    # 
    #   • Installing poetry-bundle-plugin (0.1.0)
    poetry bundle venv test_env
    # cannot import name 'temporary_directory' from 'poetry.utils.helpers' (/home/<myuser>/.local/share/pypoetry/venv/lib/python3.8/site-packages/poetry/utils/helpers.py)
    

    What is the correct poetry version to use with poetry-bundle?

    opened by SamambaMan 2
  • How to use the bundle output in a docker container for production

    How to use the bundle output in a docker container for production

    Hi

    I'm in a search for a way to build a package for my monorepo project including the internal packages. This plugin seems like it is exactly what I need but I'm encountering an issue when trying to use the build output.

    Trying to run the activate script of poetry inside the dockerfile, running: . venv/bin/activate

    It seems to activate the virtual environment but it doesn't find the python packages in projects. Running python -m site inside the virtual environment results in: (build) root@69ec21d33c0d:/app# python -m site sys.path = [ '/app', '/usr/local/lib/python38.zip', '/usr/local/lib/python3.8', '/usr/local/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/site-packages', ] USER_BASE: '/root/.local' (doesn't exist) USER_SITE: '/root/.local/lib/python3.8/site-packages' (doesn't exist) ENABLE_USER_SITE: True

    Which isn't the correct site-packages path.

    What is the correct way using this plugin out with docker container?

    question 
    opened by OceanManOne 1
  • 'Installer' object has no attribute 'remove-untracked'

    'Installer' object has no attribute 'remove-untracked'

    I tried bundeling my project with this plugin and got the following error:

    Trashtalk:project$ poetry bundle venv ~/Programming/project/test
    
      • Bundling evm_backend (0.1.0) into /home/nathan/Programming/project/test: Installing dependencies
    
      AttributeError
    
      'Installer' object has no attribute 'remove_untracked'
    
      at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry_bundle_plugin/bundlers/venv_bundler.py:133 in bundle
          129│             poetry.locker,
          130│             poetry.pool,
          131│             poetry.config,
          132│         )
        → 133│         installer.remove_untracked()
          134│         installer.use_executor(poetry.config.get("experimental.new-installer", False))
          135│ 
          136│         return_code = installer.run()
          137│         if return_code:
    

    I don't know why this doesn't work, since I have a completely fresh install of both poetry and this plugin. I did some minor detective work and found out that remove_untracked doesn't exist in this file at least. Should I downgrade to an earlier 1.2 pre-release?

    opened by Trashtalk217 1
  • Normalize name

    Normalize name

    It's a bit weird that this is poetry-bundle-plugin, but export is poetry-plugin-export. I suspect it's best to pick one of the two naming formats and sticking to it.

    opened by lovesegfault 1
  • [pre-commit.ci] pre-commit autoupdate

    [pre-commit.ci] pre-commit autoupdate

    opened by pre-commit-ci[bot] 1
  • [pre-commit.ci] pre-commit autoupdate

    [pre-commit.ci] pre-commit autoupdate

    opened by pre-commit-ci[bot] 1
  • [pre-commit.ci] pre-commit autoupdate

    [pre-commit.ci] pre-commit autoupdate

    opened by pre-commit-ci[bot] 1
  • [Question] Does bundle plugin support to bundle dependencies to existed conda environment

    [Question] Does bundle plugin support to bundle dependencies to existed conda environment

    I know that poetry install can detect conda environment automatically and install dependencies to the current activate environment. But the problem if poetry install is there is no way to make it ignore the editable dependencies. I don't know if bundle plugin support this. It would be good to have some doc about it, thank you.

    opened by link89 0
  • [feature request] optionally compress bundled venv to zip or tar.gz file

    [feature request] optionally compress bundled venv to zip or tar.gz file

    Hi,

    I would like to ask if this is a good idea to add an option to save bundled venv to .zip or tar.gz file. The usecase is for providing pyspark code and dependencies, it supports venv-pack tar.gz file which basically works the same as this bundle plugin, except it creates tar.gz file. See: https://spark.apache.org/docs/latest/api/python/user_guide/python_packaging.html#using-virtualenv

    opened by kazdy 1
  • bundle dependencies marked as editable

    bundle dependencies marked as editable

    For dependencies marked as editable, this plugin will create .pth files including the local location of the path-based dependency. In that sense, the dependency is not bundled.

    Is there a reason for a bundled install to observe the "develop = true" flag? If so, can we have an option to install these packages as non-editable instead? According to my reading of https://github.com/python-poetry/poetry/issues/1382#issuecomment-1266291854, this bundler is supposed to handle that installation case.

    poetry 1.2.1
    poetry-core 1.2.0 poetry-plugin-bundle 1.1.0

    opened by smcoll 0
  • using dot as the path crashes while deleting the current folder

    using dot as the path crashes while deleting the current folder

    Using windows WSL2 with debian and python3.7, I just migrated to poetry 1.2.2 and wanted to try the new bundle plugin that would allow me to build faster in my CI.

    I innocently typed

    poetry bundle venv .
    

    as I wanted the bundle to be in the current folder. The command started and showed

    Bundling xxx_gateway (1.1.1) into .: Removing existing virtual environment
    

    and then

    [Errno 22] Invalid argument: '.'
    

    In the meantime my folder had been emptied (no consequence git was here)

    I think other people could try to bundle in there local folder so I suggest adding an exception for the dot path. Maybe using ./bundle as a default could be interesting in some automation process as well.

    opened by Cajuteq 0
Owner
Poetry
Python packaging and dependency management made easy
Poetry
poetry2nix turns Poetry projects into Nix derivations without the need to actually write Nix expressions

poetry2nix poetry2nix turns Poetry projects into Nix derivations without the need to actually write Nix expressions. It does so by parsing pyproject.t

Nix community projects 405 Dec 29, 2022
Poetry workspace plugin for Python monorepos.

poetry-workspace-plugin Poetry workspace plugin for Python monorepos. Inspired by Yarn Workspaces. Adds a new subcommand group, poetry workspace, whic

Jack Smith 74 Jan 1, 2023
A plugin for poetry that allows you to execute scripts defined in your pyproject.toml, just like you can in npm or pipenv

poetry-exec-plugin A plugin for poetry that allows you to execute scripts defined in your pyproject.toml, just like you can in npm or pipenv Installat

null 38 Jan 6, 2023
🛠️ Plugin to integrate Chuy with Poetry

Archived This is bundled with Chuy since v1.3.0. Poetry Chuy Plugin This plugin integrates Chuy with Poetry. Note: This only works in Poetry 1.2.0 or

Eliaz Bobadilla 4 Sep 24, 2021
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

null 18.6k Jan 2, 2023
Scripts to convert the Ted-MDB corpora into the formats for DISRPT shared task and the converted corpora

Scripts to convert the Ted-MDB corpora into the formats for DISRPT shared task and the converted corpora.

null 1 Feb 8, 2022
Demo Python project using Conda and Poetry

Conda Poetry This is a demonstration of how Conda and Poetry can be used in a Python project for dev dependency management and production deployment.

Ryan Allen 2 Apr 26, 2022
Bazel rules to install Python dependencies with Poetry

rules_python_poetry Bazel rules to install Python dependencies from a Poetry project. Works with native Python rules for Bazel. Getting started Add th

Martin Liu 7 Dec 15, 2021
Canim1 - Simple python tool to search for packages without m1 wheels in poetry lockfiles

canim1 Usage Clone the repo. Run poetry install. Then you can use the tool: ❯ po

Korijn van Golen 1 Jan 25, 2022
My collection of mini-projects in various languages

Mini-Projects My collection of mini-projects in various languages About: This repository consists of a number of small projects. Most of these "mini-p

Siddhant Attavar 1 Jul 11, 2022
Beginner Projects A couple of beginner projects here

Beginner Projects A couple of beginner projects here, listed from easiest to hardest :) selector.py: simply a random selector to tell me who to faceti

Kylie 272 Jan 7, 2023
A Python Based Utility for Processing GST-Return JSON Files to Multiple Formats

GSTR 1/2A Utility by Shan.tk Open Source GSTR 1/GSTR 2A JSON to Excel utility based on Python. Useful for Auditors in Verifying GSTR 1 Return Invoices

Sudharshan TK 1 Oct 8, 2022
Blender-3D-SH-Dma-plugin - Import and export Sonic Heroes Delta Morph animations (.anm) into Blender 3D

io_scene_sonic_heroes_dma This plugin for Blender 3D allows you to import and ex

Psycrow 3 Mar 22, 2022
A collection of Workflows samples for various use cases

Workflows Samples Workflows allow you to orchestrate and automate Google Cloud and HTTP-based API services with serverless workflows.

Google Cloud Platform 76 Jan 7, 2023
Solve various integral equations using numerical methods in Python

Solve Volterra and Fredholm integral equations This Python package estimates Volterra and Fredholm integral equations using known techniques. Installa

Matthew Wildrick Thomas 18 Nov 28, 2022
A collection of repositories used to realise various end-to-end high-level synthesis (HLS) flows centering around the CIRCT project.

circt-hls What is this?: A collection of repositories used to realise various end-to-end high-level synthesis (HLS) flows centering around the CIRCT p

null 29 Dec 14, 2022
KUIZ is a web application quiz where you can create/take a quiz for learning and sharing knowledge from various subjects, questions and answers.

KUIZ KUIZ is a web application quiz where you can create/take a quiz for learning and sharing knowledge from various subjects, questions and answers.

Thanatibordee Sihaboonthong 3 Sep 12, 2022
Tindicators is a Python library to calculate the values of various technical indicators

Tindicators is a Python library to calculate the values of various technical indicators

omar 3 Mar 3, 2022
This repository contains various tools useful for offensive operations (reversing, etc) regarding the PE (Portable Executable) format

PE-Tools This repository contains various tools useful for offensive operations (reversing, etc) regarding the PE (Portable Executable) format Install

stark0de 4 Oct 13, 2022