Skip to main content

PyPI version Downloads Downloads Downloads

About

pip install toml-union

This PyPI package is indeed located in one script and combines several *.toml files (usially pyproject.toml) into one. If it finds some conflicts between items, they will be kept for manual review.

It has a docker image (docker pull pasaopasen/toml-union) and an example of its usage.

Python usage example

from pathlib import Path

from toml_union import toml_union_process

# run union
toml_union_process(
    files=Path('input').glob('*.toml'),   # get all *.toml files from examples dir
    outfile='output.toml',  # set output file path
    report='report.json',   # path for conflicts report on conflict case
)

It combines next files:

[tool.poetry]
name = "project 1"
version = "1.6.0"
description = "Some words"
authors = ["Me"]

[tool.poetry.dependencies]
"pdfminer.six" = "^20220524"
cmake = "^3.21.1"
other_package = "1"

[tool.poetry.group.dev.dependencies]
autopep8 = "^1.5"
black = "~21.8b0"
ipython = "^8.0"
pylint-django = "^2.3.0"
pytest-django = "^4.5.2"
[tool.poetry]
name = "project 2"
version = "1.6.0"
description = "Some words"
authors = ["Me"]

[tool.poetry.dependencies]
"pdfminer.six" = "^2022333333334"
torch = { version = "1.10.1+cu113", source = "pytorch" }
torchvision = { version = "0.11.2+cu113", source = "pytorch" }
other_package = "2"

[tool.poetry.group.dev.dependencies]
autopep8 = "^1.5"
black = "~21.8b0"
pytest-django = "^4.5.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "project 1"
version = "1.6.0"
description = "Some words"
authors = ["Somebody"]

[tool.poetry.dependencies]
"pdfminer.six" = "^20220524"
ansi2html = "^1.7"
beautifulsoup4 = "^4.10.0"
boto3 = "^1.16.56"
chardet = "^4.0.0"
Django = "~3.1"
django-allauth = "^0.51"
django-rosetta = "^0.9.5"
djangorestframework = "3.13.1"
cmake = "~3.21.1"

[tool.poetry.group.dev.dependencies]
autopep8 = ">=1.5.6"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

to this one:

[build-system]
build-backend = [ "poetry.core.masonry.api", "poetry.masonry.api",]
requires = [ "poetry-core>=1.0.0", "poetry>=0.12",]

[tool.poetry]
authors = [ "Me", "Somebody",]
description = "Some words"
name = [ "project 1", "project 2",]
version = "1.6.0"

[tool.poetry.dependencies]
"pdfminer.six" = [ "^20220524", "^2022333333334",]
ansi2html = "^1.7"
beautifulsoup4 = "^4.10.0"
boto3 = "^1.16.56"
chardet = "^4.0.0"
cmake = [ "^3.21.1", "~3.21.1",]
Django = "~3.1"
django-allauth = "^0.51"
django-rosetta = "^0.9.5"
djangorestframework = "3.13.1"
other_package = [ "1", "2",]

[tool.poetry.dependencies.torch]
source = "pytorch"
version = "1.10.1+cu113"

[tool.poetry.dependencies.torchvision]
source = "pytorch"
version = "0.11.2+cu113"

[tool.poetry.group.dev.dependencies]
autopep8 = [ "^1.5", ">=1.5.6",]
black = "~21.8b0"
ipython = "^8.0"
pylint-django = "^2.3.0"
pytest-django = "^4.5.2"

As u see, some packages have confict versions. In this case the report file is created and contains the sources of this conflicts:

"pdfminer.six": {
    "^20220524": [
    "input/file1.toml",
    "input/file3.toml"
    ],
    "^2022333333334": [
    "input/file2.toml"
    ]
},
"cmake": {
    "^3.21.1": [
    "input/file1.toml"
    ],
    "~3.21.1": [
    "input/file3.toml"
    ]
},
"other_package": {
    "1": [
    "input/file1.toml"
    ],
    "2": [
    "input/file2.toml"
    ]
}

Overrides

There is the ability to override some items in target *.toml file. Use syntax:

toml_union_process(
    files=Path('input').glob('*.toml'),
    outfile='output.toml',
    report='report.json',

    overrides={
        'tool.poetry.name': 'union',
        'tool.poetry.version': '12'
    }
)

In the result u will have:

[tool.poetry]
name = "union"
version = "12"

CLI

Equivalent CLI command:

toml-union examples/input/file1.toml examples/input/file2.toml examples/input/file3.toml -o output.toml -r report.json -k tool.poetry.name=union -k tool.poetry.version=12

Help message:

toml-union -h

usage: toml_union.py [-h] [--output OUTFILE] [--unicode-escape] [--report REPORT] [--remove-field [REMOVE_FIELDS [REMOVE_FIELDS ...]]] [--key-value KEY=VALUE] [--ckey-value KEY=VALUE] INPUT [INPUT ...]

Combines several toml files to one with conflicts showing

positional arguments:
  INPUT                 input toml files paths

optional arguments:
  -h, --help            show this help message and exit
  --output OUTFILE, -o OUTFILE
                        output toml file path, empty value means to print to console (default: None)
  --unicode-escape, -u  whether to try to escape unicode sequences in the outfile, useful when outfile has many slashes and codes (default: False)
  --report REPORT, -r REPORT
                        path to report json on failure (default: None)
  --remove-field [REMOVE_FIELDS [REMOVE_FIELDS ...]], -e [REMOVE_FIELDS [REMOVE_FIELDS ...]]
                        Fields to remove. May appear multiple times (default: None)
  --key-value KEY=VALUE, -k KEY=VALUE
                        Add key/value params. May appear multiple times (default: {})
  --ckey-value KEY=VALUE, -c KEY=VALUE
                        Same as --key-value but will be performed only on conflict cases (default: {})

Metadata

Release files for toml-union 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for toml-union 1.0.4
File Size Uploaded
toml_union-1.0.4.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for toml-union 1.0.4
File Interpreter ABI Platform
toml_union-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / toml_union-1.0.4.tar.gz

Download URL toml_union-1.0.4.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1c72307cb2d3fd1967a1c3076c2c862549c9d24dfd643dccc72a2d736f3d771e
BLAKE2b-256 checksum
How to use checksums
d46118f3edd3a85d1e4ec4a62aa4be3a4a1351757c05ac52edeb56a312f0104e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / toml_union-1.0.4-py3-none-any.whl

Download URL toml_union-1.0.4-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00ae4c6459cba1fe3033b8103ce0ac1f11c62723b44f871fbd55f0d24c8ad769
BLAKE2b-256 checksum
How to use checksums
2945dd817b194a389f87a9149d1d19881fe5ce3dc029648ceba1fc574c6743e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page