Skip to content

Commit

Permalink
Add default template, add optional dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
u committed Jan 8, 2025
1 parent 743682c commit bdc3aec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 13 additions & 1 deletion py2pack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
import libarchive
except ModuleNotFoundError:
libarchive = None

DEFAULT_TEMPLATE = 'opensuse.spec'
try:
import distro
DEFAULT_TEMPLATE = {
'fedora' : 'fedora.spec',
'debian' : 'opensuse.dsc',
'mageia' : 'mageia.spec'
}.get(distro.id(), DEFAULT_TEMPLATE)
except ModuleNotFoundError:
pass

import io


Expand Down Expand Up @@ -530,7 +542,7 @@ def main():
parser_generate.add_argument('--source-glob', help='source glob template')
parser_generate.add_argument('--local', action='store_true', help='build from local package')
parser_generate.add_argument('--localfile', default='', help='path to the local PKG-INFO or json metadata')
parser_generate.add_argument('-t', '--template', choices=file_template_list(), default='opensuse.spec', help='file template')
parser_generate.add_argument('-t', '--template', choices=file_template_list(), default=DEFAULT_TEMPLATE, help='file template')
parser_generate.add_argument('-f', '--filename', help='spec filename (optional)')
# TODO (toabctl): remove this is a later release
parser_generate.add_argument(
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ classifiers = [
]
dependencies = [
"Jinja2",
"distro",
"libarchive-c",
"backports.entry_points_selectable",
"build",
"setuptools",
Expand All @@ -38,13 +40,20 @@ dependencies = [
"requests",
"tomli; python_version < '3.11'",
]

requires-python = ">=3.6"
dynamic = ['version']


[project.urls]
homepage = "http://github.com/openSUSE/py2pack"

[project.optional-dependencies]
service = [
"libarchive-c",
"distro",
]

[project.scripts]
py2pack = "py2pack:main"

Expand Down

0 comments on commit bdc3aec

Please sign in to comment.