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) [email protected]:/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
A Python wrapper for Matrix Synapse admin API

Synapse-admin-api-python A Python wrapper for Matrix Synapse admin API. Versioning This library now supports up to Synapse 1.45.0, any Admin API intro

Knugi 9 Sep 28, 2022
ALSPAC data analysis studying links between screen-usage and mental health issues in children. Provided data has been synthesised.

ADSMH - Mental Health and Screen Time Group coursework for Applied Data Science at the University of Bristol. Overview The data set that you have was

Kai 1 Jan 13, 2022
Checking-For-Fibonacci-Syquence-In-Python - Checking For Fibonacci Syquence In Python

Checking-For-Fibonacci-Syquence-In-Python The Fibonacci sequence is a set of num

John Michael Oliba 1 Feb 14, 2022
🐍 This snake helps you reconnect the Web, with RSS feeds!

This snake helps you reconnect the Web, with RSS feeds! RSSerpent is an open-source software that create RSS feeds for websites that do not provide an

211 Dec 08, 2022
Pipenv-local-deps-repro - Reproduction of a local transitive dependency on pipenv

Reproduction of the pipenv bug with transitive local dependencies. Clone this re

Lucas Duailibe 2 Jan 11, 2022
A tool that bootstraps your dotfiles ⚡️

Dotbot Dotbot makes installing your dotfiles as easy as git clone $url && cd dotfiles && ./install, even on a freshly installed system! Rationale Gett

Anish Athalye 5.9k Jan 07, 2023
A Bot Which Can generate Random Account Based On Your Hits.

AccountGenBot This Bot Can Generate Account With Hits You Save (Randomly) Keyfeatures Join To Use Support Limit Account Generation Using Sql Customiza

DevsExpo 30 Oct 21, 2022
NORETURN is an esoteric programming language, based around the idea of not going back

NORETURN NORETURN is an esoteric programming language, based around the idea of not going back Concept Program coded in noreturn runs over one array,

1 Dec 15, 2021
HomeAssistant Linux Companion

Application to run on linux desktop computer to provide sensors data to homeasssistant, and get notifications as if it was a mobile device.

Javier Lopez 10 Dec 27, 2022
TMTC Commander Core

This commander application was first developed by KSat for the SOURCE project to test the on-board software but has evolved into a more generic tool for satellite developers to perform TMTC (Telemetr

robamu 8 Dec 14, 2022
python scripts to perform coin die clustering (performed on Riedones3D).

python scripts to perform coin die clustering (performed on Riedones3D).

Sofiane 2 Apr 29, 2022
AIST++ API This repo contains starter code for using the AIST++ dataset.

Explainability for Vision Transformers (in PyTorch) This repository implements methods for explainability in Vision Transformers

Google 260 Dec 30, 2022
Return-Parity-MDP - Towards Return Parity in Markov Decision Processes

Towards Return Parity in Markov Decision Processes Code for the AISTATS 2022 pap

Jianfeng Chi 3 Nov 27, 2022
1cak - An Indonesian web that provide lot of fun.

An unofficial API of 1cak.com 1cak - An Indonesian web that provide lot of fun. Endpoint Lol - 10 Recent stored posts on database Example: https://on

Dicky Mulia Fiqri 5 Sep 27, 2022
Gunakan Dengan Bijak!!

YMBF Made with ❤️ by ikiwzXD_ menu Results notice me: if you get cp results, save 3/7 days then log in. Install script on Termux $ pkg update && pkg u

Ikiwz 0 Jul 11, 2022
Gba-free-fonts - Free font resources for GBA game development

gba-free-fonts Free font resources for GBA game development This repo contains m

28 Dec 30, 2022
Headless chatbot that detects spam and posts links to it to chatrooms for quick deletion.

SmokeDetector Headless chatbot that detects spam and posts it to chatrooms. Uses ChatExchange, takes questions from the Stack Exchange realtime tab, a

Charcoal 421 Dec 21, 2022
Build Xmas cards with user inputs

Automatically build Xmas cards with user inputs

Anand 9 Jan 25, 2022
A dot matrix rendered using braille characters.

⣿ dotmatrix A dot matrix rendered using braille characters. Description This library provides class called Matrix which represents a dot matrix that c

Tim Fischer 25 Dec 12, 2022
Urban Big Data Centre Housing Sensor Project

Housing Sensor Project The Urban Big Data Centre is conducting a study of indoor environmental data in Scottish houses. We are using Raspberry Pi devi

Jeremy Singer 2 Dec 13, 2021