<#18179 Individual versioning using semver/commiti...
# github-notifications
q
#18179 Individual versioning using semver/commitizen Issue created by IsmaelMartinez Is your feature request related to a problem? Please describe. When packaging multiple libraries, I don't find a way to increase their version number (patch, minor, major) automatically. Currently it requires to remember to edit the
pyproject.toml
file Describe the solution you'd like It would be ideal if the package command can automatically increase the version number depending on the commits by using commitizen or others. Describe alternatives you've considered Adding a plugin (probably better than a macro) might be able to archive this, but haven't had the time to explore that option. The idea is that it will run just before the package command and increase the version number of any libraries that has changed. Appreciate if you can provide more info in other ways and/or examples to archive this. Additional context We use poetry for our libraries, and have a mono repo that generates multiple libraries (for external systems to consume). An example. If I got 3 pyproject.toml that then I publish as libraries, called A,B and C. Assuming dependencies goes like this C -> B -> A. Meaning, B depends on A and C depends on B. • If A changes, I would like the version number for A, B and C to increase. • If B changes, I would like the version of B and C to change. • If C changes, Then I would like only the version in C to change. Does this make sense? A bonus extra would be to detect what number to increase depending on the commit (using git commitizen or similar) but I can live without that Our libraries have a poetry file like this:
Copy code
[tool.poetry]
name = "library_1"
version = "2.0.0"
description = "my internal library"
authors = ["<mailto:blabla@blablabla.com|blabla@blablabla.com>"]
readme = "README.md"
repository = "<https://ohhh-this-url-is-amazing/but-is-not-real>"

[tool.poetry.dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Got a wee publish macro that looks like this:
Copy code
# flake8: noqa: F821
def poetry_distribution(name, **kwargs):
    resources(name="package_data", sources=["pyproject.toml", "README.md"])

    python_distribution(
        name="dist",
        dependencies=[":package_data", f"src/python/{name}/src", "//:root"],
        provides=python_artifact(name=name),
        generate_setup=False,
    )
Then in the folder for each library I have this in the BUILD file
Copy code
poetry_distribution(
    name="name-of-my-library",
)
The project structure is like this:
Copy code
├── BUILD
├── dependencies.lock
├── dist
│   ├── library-1-2.0.0-py2.py3-none-any.whl
│   ├── library-1-2.0.0.tar.gz
│   ├── library-2-5.0.0-py2.py3-none-any.whl
│   ├── library-2-5.0.0.tar.gz
│   ├── library-3-3.0.0-py2.py3-none-any.whl
│   ├── library-3-3.0.0.tar.gz
│   ├── library-4-2.0.0-py2.py3-none-any.whl
│   └── library-4-2.0.0.tar.gz
├── pants
├── pants.toml
├── pants_plugins
│   ├── BUILD
│   └── macros.py <- This is where I have put the macro
├── pyproject.toml
├── setup.cfg
└── src
    └── python
        ├── library-1
        │   ├── BUILD
        │   ├── README.md
        │   ├── pyproject.toml
        │   ├── src
        │   │   ├── BUILD
        │   │   └── library-1.py
        │   └── test
        │       ├── BUILD
        │       └── test_library-1.py
        ├── library-2
        │   ├── BUILD
        │   ├── README.md
        │   ├── pyproject.toml
        │   └── src
        │       ├── BUILD
        │       ├── library-2.py
        │       ├── test_something_else_library-2.py
        │       └── test_library-2.py
        ├── library-3
        │   ├── BUILD
        │   ├── README.md
        │   ├── pyproject.toml
        │   └── src
        │       ├── BUILD
        │       ├── __init__.py
        │       ├── library-3.py
        │       └── test_library-3.py
        └── ppl_library-4
            ├── BUILD
            ├── README.md
            ├── pyproject.toml
            └── src
                ├── BUILD
                ├── ppl_library-4.py
                └── test_library-4.py
The only root source config I got in the pants.toml is
Copy code
[source]
root_patterns = ['/src/python/*/src', '/']
And added also this like to activate the macros
Copy code
build_file_prelude_globs = ["pants_plugins/macros.py"]
Thanks in advance!! From this slack message pantsbuild/pants