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 simple script for generating screenshots with Vapoursynth

Vapoursynth-Screenshots A simple script for generating screenshots with Vapoursynth. About I'm lazy, and hate changing variables for each batch of scr

7 Dec 31, 2022
A compilation of useful scripts to automate common tasks

Scripts-To-Automate-This A compilation of useful scripts for common tasks Name What it does Type Add file extensions Adds ".png" to a list of file nam

0 Nov 05, 2021
A Python program for calculating the 95%CI for GNSS-derived site velocities

GNSS_Vel_95%CI A Python program for calculating the 95%CI for GNSS-derived site velocities Function_GNSS_95CI.py is a Python function for calculating

<a href=[email protected]"> 4 Dec 16, 2022
🍏 Make Thinc faster on macOS by calling into Apple's native Accelerate library

🍏 Make Thinc faster on macOS by calling into Apple's native Accelerate library

Explosion 81 Nov 26, 2022
Programming labs for 6.S060 (Foundations of Computer Security).

6.S060 Labs This git repository contains the code for the labs in 6.S060. In these labs, you will add a series of security features to a photo-sharing

MIT PDOS 10 Nov 02, 2022
UFDR2DIR - A script to convert a Cellebrite UFDR to the original file structure

UFDR2DIR A script to convert a Cellebrite UFDR to it's original file and directo

DFIRScience 25 Oct 24, 2022
Object-oriented programming (OOP) is a method of structuring a program by bundling related properties and behaviors into individual objects. In this tutorial, you’ll learn the basics of object-oriented programming in Python.

06_Python_Object_Class Introduction 👋 Objected oriented programming as a discipline has gained a universal following among developers. Python, an in-

Milaan Parmar / Милан пармар / _米兰 帕尔马 239 Dec 20, 2022
Python implementation of an automatic parallel parking system in a virtual environment, including path planning, path tracking, and parallel parking

Automatic Parallel Parking: Path Planning, Path Tracking & Control This repository contains a python implementation of an automatic parallel parking s

134 Jan 09, 2023
Additional useful operations for Python

Pyteal Extensions Additional useful operations for Python Available Operations MulDiv64: calculate m1*m2/d with no overflow on multiplication (TEAL 3+

Ulam Labs 11 Dec 14, 2022
Project aims to map out common user behavior on the computer

User-Behavior-Mapping-Tool Project aims to map out common user behavior on the computer. Most of the code is based on the research by kacos2000 found

trustedsec 136 Dec 23, 2022
management tool for systemd-nspawn containers

nspctl nspctl, management tool for systemd-nspawn containers. Why nspctl? There are different tools for systemd-nspawn containers. You can use native

Emre Eryilmaz 5 Nov 27, 2022
The ldapconsole script allows you to perform custom LDAP requests to a Windows domain

ldapconsole The ldapconsole script allows you to perform custom LDAP requests to a Windows domain. Features Authenticate with password Authenticate wi

Podalirius 38 Dec 09, 2022
A set of simple functions to upload and fetch pastes on paste.uploadgram.me

pastegram-py A set of simple functions to upload and fetch pastes on paste.uploadgram.me. API Documentation Methods upload_paste(contents: bytes, file

Uploadgram 3 Sep 13, 2022
A script that will warn you, by opening a new browser tab, when there are new content in your favourite websites.

web check A script that will warn you, by opening a new browser tab, when there are new content in your favourite websites. What it does The script wi

Jaime Álvarez 52 Mar 15, 2022
A module to prevent invites and joins to Matrix rooms by checking the involved server(s)' domain.

Synapse Domain Rule Checker A module to prevent invites and joins to Matrix rooms by checking the involved server(s)' domain. Installation From the vi

matrix.org 4 Oct 24, 2022
My qtile config with a fresh-looking bar and pywal support

QtileConfig My qtile config with a fresh-looking bar and pywal support. Note: This is my first rice and first github repo. Please excuse my poor codin

Eden 4 Nov 10, 2021
py2dis - A disassembly engine & library for Python

py2dis - A disassembly engine & library for Python. py2dis is a disassembly library for Python that does not use any modules/libraries other than colo

3 Feb 04, 2022
This python code will get requests from SET (The Stock Exchange of Thailand) a previously-close stock price and return it in Thai Baht currency using beautiful soup 4 HTML scrapper.

This python code will get requests from SET (The Stock Exchange of Thailand) a previously-close stock price and return it in Thai Baht currency using beautiful soup 4 HTML scrapper.

Andre 1 Oct 24, 2022
Removes all archived super productivity tasks. Just run the python script.

delete-archived-sp-tasks.py Removes all archived super productivity tasks. Just run the python script. This is helpful to do a cleanup every 3-6 month

Ben Herbst 1 Jan 09, 2022
Python data loader for Solar Orbiter's (SolO) Energetic Particle Detector (EPD).

Data loader (and downloader) for Solar Orbiter/EPD energetic charged particle sensors EPT, HET, and STEP. Supports level 2 and low latency data provided by ESA's Solar Orbiter Archive.

Jan Gieseler 9 Dec 16, 2022