# Poetry Monoranger Plugin
![PyPI - Version](https://img.shields.io/pypi/v/poetry-monoranger-plugin)
![GitHub License](https://img.shields.io/github/license/ag14774/poetry-monoranger-plugin)
[![Tests](https://github.com/ag14774/poetry-monoranger-plugin/actions/workflows/main.yml/badge.svg)](https://github.com/ag14774/poetry-monoranger-plugin/actions/workflows/main.yml)
**Monoranger** is a plugin for [Poetry](https://python-poetry.org/) that helps you manage your monorepo.
**Main Features**:
- Shared `poetry.lock` file across multiple projects in a monorepo
- Shared virtual environment across multiple projects in a monorepo
- Rewrite path dependencies during `poetry build`
## Installation
```bash
poetry self add poetry-monoranger-plugin
```
## Usage
### Expected project structure
The plugin is generally flexible when it comes to the structure of the repository. However, it is expected that each project will have its own `pyproject.toml` file and that the root of the repository will also have a central `pyproject.toml` file including all projects as a path dependency.
```
monorepo/
├── library-one/
│ ├── pyproject.toml
│ └── library_one/
├── library-two/
│ ├── pyproject.toml
│ └── library_two/
├── poetry.lock
└── pyproject.toml
```
The root `pyproject.toml` file should include all projects as a path dependency:
```toml
# ...
[tool.poetry.dependencies]
python = "^3.9"
library-one = { path = "library-one", develop = true }
library-two = { path = "library-two", develop = true }
# ...
```
Each project's `pyproject.toml` file should include the dependencies it needs (including path dependencies to other projects) as well as enabling the plugin:
```toml
# ...
[tool.poetry.dependencies]
python = "^3.9"
numpy = "^1.21.0"
library-two = { path = "../library-two", develop = true }
[tool.poetry-monoranger-plugin]
enabled = true
monorepo-root = "../"
version-rewrite-rule = '==' # Choose between "==", "~", "^", ">=,<"
# ...
```
The plugin by default is disabled in order to avoid having undesired consequences on other projects (as plugins are installed globally). To enable it, set `enabled = true` in each project's `pyproject.toml` file.
### Commands
The plugin modifies the following commands:
- `poetry lock`:
Ensures that the shared lock file (located at the root) is up-to-date irrespective of the directory from which the command is run. This is convenient since it avoids accidentally creating a per-project lock file when running from within a project directory. It also eliminated the need to switch to the root directory to update the lock file.
- `poetry install`:
Installs dependencies for all projects in the monorepo, ensuring that the shared virtual environment is used. As before, this command can be run from any directory within the monorepo without needing to switch to the root directory.
- `poetry update`:
Updates the provided dependency (or all dependencies of **current** project if none provided). This will update the shared lock file as well as installing the updated dependencies in the shared virtual environment.
- `poetry add`:
Adds a new dependency to the `pyproject.toml` of the **current** project, updates the shared lock file, and installs the new dependency in the shared virtual environment. This is equivalent to manually modifying a project's `pyproject.toml` file, followed by running `poetry lock` and `poetry install` from the root directory.
- `poetry remove`:
Removes a dependency from the specified project, updates the shared lockfile, and removes the dependency from the shared virtual environment if it is no longer required by any other project.
- `poetry build`:
Builds the **current** project, replacing editable path dependencies with the current version of the package. This is useful when building a project that depends on another project in the monorepo, as it ensures that the built package can be installed (e.g. as a wheel file) without expecting the other project to be present in a specific location.
### Configuration
The plugin can be configured in the `pyproject.toml` file of each project. The following options are available:
- `enabled` (bool): Whether the plugin is enabled for the current project. Default: `false`
- `monorepo-root` (str): The path to the root of the monorepo. Default: `../`
- `version-rewrite-rule` (str): The version rewrite rule to apply when building the project. Default: `==`
## License
This project is licensed under the Apache 2.0 license - see the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/ag14774/poetry-monoranger-plugin",
"name": "poetry-monoranger-plugin",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "packaging, poetry, monorepo, lockfile, virtualenv",
"author": "Andreas Georgiou",
"author_email": "andreas.x.georgiou@gsk.com",
"download_url": "https://files.pythonhosted.org/packages/f0/00/45b65f18603afb2cdc2857f98cf4b86942e8d32a8a8ac74a3d9416cc6f64/poetry_monoranger_plugin-0.2.0.tar.gz",
"platform": null,
"description": "# Poetry Monoranger Plugin\n\n![PyPI - Version](https://img.shields.io/pypi/v/poetry-monoranger-plugin)\n![GitHub License](https://img.shields.io/github/license/ag14774/poetry-monoranger-plugin)\n[![Tests](https://github.com/ag14774/poetry-monoranger-plugin/actions/workflows/main.yml/badge.svg)](https://github.com/ag14774/poetry-monoranger-plugin/actions/workflows/main.yml)\n\n**Monoranger** is a plugin for [Poetry](https://python-poetry.org/) that helps you manage your monorepo.\n\n**Main Features**:\n- Shared `poetry.lock` file across multiple projects in a monorepo\n- Shared virtual environment across multiple projects in a monorepo\n- Rewrite path dependencies during `poetry build`\n\n## Installation\n\n```bash\npoetry self add poetry-monoranger-plugin\n```\n\n## Usage\n\n### Expected project structure\nThe plugin is generally flexible when it comes to the structure of the repository. However, it is expected that each project will have its own `pyproject.toml` file and that the root of the repository will also have a central `pyproject.toml` file including all projects as a path dependency.\n```\nmonorepo/\n\u251c\u2500\u2500 library-one/\n\u2502 \u251c\u2500\u2500 pyproject.toml\n\u2502 \u2514\u2500\u2500 library_one/\n\u251c\u2500\u2500 library-two/\n\u2502 \u251c\u2500\u2500 pyproject.toml\n\u2502 \u2514\u2500\u2500 library_two/\n\u251c\u2500\u2500 poetry.lock\n\u2514\u2500\u2500 pyproject.toml\n```\n\nThe root `pyproject.toml` file should include all projects as a path dependency:\n```toml\n# ...\n[tool.poetry.dependencies]\npython = \"^3.9\"\nlibrary-one = { path = \"library-one\", develop = true }\nlibrary-two = { path = \"library-two\", develop = true }\n# ...\n```\n\nEach project's `pyproject.toml` file should include the dependencies it needs (including path dependencies to other projects) as well as enabling the plugin:\n```toml\n# ...\n[tool.poetry.dependencies]\npython = \"^3.9\"\nnumpy = \"^1.21.0\"\nlibrary-two = { path = \"../library-two\", develop = true }\n\n[tool.poetry-monoranger-plugin]\nenabled = true\nmonorepo-root = \"../\"\nversion-rewrite-rule = '==' # Choose between \"==\", \"~\", \"^\", \">=,<\"\n# ...\n```\nThe plugin by default is disabled in order to avoid having undesired consequences on other projects (as plugins are installed globally). To enable it, set `enabled = true` in each project's `pyproject.toml` file.\n\n### Commands\nThe plugin modifies the following commands:\n\n- `poetry lock`:\n\nEnsures that the shared lock file (located at the root) is up-to-date irrespective of the directory from which the command is run. This is convenient since it avoids accidentally creating a per-project lock file when running from within a project directory. It also eliminated the need to switch to the root directory to update the lock file.\n\n- `poetry install`:\n\nInstalls dependencies for all projects in the monorepo, ensuring that the shared virtual environment is used. As before, this command can be run from any directory within the monorepo without needing to switch to the root directory.\n\n- `poetry update`:\n\nUpdates the provided dependency (or all dependencies of **current** project if none provided). This will update the shared lock file as well as installing the updated dependencies in the shared virtual environment.\n\n- `poetry add`:\n\nAdds a new dependency to the `pyproject.toml` of the **current** project, updates the shared lock file, and installs the new dependency in the shared virtual environment. This is equivalent to manually modifying a project's `pyproject.toml` file, followed by running `poetry lock` and `poetry install` from the root directory.\n\n- `poetry remove`:\n\nRemoves a dependency from the specified project, updates the shared lockfile, and removes the dependency from the shared virtual environment if it is no longer required by any other project.\n\n- `poetry build`:\n\nBuilds the **current** project, replacing editable path dependencies with the current version of the package. This is useful when building a project that depends on another project in the monorepo, as it ensures that the built package can be installed (e.g. as a wheel file) without expecting the other project to be present in a specific location.\n\n\n### Configuration\nThe plugin can be configured in the `pyproject.toml` file of each project. The following options are available:\n\n- `enabled` (bool): Whether the plugin is enabled for the current project. Default: `false`\n- `monorepo-root` (str): The path to the root of the monorepo. Default: `../`\n- `version-rewrite-rule` (str): The version rewrite rule to apply when building the project. Default: `==`\n\n## License\nThis project is licensed under the Apache 2.0 license - see the [LICENSE](LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Monoranger is a plugin for Poetry that helps you manage your monorepo, enabling shared lockfiles and virtual environments.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/ag14774/poetry-monoranger-plugin",
"Repository": "https://github.com/ag14774/poetry-monoranger-plugin"
},
"split_keywords": [
"packaging",
" poetry",
" monorepo",
" lockfile",
" virtualenv"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7b1d6c52eb66fcb7b3a0284645cdb8367c110225a13a3537a2bdb08895d50dff",
"md5": "90b57aaa7b7cf0ab1c6edf2f145dc189",
"sha256": "24edabf890550cda29953f58528b3bbb58cb532c77e984236fedac3aa20efcf5"
},
"downloads": -1,
"filename": "poetry_monoranger_plugin-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "90b57aaa7b7cf0ab1c6edf2f145dc189",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 16720,
"upload_time": "2024-12-18T20:58:25",
"upload_time_iso_8601": "2024-12-18T20:58:25.005601Z",
"url": "https://files.pythonhosted.org/packages/7b/1d/6c52eb66fcb7b3a0284645cdb8367c110225a13a3537a2bdb08895d50dff/poetry_monoranger_plugin-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f00045b65f18603afb2cdc2857f98cf4b86942e8d32a8a8ac74a3d9416cc6f64",
"md5": "e05795b693f87170ab9c58467d672ac0",
"sha256": "569b7a48d15dc330b2335563d9727f5bd359452383fc0cfc694c99e424555a34"
},
"downloads": -1,
"filename": "poetry_monoranger_plugin-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "e05795b693f87170ab9c58467d672ac0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 14152,
"upload_time": "2024-12-18T20:58:26",
"upload_time_iso_8601": "2024-12-18T20:58:26.968882Z",
"url": "https://files.pythonhosted.org/packages/f0/00/45b65f18603afb2cdc2857f98cf4b86942e8d32a8a8ac74a3d9416cc6f64/poetry_monoranger_plugin-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-18 20:58:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ag14774",
"github_project": "poetry-monoranger-plugin",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "poetry-monoranger-plugin"
}