Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bases/polylith/cli/create.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

from polylith import project
from polylith import interactive, project
from polylith.bricks import base, component
from polylith.commands.create import create
from polylith.workspace.create import create_workspace
Expand Down Expand Up @@ -52,7 +52,7 @@ def project_command(
"""Creates a Polylith project."""
create(name, description, _create_project)

project.interactive.run(name)
interactive.project.run(name)


@app.command("workspace")
Expand Down
4 changes: 2 additions & 2 deletions components/polylith/commands/sync.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from typing import Union

from polylith import info, project, sync
from polylith import info, interactive, sync


def is_project_without_bricks(project_data: dict) -> bool:
Expand All @@ -17,7 +17,7 @@ def choose_base(root: Path, ns: str, project_data: dict) -> Union[str, None]:
if not possible_bases:
return None

return project.interactive.choose_base_for_project(
return interactive.project.choose_base_for_project(
root, ns, project_data["name"], possible_bases
)

Expand Down
3 changes: 3 additions & 0 deletions components/polylith/interactive/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from polylith.interactive import project

__all__ = ["project"]
4 changes: 2 additions & 2 deletions components/polylith/poetry/commands/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from cleo.helpers import option
from poetry.console.commands.command import Command
from polylith import project
from polylith import interactive, project
from polylith.commands.create import create

command_name = "poly create project"
Expand Down Expand Up @@ -37,6 +37,6 @@ def handle(self) -> int:

create(name, description, create_project)

project.interactive.run(name)
interactive.project.run(name)

return 0
2 changes: 0 additions & 2 deletions components/polylith/project/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from polylith.project import interactive
from polylith.project.create import create_project
from polylith.project.get import (
get_packages_for_projects,
Expand All @@ -14,6 +13,5 @@
"get_project_name",
"get_project_template",
"get_toml",
"interactive",
"parse_package_paths",
]
87 changes: 5 additions & 82 deletions components/polylith/project/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,84 +4,7 @@

import tomlkit
from polylith import configuration, repo, toml

poetry_pyproject_template = """\
[tool.poetry]
name = "{name}"
version = "0.1.0"
{description}
{authors}
license = ""

packages = []

[tool.poetry.dependencies]
python = "{python_version}"

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

poetry_pep621_pyproject_template = """\
[tool.poetry]
packages = []

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

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

hatch_pyproject_template = """\
[build-system]
requires = ["hatchling", "hatch-polylith-bricks"]
build-backend = "hatchling.build"

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

[tool.hatch.build.targets.wheel]
packages = ["{namespace}"]

[tool.hatch.build.hooks.polylith-bricks]

[tool.polylith.bricks]
"""

pdm_pyproject_template = """\
[build-system]
requires = ["pdm-backend", "pdm-polylith-bricks"]
build-backend = "pdm.backend"

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

[tool.polylith.bricks]
"""
from polylith.project import templates


def get_project_name(toml_data) -> str:
Expand Down Expand Up @@ -147,18 +70,18 @@ def get_packages_for_projects(root: Path) -> List[dict]:

def _get_poetry_template(pyproject: dict) -> str:
if repo.is_pep_621_ready(pyproject):
return poetry_pep621_pyproject_template
return templates.poetry_pep621_pyproject_template

return poetry_pyproject_template
return templates.poetry_pyproject_template


def guess_project_template(pyproject: dict) -> str:
if repo.is_poetry(pyproject):
template = _get_poetry_template(pyproject)
elif repo.is_hatch(pyproject):
template = hatch_pyproject_template
template = templates.hatch_pyproject_template
elif repo.is_pdm(pyproject):
template = pdm_pyproject_template
template = templates.pdm_pyproject_template
else:
raise ValueError("Failed to guess the type of Project")

Expand Down
154 changes: 154 additions & 0 deletions components/polylith/project/templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
poetry_pyproject_template = """\
[tool.poetry]
name = "{name}"
version = "0.1.0"
{description}
{authors}
license = ""

packages = []

[tool.poetry.dependencies]
python = "{python_version}"

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

poetry_pep621_pyproject_template = """\
[tool.poetry]
packages = []

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

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

hatch_pyproject_template = """\
[build-system]
requires = ["hatchling", "hatch-polylith-bricks"]
build-backend = "hatchling.build"

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

[tool.hatch.build.targets.wheel]
packages = ["{namespace}"]

[tool.hatch.build.hooks.polylith-bricks]

[tool.polylith.bricks]
"""

pdm_pyproject_template = """\
[build-system]
requires = ["pdm-backend", "pdm-polylith-bricks"]
build-backend = "pdm.backend"

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

[tool.polylith.bricks]
"""
poetry_pyproject_template = """\
[tool.poetry]
name = "{name}"
version = "0.1.0"
{description}
{authors}
license = ""

packages = []

[tool.poetry.dependencies]
python = "{python_version}"

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

poetry_pep621_pyproject_template = """\
[tool.poetry]
packages = []

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

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

hatch_pyproject_template = """\
[build-system]
requires = ["hatchling", "hatch-polylith-bricks"]
build-backend = "hatchling.build"

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

[tool.hatch.build.targets.wheel]
packages = ["{namespace}"]

[tool.hatch.build.hooks.polylith-bricks]

[tool.polylith.bricks]
"""

pdm_pyproject_template = """\
[build-system]
requires = ["pdm-backend", "pdm-polylith-bricks"]
build-backend = "pdm.backend"

[project]
name = "{name}"
version = "0.1.0"
{description}
{authors}

requires-python = "{python_version}"

dependencies = []

[tool.polylith.bricks]
"""
3 changes: 2 additions & 1 deletion projects/poetry_polylith_plugin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry-polylith-plugin"
version = "1.45.1"
version = "1.45.2"
description = "A Poetry plugin that adds tooling support for the Polylith Architecture"
authors = ["David Vujic"]
homepage = "https://davidvujic.github.io/python-polylith-docs/"
Expand All @@ -23,6 +23,7 @@ packages = [
{ include = "polylith/files", from = "../../components" },
{ include = "polylith/imports", from = "../../components" },
{ include = "polylith/info", from = "../../components" },
{ include = "polylith/interactive",from = "../../components" },
{ include = "polylith/interface", from = "../../components" },
{ include = "polylith/libs", from = "../../components" },
{ include = "polylith/output", from = "../../components" },
Expand Down
3 changes: 2 additions & 1 deletion projects/polylith_cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "polylith-cli"
version = "1.38.1"
version = "1.38.2"
description = "Python tooling support for the Polylith Architecture"
authors = ['David Vujic']
homepage = "https://davidvujic.github.io/python-polylith-docs/"
Expand All @@ -24,6 +24,7 @@ packages = [
{ include = "polylith/files", from = "../../components" },
{ include = "polylith/imports", from = "../../components" },
{ include = "polylith/info", from = "../../components" },
{ include = "polylith/interactive",from = "../../components" },
{ include = "polylith/interface", from = "../../components" },
{ include = "polylith/libs", from = "../../components" },
{ include = "polylith/output", from = "../../components" },
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ packages = [
{ include = "polylith/hatch", from = "components" },
{ include = "polylith/imports", from = "components" },
{ include = "polylith/info", from = "components" },
{ include = "polylith/interactive",from = "components" },
{ include = "polylith/interface", from = "components" },
{ include = "polylith/libs", from = "components" },
{ include = "polylith/output", from = "components" },
Expand Down
2 changes: 1 addition & 1 deletion test/components/polylith/project/test_templates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
import tomlkit
from polylith.project.get import (
from polylith.project.templates import (
hatch_pyproject_template,
pdm_pyproject_template,
poetry_pyproject_template,
Expand Down