diff options
| author | Jaime Resano <Jaime.Resano-Aisa@qt.io> | 2025-02-24 16:11:28 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-03-12 22:15:36 +0100 |
| commit | 545ca796dbd93edb66dc3c21c74511fab8e9d0a3 (patch) | |
| tree | 864fa936fb5986d39ec2477b87671550f4dae830 /sources/pyside-tools/project_lib/pyproject_json.py | |
| parent | 3ea026146e4c4f13d9069099c18f50df62020e62 (diff) | |
pyproject.toml: 2. Add pyproject.toml support for pyside6 tools
This patch adds support for pyproject.toml files to the pyside6-project
tool. A new command argument is added to migrate a .pyproject JSON file
to the new pyproject.toml file:
`pyside6-project migrate-pyproject`
The new features are tested and it is guaranteed that the current
behavior is preserved. A new flag is added to the project creation operations, "--legacy-pyproject", in order to generate a .pyproject file instead of a pyproject.toml file.
Note that the tomlkit library is added to the requirements.txt file.
https://github.com/python-poetry/tomlkit
Task-number: PYSIDE-2714
Change-Id: If33956dea73b79df0a52d4dcda3934c85e57182d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools/project_lib/pyproject_json.py')
| -rw-r--r-- | sources/pyside-tools/project_lib/pyproject_json.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sources/pyside-tools/project_lib/pyproject_json.py b/sources/pyside-tools/project_lib/pyproject_json.py index abef7e2f4..2b0b9da15 100644 --- a/sources/pyside-tools/project_lib/pyproject_json.py +++ b/sources/pyside-tools/project_lib/pyproject_json.py @@ -6,6 +6,21 @@ from pathlib import Path from .pyproject_parse_result import PyProjectParseResult +def write_pyproject_json(pyproject_file: Path, project_files: list[str]): + """ + Create or update a *.pyproject file with the specified content. + + :param pyproject_file: The *.pyproject file path to create or update. + :param project_files: The relative paths of the files to include in the project. + """ + # The content of the file is fully replaced, so it is not necessary to read and merge any + # existing content + content = { + "files": sorted(project_files), + } + pyproject_file.write_text(json.dumps(content), encoding="utf-8") + + def parse_pyproject_json(pyproject_json_file: Path) -> PyProjectParseResult: """ Parse a pyproject.json file and return a PyProjectParseResult object. |
