# 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/67/3d/ceecf38cb66bb694771f7fadb57c0df935c8ac9cd29d9ca7db7649eea1cf/poetry_monoranger_plugin-0.1.2.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.1.2",
"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": "534220be76c47251c6a2b03c881f168859022b3a468844e77c800c0df99417dd",
"md5": "a228f38049d661381da48162c177b23c",
"sha256": "9d3d68d617727a7363fc20d15c24e084eb5556e98487c4d58e9cb054fc0e9d4e"
},
"downloads": -1,
"filename": "poetry_monoranger_plugin-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a228f38049d661381da48162c177b23c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 16465,
"upload_time": "2024-10-15T15:58:03",
"upload_time_iso_8601": "2024-10-15T15:58:03.263351Z",
"url": "https://files.pythonhosted.org/packages/53/42/20be76c47251c6a2b03c881f168859022b3a468844e77c800c0df99417dd/poetry_monoranger_plugin-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "673dceecf38cb66bb694771f7fadb57c0df935c8ac9cd29d9ca7db7649eea1cf",
"md5": "07704e10d395bcded18c216cd3a19851",
"sha256": "e033d1832a74b5cd9db443156c9d3d992a9f801e1dc1bf65d49cb57176190e92"
},
"downloads": -1,
"filename": "poetry_monoranger_plugin-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "07704e10d395bcded18c216cd3a19851",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 14033,
"upload_time": "2024-10-15T15:58:05",
"upload_time_iso_8601": "2024-10-15T15:58:05.051626Z",
"url": "https://files.pythonhosted.org/packages/67/3d/ceecf38cb66bb694771f7fadb57c0df935c8ac9cd29d9ca7db7649eea1cf/poetry_monoranger_plugin-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-15 15:58:05",
"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"
}