mirror of
https://github.com/danieldemus/pyp2spec.git
synced 2026-07-27 21:00:37 +02:00
Move to rpmautospec macros for changelog and release
rpmautospec has been present in Fedora since F35 and it's currently a recommended way of handling the changelog and release specfile entries: https://fedoraproject.org/wiki/Changes/rpmautospec
This commit is contained in:
committed by
Karolina Surma
parent
238faa40d6
commit
ebd1b81075
@@ -2,6 +2,8 @@
|
||||
|
||||
# Unreleased
|
||||
### Changed
|
||||
- rpmautospec macros (`%autochangelog` and `%autorelease`) are now used to populate the respective
|
||||
fields in the generated specfile. The CLI options for defining custom values have been removed
|
||||
- Convert the Python classifiers to Fedora SPDX expressions (where possible, based on [PEP 639](https://peps.python.org/pep-0639/))
|
||||
- When `--fedora-compliant` option is set, a check of the converted license expressions is performed
|
||||
to determine whether the license is allowed in Fedora. Data is provided by the [Fedora Legal team](https://gitlab.com/fedora/legal/fedora-license-data/)
|
||||
|
||||
@@ -149,8 +149,6 @@ def fill_in_template(config):
|
||||
archful=config.get_bool("archful"),
|
||||
archive_name=config.get_string("archive_name"),
|
||||
binary_files=config.get_list("binary_files"),
|
||||
changelog_head=config.get_string("changelog_head"),
|
||||
changelog_msg=config.get_string("changelog_msg"),
|
||||
description=wrap_description(config),
|
||||
doc_files=" ".join(config.get_list("doc_files")),
|
||||
extra_build_requires=generate_extra_build_requires(config),
|
||||
@@ -160,7 +158,6 @@ def fill_in_template(config):
|
||||
name=config.get_string("pypi_name"),
|
||||
python_name=config.get_string("python_name"),
|
||||
pypi_version=config.get_string("pypi_version"),
|
||||
release=config.get_string("release"),
|
||||
source=config.get_string("source"),
|
||||
summary=config.get_string("summary"),
|
||||
test_method=generate_check(config),
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from datetime import date
|
||||
from functools import wraps
|
||||
from subprocess import check_output
|
||||
import re
|
||||
import sys
|
||||
|
||||
@@ -226,32 +224,6 @@ class PypiPackage:
|
||||
return archive_name
|
||||
|
||||
|
||||
def changelog_head(email, name, changelog_date):
|
||||
"""Return f'{date} {name} <{email}>'"""
|
||||
|
||||
# Date is set for the tests
|
||||
if not changelog_date:
|
||||
changelog_date = (date.today()).strftime("%a %b %d %Y")
|
||||
|
||||
if email or name:
|
||||
return f"{changelog_date} {name} <{email}>"
|
||||
|
||||
try:
|
||||
result = check_output(["rpmdev-packager"])
|
||||
result = result.decode().strip()
|
||||
except FileNotFoundError:
|
||||
# Set a dummy value not to fail on missing changelog data
|
||||
result = "mockbuilder"
|
||||
|
||||
return f"{changelog_date} {result}"
|
||||
|
||||
|
||||
def changelog_msg():
|
||||
"""Return a default changelog message."""
|
||||
|
||||
return "Initial package"
|
||||
|
||||
|
||||
def get_description(package):
|
||||
"""Return a default package description."""
|
||||
|
||||
@@ -286,13 +258,8 @@ def is_package_name(package):
|
||||
def create_config_contents(
|
||||
package,
|
||||
description=None,
|
||||
release=None,
|
||||
message=None,
|
||||
email=None,
|
||||
name=None,
|
||||
version=None,
|
||||
summary=None,
|
||||
date=None,
|
||||
session=None,
|
||||
license=None,
|
||||
compliant=False,
|
||||
@@ -312,12 +279,6 @@ def create_config_contents(
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
# If the arguments weren't provided via CLI,
|
||||
# get them from the stored package object data or the default values
|
||||
if message is None:
|
||||
message = changelog_msg()
|
||||
click.secho(f"Assuming changelog --message={message}", fg="yellow")
|
||||
|
||||
if description is None:
|
||||
description = get_description(package)
|
||||
click.secho(f"Assuming --description={description}", fg="yellow")
|
||||
@@ -334,10 +295,6 @@ def create_config_contents(
|
||||
license = pkg.license(check_compliance=compliant, session=session)
|
||||
click.secho(f"Assuming --license={license}", fg="yellow")
|
||||
|
||||
if release is None:
|
||||
release = "1"
|
||||
click.secho(f"Assuming --release={release}", fg="yellow")
|
||||
|
||||
if top_level:
|
||||
click.secho("Only top-level modules will be checked", fg="yellow")
|
||||
contents["test_top_level"] = True
|
||||
@@ -347,14 +304,11 @@ def create_config_contents(
|
||||
click.secho("You may need to specify manual_build_requires in the config file", fg="magenta")
|
||||
contents["archful"] = archful
|
||||
|
||||
contents["changelog_msg"] = message
|
||||
contents["changelog_head"] = changelog_head(email, name, date)
|
||||
contents["description"] = description
|
||||
contents["summary"] = summary
|
||||
contents["version"] = convert_version_to_rpm_scheme(version)
|
||||
contents["pypi_version"] = pkg.pypi_version_or_macro(version)
|
||||
contents["license"] = license
|
||||
contents["release"] = release
|
||||
contents["pypi_name"] = pkg.pypi_name
|
||||
contents["python_name"] = pkg.python_name()
|
||||
contents["url"] = pkg.project_url()
|
||||
@@ -385,10 +339,6 @@ def create_config(options):
|
||||
contents = create_config_contents(
|
||||
options["package"],
|
||||
description=options["description"],
|
||||
release=options["release"],
|
||||
message=options["message"],
|
||||
email=options["email"],
|
||||
name=options["packager"],
|
||||
version=options["version"],
|
||||
summary=options["summary"],
|
||||
license=options["license"],
|
||||
@@ -409,22 +359,6 @@ def pypconf_args(func):
|
||||
"--description", "-d",
|
||||
help="Provide description for the package",
|
||||
)
|
||||
@click.option(
|
||||
"--release", "-r",
|
||||
help="Provide Fedora release, default: 1",
|
||||
)
|
||||
@click.option(
|
||||
"--message", "-m",
|
||||
help="Provide custom changelog message for the package",
|
||||
)
|
||||
@click.option(
|
||||
"--email", "-e",
|
||||
help="Provide e-mail for changelog, default: output of `rpmdev-packager`",
|
||||
)
|
||||
@click.option(
|
||||
"--packager", "-p",
|
||||
help="Provide packager name for changelog, default: output of `rpmdev-packager`",
|
||||
)
|
||||
@click.option(
|
||||
"--version", "-v",
|
||||
help="Provide package version to query PyPI for, default: latest",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: {{python_name}}
|
||||
Version: {{version}}
|
||||
Release: {{release}}%{?dist}
|
||||
Release: %autorelease
|
||||
Summary: {{summary}}
|
||||
|
||||
# Check if the automatically generated License and its spelling is correct for Fedora
|
||||
@@ -70,5 +70,4 @@ Summary: %{summary}
|
||||
{% endif %}
|
||||
|
||||
%changelog
|
||||
* {{changelog_head}} - {{version}}-{{release}}
|
||||
- {{changelog_msg}}
|
||||
%autochangelog
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: python-click
|
||||
Version: 7.1.2
|
||||
Release: 1%{?dist}
|
||||
Release: %autorelease
|
||||
Summary: Composable command line interface toolkit
|
||||
|
||||
# Check if the automatically generated License and its spelling is correct for Fedora
|
||||
@@ -53,5 +53,4 @@ Summary: %{summary}
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Nov 03 2021 Packager <packager@maint.com> - 7.1.2-1
|
||||
- Initial package
|
||||
%autochangelog
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: python-markdown-it-py
|
||||
Version: 1.1.0
|
||||
Release: 3%{?dist}
|
||||
Release: %autorelease
|
||||
Summary: Python port of markdown-it
|
||||
|
||||
# Check if the automatically generated License and its spelling is correct for Fedora
|
||||
@@ -65,5 +65,4 @@ not test_linkify'
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Jul 23 2021 Package Maintainer <package@maintainer.com> - 1.1.0-3
|
||||
- Rebuilt
|
||||
%autochangelog
|
||||
|
||||
@@ -2,7 +2,6 @@ pypi_name = "aionotion"
|
||||
pypi_version = "%{version}"
|
||||
python_name = "python-aionotion"
|
||||
version = "2.0.3"
|
||||
release = "4"
|
||||
summary = "Python library for Notion Home Monitoring"
|
||||
license = "MIT"
|
||||
url = "https://github.com/bachya/aionotion"
|
||||
@@ -11,6 +10,4 @@ archive_name = "aionotion"
|
||||
description = '''
|
||||
A asyncio-friendly library for Notion Home Monitoring devices.
|
||||
'''
|
||||
changelog_head = "Fri Jun 04 2021 Package Manager <package@manager.com>"
|
||||
changelog_msg = "Rebuilt for Python 3.10"
|
||||
test_top_level = true
|
||||
@@ -2,7 +2,6 @@ pypi_name = "boutdata"
|
||||
pypi_version = "%{version}"
|
||||
python_name = "python-boutdata"
|
||||
version = "0.1.3"
|
||||
release = "0.2"
|
||||
summary = "Python package for collecting BOUT++ data"
|
||||
license = "LGPLv3+"
|
||||
url = "http://boutproject.github.io"
|
||||
@@ -22,6 +21,3 @@ test_method = "pytest"
|
||||
test_top_level = true
|
||||
license_files = ["LICENSE"]
|
||||
doc_files = ["README.md"]
|
||||
|
||||
changelog_head = "Fri Sep 18 2020 Package Maintainer <package@maintainer.org>"
|
||||
changelog_msg = "Initial package."
|
||||
@@ -2,7 +2,6 @@ pypi_name = "click"
|
||||
pypi_version = "%{version}"
|
||||
python_name = "python-click"
|
||||
version = "7.1.2"
|
||||
release = "6"
|
||||
summary = "Simple wrapper around optparse for powerful command line utilities"
|
||||
license = "BSD"
|
||||
url = "https://github.com/mitsuhiko/click"
|
||||
@@ -20,6 +19,3 @@ test_method = "tox"
|
||||
|
||||
license_files = ["LICENSE.rst"]
|
||||
doc_files = ["README.rst", "CHANGES.rst"]
|
||||
|
||||
changelog_head = "Wed Jun 02 2021 Package Maintainer <package@maintainer.com>"
|
||||
changelog_msg = "Rebuilt for Python 3.10"
|
||||
@@ -2,7 +2,6 @@ pypi_name = "jupyter-packaging"
|
||||
pypi_version = "%{version}"
|
||||
python_name = "python-jupyter-packaging"
|
||||
version = "0.10.4"
|
||||
release = "2"
|
||||
summary = "Tools to help build and install Jupyter Python packages"
|
||||
license = "BSD"
|
||||
url = "https://github.com/jupyter/jupyter-packaging"
|
||||
@@ -26,6 +25,3 @@ unwanted_tests = [
|
||||
|
||||
license_files = ["LICENSE"]
|
||||
doc_files = ["README.md"]
|
||||
|
||||
changelog_head = "Fri Jul 23 2021 Package Maintainer <package@maintainer.com>"
|
||||
changelog_msg = "Initial package"
|
||||
@@ -2,7 +2,6 @@ pypi_name = "markdown-it-py"
|
||||
pypi_version = "%{version}"
|
||||
python_name = "python-markdown-it-py"
|
||||
version = "1.1.0"
|
||||
release = "3"
|
||||
summary = "Python port of markdown-it"
|
||||
license = "MIT"
|
||||
url = "https://github.com/executablebooks/markdown-it-py"
|
||||
@@ -32,6 +31,3 @@ unwanted_tests = [
|
||||
license_files = ["LICENSE", "LICENSE.markdown-it"]
|
||||
doc_files = ["README.md"]
|
||||
binary_files = ["markdown-it"]
|
||||
|
||||
changelog_head = "Fri Jul 23 2021 Package Maintainer <package@maintainer.com>"
|
||||
changelog_msg = "Rebuilt"
|
||||
@@ -1,11 +1,8 @@
|
||||
archful = true
|
||||
changelog_msg = "Package generated with pyp2spec"
|
||||
changelog_head = "Wed Nov 03 2021 Packager <packager@maint.com>"
|
||||
description = "This is package 'tornado' generated automatically by pyp2spec."
|
||||
summary = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed."
|
||||
version = "6.1"
|
||||
license = "ASL"
|
||||
release = "1"
|
||||
pypi_name = "tornado"
|
||||
pypi_version = "%{version}"
|
||||
python_name = "python-tornado"
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
changelog_msg = "Initial package"
|
||||
changelog_head = "Wed Nov 03 2021 Packager <packager@maint.com>"
|
||||
description = "This is package 'aionotion' generated automatically by pyp2spec."
|
||||
summary = "A simple Python 3 library for Notion Home Monitoring"
|
||||
version = "2.0.3"
|
||||
license = "MIT"
|
||||
release = "1"
|
||||
pypi_name = "aionotion"
|
||||
pypi_version = "%{version}"
|
||||
python_name = "python-aionotion"
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
changelog_msg = "Initial package"
|
||||
changelog_head = "Wed Nov 03 2021 Packager <packager@maint.com>"
|
||||
description = "This is package 'click' generated automatically by pyp2spec."
|
||||
summary = "Composable command line interface toolkit"
|
||||
version = "7.1.2"
|
||||
license = "BSD-3-Clause"
|
||||
release = "1"
|
||||
pypi_name = "click"
|
||||
pypi_version = "%{version}"
|
||||
python_name = "python-click"
|
||||
|
||||
+2
-18
@@ -13,11 +13,6 @@ from pyp2spec.pyp2conf import PypiPackage, create_config_contents
|
||||
from pyp2spec.pyp2conf import convert_version_to_rpm_scheme
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def changelog():
|
||||
return ("Wed Nov 03 2021", "Packager", "packager@maint.com")
|
||||
|
||||
|
||||
def test_non_existent_package(betamax_session):
|
||||
with pytest.raises(SystemExit):
|
||||
PypiPackage("definitely-nonexisting-package-name", session=betamax_session)
|
||||
@@ -29,14 +24,11 @@ def test_non_existent_package(betamax_session):
|
||||
("click", "7.1.2"),
|
||||
]
|
||||
)
|
||||
def test_automatically_generated_config_is_valid(betamax_parametrized_session, changelog, package, version):
|
||||
def test_automatically_generated_config_is_valid(betamax_parametrized_session, package, version):
|
||||
"""Run the config rendering in fully automated mode and compare the results"""
|
||||
config = create_config_contents(
|
||||
package=package,
|
||||
version=version,
|
||||
date=changelog[0],
|
||||
name=changelog[1],
|
||||
email=changelog[2],
|
||||
session=betamax_parametrized_session,
|
||||
)
|
||||
|
||||
@@ -55,13 +47,8 @@ def test_config_with_customization_is_valid(betamax_session):
|
||||
config = create_config_contents(
|
||||
package=package,
|
||||
description="A asyncio-friendly library for Notion Home Monitoring devices.\n",
|
||||
release="4",
|
||||
message="Rebuilt for Python 3.10",
|
||||
email="package@manager.com",
|
||||
name="Package Manager",
|
||||
version="2.0.3",
|
||||
summary="Python library for Notion Home Monitoring",
|
||||
date="Fri Jun 04 2021",
|
||||
top_level=True,
|
||||
compliant=True,
|
||||
session=betamax_session,
|
||||
@@ -73,14 +60,11 @@ def test_config_with_customization_is_valid(betamax_session):
|
||||
assert config == loaded_contents
|
||||
|
||||
|
||||
def test_archful_package(betamax_session, changelog):
|
||||
def test_archful_package(betamax_session):
|
||||
"""Generate config for tornado which is archful"""
|
||||
package = "tornado"
|
||||
config = create_config_contents(
|
||||
package=package,
|
||||
date=changelog[0],
|
||||
name=changelog[1],
|
||||
email=changelog[2],
|
||||
top_level=True,
|
||||
license="Apache 2.0",
|
||||
archful=True,
|
||||
|
||||
Reference in New Issue
Block a user