poetry-bundle-local-deps-plugin


Namepoetry-bundle-local-deps-plugin JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/lucasvieirasilva/poetry-bundle-local-deps-plugin
SummaryPoetry Plugin for Bundling Local Dependencies
upload_time2024-11-07 23:00:12
maintainerNone
docs_urlNone
authorLucas Vieira
requires_python<4,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Poetry Bundle Local Dependencies Plugin

## SonarCloud Status

[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=bugs)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)

[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)

Poetry plugin to bundle local dependencies (only path, not supported git or url) into a single package.

## Motivation

Poetry is a great tool to manage Python dependencies, and works perfectly when there only one pyproject in the repository, however, for many reasons, you may want to have multiple pyproject files in the same repository, and have local shared dependencies to avoid code duplication, however, when you want to distribute your package, the `poetry build` command generates the dist package referencing the local path, which does not work in other environments.

In some cases, you don't want to publish all the auxiliary packages, or if you are deploying your application to a Docker or an AWS Lambda, you also don't want to deal with resolving the local dependencies by yourself.

This plugin aims to solve this problem by intercepting the `poetry build` command and generating the dist package with the local dependencies and their dependencies bundled into a single package.

This plugin is lightweight version of [@nxlv/python](https://www.npmjs.com/package/@nxlv/python) Nx monorepo plugin.

## How it works

1. Intercept the `poetry build` command.
2. Create a temporary directory.
3. Copy all the project files to the temporary directory.
4. Read the `pyproject.toml` and find the local dependencies.
5. For each local dependency, copy the `pyproject.toml::tool.poetry.packages` to the temporary directory, (recursively if necessary).
6. Let Poetry build continue as usual (pointing to the temporary directory).
7. After the build is done, copy the generated dist package to the original directory.
8. Remove the temporary directory.

### Example

`package/a/pyproject.toml`

```toml
[tool.poetry]
name = "a"
version = "0.1.0"
description = ""

  [[tool.poetry.packages]]
  include = "a"

[tool.poetry.dependencies]
python = "^3.12"
b = { path = "../b", develop = true }
```

`package/b/pyproject.toml`

```toml
[tool.poetry]
name = "b"
version = "0.1.0"
description = ""

  [[tool.poetry.packages]]
  include = "b"

[tool.poetry.dependencies]
python = "^3.12"
requests = "^2.32.3"
```

The standard behavior of `poetry build` would generate the following dist package:

`a-0.1.0.dist-info/METADATA`

```text
Metadata-Version: 2.1
Name: a
Version: 0.1.0
Summary:
Requires-Python: >=3.12,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: b @ file:///Users/lucasvieira/Projects/poetry-bundle-local-deps-plugin-demo/packages/b
```

`a-0.1.0/`

```text
- a/*.py
- PKG-INFO
- pyproject.toml
```

Which would not work if you try to install it in another environment.

With this plugin, the dist package would be:

`a-0.1.0.dist-info/METADATA`

```text
Metadata-Version: 2.1
Name: a
Version: 0.1.0
Summary:
Requires-Python: >=3.12,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: requests (>=2.32.3,<3.0.0)
```

`a-0.1.0/`

```text
- a/*.py
- b/*.py
- PKG-INFO
- pyproject.toml
```

Which would work in any environment, because all the dependencies are bundled into a single package.

## Install

`poetry self add poetry-bundle-local-deps-plugin`

## Usage

Enable the plugin in the `pyproject.toml`:

```toml
[tool.bundle_local_deps_config]
enabled = true
```

Run the `poetry build` command as usual.

## Contributing

- See our [Contributing Guide](CONTRIBUTING.md)

## Change Log

- See our [Change Log](CHANGELOG.md)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lucasvieirasilva/poetry-bundle-local-deps-plugin",
    "name": "poetry-bundle-local-deps-plugin",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Lucas Vieira",
    "author_email": "lucas.vieira94@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/20/21/1c80643d5c5403b2961920e7a9d240d6fe7149f9179404cd28ee4eb04d4d/poetry_bundle_local_deps_plugin-0.2.1.tar.gz",
    "platform": null,
    "description": "# Poetry Bundle Local Dependencies Plugin\n\n## SonarCloud Status\n\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=bugs)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=lucasvieirasilva_poetry-bundle-local-deps-plugin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=lucasvieirasilva_poetry-bundle-local-deps-plugin)\n\nPoetry plugin to bundle local dependencies (only path, not supported git or url) into a single package.\n\n## Motivation\n\nPoetry is a great tool to manage Python dependencies, and works perfectly when there only one pyproject in the repository, however, for many reasons, you may want to have multiple pyproject files in the same repository, and have local shared dependencies to avoid code duplication, however, when you want to distribute your package, the `poetry build` command generates the dist package referencing the local path, which does not work in other environments.\n\nIn some cases, you don't want to publish all the auxiliary packages, or if you are deploying your application to a Docker or an AWS Lambda, you also don't want to deal with resolving the local dependencies by yourself.\n\nThis plugin aims to solve this problem by intercepting the `poetry build` command and generating the dist package with the local dependencies and their dependencies bundled into a single package.\n\nThis plugin is lightweight version of [@nxlv/python](https://www.npmjs.com/package/@nxlv/python) Nx monorepo plugin.\n\n## How it works\n\n1. Intercept the `poetry build` command.\n2. Create a temporary directory.\n3. Copy all the project files to the temporary directory.\n4. Read the `pyproject.toml` and find the local dependencies.\n5. For each local dependency, copy the `pyproject.toml::tool.poetry.packages` to the temporary directory, (recursively if necessary).\n6. Let Poetry build continue as usual (pointing to the temporary directory).\n7. After the build is done, copy the generated dist package to the original directory.\n8. Remove the temporary directory.\n\n### Example\n\n`package/a/pyproject.toml`\n\n```toml\n[tool.poetry]\nname = \"a\"\nversion = \"0.1.0\"\ndescription = \"\"\n\n  [[tool.poetry.packages]]\n  include = \"a\"\n\n[tool.poetry.dependencies]\npython = \"^3.12\"\nb = { path = \"../b\", develop = true }\n```\n\n`package/b/pyproject.toml`\n\n```toml\n[tool.poetry]\nname = \"b\"\nversion = \"0.1.0\"\ndescription = \"\"\n\n  [[tool.poetry.packages]]\n  include = \"b\"\n\n[tool.poetry.dependencies]\npython = \"^3.12\"\nrequests = \"^2.32.3\"\n```\n\nThe standard behavior of `poetry build` would generate the following dist package:\n\n`a-0.1.0.dist-info/METADATA`\n\n```text\nMetadata-Version: 2.1\nName: a\nVersion: 0.1.0\nSummary:\nRequires-Python: >=3.12,<4.0\nClassifier: Programming Language :: Python :: 3\nClassifier: Programming Language :: Python :: 3.12\nRequires-Dist: b @ file:///Users/lucasvieira/Projects/poetry-bundle-local-deps-plugin-demo/packages/b\n```\n\n`a-0.1.0/`\n\n```text\n- a/*.py\n- PKG-INFO\n- pyproject.toml\n```\n\nWhich would not work if you try to install it in another environment.\n\nWith this plugin, the dist package would be:\n\n`a-0.1.0.dist-info/METADATA`\n\n```text\nMetadata-Version: 2.1\nName: a\nVersion: 0.1.0\nSummary:\nRequires-Python: >=3.12,<4.0\nClassifier: Programming Language :: Python :: 3\nClassifier: Programming Language :: Python :: 3.12\nRequires-Dist: requests (>=2.32.3,<3.0.0)\n```\n\n`a-0.1.0/`\n\n```text\n- a/*.py\n- b/*.py\n- PKG-INFO\n- pyproject.toml\n```\n\nWhich would work in any environment, because all the dependencies are bundled into a single package.\n\n## Install\n\n`poetry self add poetry-bundle-local-deps-plugin`\n\n## Usage\n\nEnable the plugin in the `pyproject.toml`:\n\n```toml\n[tool.bundle_local_deps_config]\nenabled = true\n```\n\nRun the `poetry build` command as usual.\n\n## Contributing\n\n- See our [Contributing Guide](CONTRIBUTING.md)\n\n## Change Log\n\n- See our [Change Log](CHANGELOG.md)\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Poetry Plugin for Bundling Local Dependencies",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/lucasvieirasilva/poetry-bundle-local-deps-plugin",
        "Repository": "https://github.com/lucasvieirasilva/poetry-bundle-local-deps-plugin"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8a5aa3f9812280f516fe64207fbcc84fd7eaa0df5f8ddd7c6cc9f1e129e7e8e",
                "md5": "964c704e9b17e718165333cb26731203",
                "sha256": "1e93ce8a9ff11eb4f7a69e4c43dfd9cc01a96f9b1b1ea0be0e70adf051a84ea7"
            },
            "downloads": -1,
            "filename": "poetry_bundle_local_deps_plugin-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "964c704e9b17e718165333cb26731203",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.9",
            "size": 6211,
            "upload_time": "2024-11-07T23:00:11",
            "upload_time_iso_8601": "2024-11-07T23:00:11.667986Z",
            "url": "https://files.pythonhosted.org/packages/a8/a5/aa3f9812280f516fe64207fbcc84fd7eaa0df5f8ddd7c6cc9f1e129e7e8e/poetry_bundle_local_deps_plugin-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "20211c80643d5c5403b2961920e7a9d240d6fe7149f9179404cd28ee4eb04d4d",
                "md5": "f2b74f0202d1283b69bf1db6aef6df2f",
                "sha256": "5c776d916546ee86e3649bb6ba4588169b891a58aec9d62a5cbe5a7c26f4f535"
            },
            "downloads": -1,
            "filename": "poetry_bundle_local_deps_plugin-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f2b74f0202d1283b69bf1db6aef6df2f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.9",
            "size": 5461,
            "upload_time": "2024-11-07T23:00:12",
            "upload_time_iso_8601": "2024-11-07T23:00:12.671952Z",
            "url": "https://files.pythonhosted.org/packages/20/21/1c80643d5c5403b2961920e7a9d240d6fe7149f9179404cd28ee4eb04d4d/poetry_bundle_local_deps_plugin-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-07 23:00:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lucasvieirasilva",
    "github_project": "poetry-bundle-local-deps-plugin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "poetry-bundle-local-deps-plugin"
}
        
Elapsed time: 0.39773s