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
This is a library for simulate probability theory problems specialy conditional probability

This is a library for simulate probability theory problems specialy conditional probability. It is also useful to create custom single or joint distribution with specific PMF or PDF to get probabilit

Mohamadreza Kariminejad 6 Mar 30, 2022
Click2call for asterisk with python

Click2call para Asterisk com Python Este projeto disponibiliza uma API construíd

Benedito Marques 1 Jan 17, 2022
Sudoku solver using backtracking

Sudoku solver Sudoku solver using backtracking Basically in sudoku, we want to be able to solve a sudoku puzzle given an input like this, which repres

Kylie 99 Jan 07, 2023
A price calculator for multiple things

Price Calculator A price calculator for multiple things Example I have 0.0567kg diamond. The price of diamond in kg is: $4500. Then it says: The price

Abel 1 Nov 26, 2021
Beacon Object File (BOF) to obtain a usable TGT for the current user.

Beacon Object File (BOF) to obtain a usable TGT for the current user.

Connor McGarr 109 Dec 25, 2022
Fastest Semantle solver this side of the Mississippi

semantle Fastest Semantle solver this side of the Mississippi. Roughly 3 average turns to win Measured against (part of) the word2vec-google-news-300

Frank Odom 8 Dec 26, 2022
Grouping nucleotide coordinate ranges.

NuclRanger Grouping nucleotide coordinate ranges. A quick pre-processing step for "bedtools getfasta":- https://bedtools.readthedocs.io/en/latest/cont

Sujanavan Tiruvayipati 1 Oct 04, 2022
Datargsing is a data management and manipulation Python library

Datargsing What is It? Datargsing is a data management and manipulation Python library which is currently in deving Why this library is good? This Pyt

CHOSSY Lucas 10 Oct 24, 2022
Notebook researcher - Notebook researcher with python

notebook_researcher To run the server, you must follow these instructions: At th

4 Sep 02, 2022
Modern robots.txt Parser for Python

Robots Exclusion Protocol Parser for Python Robots.txt parsing in Python. Goals Fetching -- helper utilities for fetching and parsing robots.txts, inc

Moz 176 Dec 16, 2022
The best free and open-source automated time tracker. Cross-platform, extensible, privacy-focused.

Records what you do so that you can know how you've spent your time. All in a secure way where you control the data. Website — Forum — Documentation —

ActivityWatch 7.8k Jan 09, 2023
This Python library searches through a static directory and appends artist, title, track number, album title, duration, and genre to a .json object

This Python library searches through a static directory (needs to match your environment) and appends artist, title, track number, album title, duration, and genre to a .json object. This .json objec

Edan Ybarra 1 Jun 20, 2022
msImpersonate - User account impersonation written in pure Python3

msImpersonate v1.0 msImpersonate is a Python-native user impersonation tool that is capable of impersonating local or network user accounts with valid

Joe Helle 90 Dec 16, 2022
A faster copy of nell's comet nuker

Astro a faster copy of nell's comet nuker also nell uses external libraries like it's cocaine man never learned to use ansi color codes (ily nell) (On

horrid 8 Aug 15, 2022
A simply program to find active jackbox.tv game codes

PeepingJack A simply program to find active jackbox.tv game codes How does this work? It uses a threadpool to loop through all possible codes in a ran

3 Mar 20, 2022
Xkcd.py - Script to generate wallpapers based on XKCD comics

xkcd.py Script to generate wallpapers based on XKCD comics Usage python3 xkcd.py

Gideon Wolfe 11 Sep 06, 2022
A fishing bot script written in Python!

A fishing bot script written in Python!

Anel Drocic 3 Nov 03, 2021
An html wrapper for python

MessySoup What is it? MessySoup is a python wrapper for html elements. While still a ways away, the main goal is to be able to build a wesbite straigh

4 Jan 05, 2022
A water drinking notification every hour to keep you healthy while coding :)

Water_Notification A water drinking notification every hour to keep you healthy while coding. 💧 💧 Stay Hydrated Stay Healthy 💧 💧 Authors @CrazyCat

Arghya Banerjee 1 Dec 22, 2021
디텍션 유틸 모음

Object detection utils 유틸모음 설명 링크 convert convert 관련코드 https://github.com/AI-infinyx/ob_utils/tree/main/convert crawl 구글, 네이버, 빙 등 크롤링 관련 https://gith

codetest 41 Jan 22, 2021