Skip to content

Commit

Permalink
Add python packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Vanden Broeck committed May 27, 2024
1 parent e51e4d9 commit 4973342
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 8 deletions.
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ RUN apk add --no-cache python3 python3-dev py3-pip gcc jq \

RUN python3 -m venv --upgrade-deps /opt/venv

COPY requirements.txt /opt
COPY ansible_collection_helper.py /opt/
COPY templates /opt/templates/

RUN /opt/venv/bin/pip install -r /opt/requirements.txt
COPY . /usr/local/src/ansible_collection_helper
RUN /opt/venv/bin/pip install --no-cache-dir /usr/local/src/ansible_collection_helper &&\
rm -rf /usr/local/src/ansible_collection_helper
7 changes: 7 additions & 0 deletions hatch.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2021 Dalibo
#
# SPDX-License-Identifier: GPL-3.0-or-later

[version]
source = "vcs"
raw-options = { git_describe_command = ["git", "describe", "--dirty", "--tags", "--long", "--match", "v[0-9]*"] }
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-FileCopyrightText: 2024 Dalibo
#
# SPDX-License-Identifier: GPL-3.0-or-later
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "ansible_collection_helper"
description = "Helper to manage Ansible collection"
readme = "README.md"
requires-python = ">=3.11, <4"
license = { text = "GPLv3" }
authors = [{ name = "Dalibo SCOP", email = "[email protected]" }]
keywords = [
"ansible",
"command-line",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Topic :: System :: Systems Administration",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
]
dynamic = ["version"]

dependencies = [
"ansible==8.6.1",
"ansible-compat==4.1.10",
"ansible-core==2.15.6",
"ansible-lint==6.22.0",
"codespell==2.2.6",
"distlib==0.3.8",
"molecule==6.0.2",
"molecule-plugins[docker]==23.5.0",
"pytest-testinfra==10.0.0",
"urllib3<2"
]

[project.urls]
Source = "https://github.com/dalibo/docker-dind-molecule/"
Tracker = "https://github.com/dalibo/docker-dind-molecule/"


[project.scripts]
ansible_collection_helper = "ansible_collection_helper:helper.main"
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@

import yaml
from ansible.cli.doc import DocCLI
from jinja2 import Environment, FileSystemLoader
from jinja2 import Environment, PackageLoader

env = Environment(loader=FileSystemLoader((Path(__file__).parent / "templates")))
from . import __name__ as pkgname

env = Environment(
loader=PackageLoader(package_name=pkgname, package_path="templates"),
trim_blocks=True,
lstrip_blocks=True,
)
template = env.get_template("readme.jinja2")


Expand All @@ -31,7 +37,7 @@ def generate_role_documentation(
logging.info("generate README for %s", role_name)
spec = yaml.safe_load(f_spec)["argument_specs"]["main"]
options: Sequence[str] = []
DocCLI.add_fields(options, spec["options"], limit=120, opt_indent=" ")
DocCLI.add_fields(options, spec["options"], limit=1000, opt_indent=" ")
f_doc.write(
template.render(
role_name=role_name,
Expand Down
File renamed without changes.

0 comments on commit 4973342

Please sign in to comment.