diff --git a/README.md b/README.md index 76e3f41..4228ca6 100644 --- a/README.md +++ b/README.md @@ -140,9 +140,9 @@ Configuration data is stored in a TOML file. | Field | Description | Type | | -------- | -------- | -------- | -| pypi_name | package name as stored in PyPI | string | +| name | package canonical name | string | | python_name | pypi_name prepended with `python-` and alternative Python version, if `python_alt_version` is defined| string | -| pypi_version | package version string as on PyPI | string +| version | package version string | string | summary | short package summary | string | | license | license name | string | | url | project URL | string | @@ -163,8 +163,8 @@ Configuration data is stored in a TOML file. license = "MIT" archful = false summary = "A simple Python 3 library for Notion Home Monitoring" -pypi_version = "2024.3.1" -pypi_name = "aionotion" +version = "2024.3.1" +name = "aionotion" python_name = "python-aionotion" url = "https://github.com/bachya/aionotion" source = "PyPI" diff --git a/pyp2spec/conf2spec.py b/pyp2spec/conf2spec.py index af06d98..1a84811 100644 --- a/pyp2spec/conf2spec.py +++ b/pyp2spec/conf2spec.py @@ -103,11 +103,11 @@ def convert_version_to_rpm_scheme(version: str) -> str: return str(RpmVersion(version)) -def same_as_rpm(pypi_version: str) -> bool: - return pypi_version == convert_version_to_rpm_scheme(pypi_version) +def same_as_rpm(version: str) -> bool: + return version == convert_version_to_rpm_scheme(version) -def archive_basename(config: ConfigFile, pypi_version: str) -> str: +def archive_basename(config: ConfigFile, version: str) -> str: """Return the archive basename. The filename has been standardized in PEP 625, but many projects out there @@ -124,7 +124,7 @@ def archive_basename(config: ConfigFile, pypi_version: str) -> str: # Second, split paths and keep only the last part of it filename = filename.split("/")[-1] # Last, get rid of the version string and the delimiter "-" - return filename.replace("-" + pypi_version, "") + return filename.replace("-" + version, "") def is_zip(config: ConfigFile) -> bool: @@ -150,15 +150,15 @@ def source(config: ConfigFile) -> str: """ detected_source = config.get_string("source") if detected_source == "PyPI": - pypi_version = config.get_string("pypi_version") - version_str = pypi_version_or_macro(pypi_version) - basename = archive_basename(config, pypi_version) + version = config.get_string("version") + version_str = python_version_or_macro(version) + basename = archive_basename(config, version) source_macro_args = basename if is_zip(config): source_macro_args += f" {version_str} zip" else: - if version_str == pypi_version: + if version_str == version: source_macro_args += f" {version_str}" return "%{pypi_source " + source_macro_args + "}" elif detected_source == "local": @@ -167,10 +167,10 @@ def source(config: ConfigFile) -> str: raise NotImplementedError("pyp2spec can deal with `PyPI` and `local` sources") -def pypi_version_or_macro(pypi_version: str) -> str: - if same_as_rpm(pypi_version): +def python_version_or_macro(version: str) -> str: + if same_as_rpm(version): return "%{version}" - return pypi_version + return version def fill_in_template(config: ConfigFile, declarative_buildsystem: bool) -> str: @@ -181,30 +181,30 @@ def fill_in_template(config: ConfigFile, declarative_buildsystem: bool) -> str: license, license_notice = get_license_string(config) - pypi_version = config.get_string("pypi_version") + version = config.get_string("version") result = spec_template.render( additional_build_requires=list_additional_build_requires(config), archful=config.get_bool("archful"), - archive_name=archive_basename(config, pypi_version), + archive_name=archive_basename(config, version), automode=config.get_bool("automode"), compat=config.get_string("compat"), - compat_name=create_compat_name(config.get_string("pypi_name"), config.get_string("compat")), + compat_name=create_compat_name(config.get_string("name"), config.get_string("compat")), declarative_buildsystem=declarative_buildsystem, extras=",".join(config.get_list("extras")), license=license, license_notice=license_notice, mandate_license=config.get_bool("license_files_present"), - name=config.get_string("pypi_name"), + name=config.get_string("name"), python_compat_name=create_compat_name(config.get_string("python_name"), config.get_string("compat")), - pypi_version=pypi_version_or_macro(pypi_version), + pypi_version=python_version_or_macro(version), python_alt_version=config.get_string("python_alt_version"), source=source(config), summary=config.get_string("summary"), test_top_level=config.get_bool("test_top_level"), python3_pkgversion=python3_pkgversion_or_3(config), url=config.get_string("url"), - version=convert_version_to_rpm_scheme(pypi_version), + version=convert_version_to_rpm_scheme(version), ) return result diff --git a/pyp2spec/pyp2conf.py b/pyp2spec/pyp2conf.py index 826e762..eaaaeea 100644 --- a/pyp2spec/pyp2conf.py +++ b/pyp2spec/pyp2conf.py @@ -20,8 +20,8 @@ from pyp2spec.local_loaders import load_dist_data_from_dir @dataclass class PackageInfo: - pypi_name: str - pypi_version: str + name: str + version: str summary: str url: str extras: list @@ -47,8 +47,8 @@ def prepare_package_info(data: RawMetadata | dict) -> PackageInfo: if (not homepage and (homepage := data.get("package_url", ""))): project_urls["home_page"] = homepage return PackageInfo( - pypi_name=normalize_name(data.get("name", "")), - pypi_version=data.get("version", ""), + name=normalize_name(data.get("name", "")), + version=data.get("version", ""), summary=get_summary_or_placeholder(data.get("summary", "")), url=resolve_url(project_urls), extras=get_extras(data.get("provides_extra", []), data.get("requires_dist", [])), @@ -121,14 +121,14 @@ def create_config_contents( pkg_info = create_package_from_source(package, version, compat, path, session) python_alt_version = options.get("python_alt_version") - pkg_info.python_name = prepend_name_with_python(pkg_info.pypi_name, python_alt_version) + pkg_info.python_name = prepend_name_with_python(pkg_info.name, python_alt_version) if compat is not None: inform(f"Creating a compat package for version: '{compat}'") pkg_info.compat = compat if version is None: - inform(f"No version specified, assuming the version found: '{pkg_info.pypi_version}'") + inform(f"No version specified, assuming the version found: '{pkg_info.version}'") if pkg_info.archful: caution("Package contains compiled extensions - you may need to specify additional build requirements") diff --git a/tests/test_conf2spec.py b/tests/test_conf2spec.py index f3c2cf2..962c6bb 100644 --- a/tests/test_conf2spec.py +++ b/tests/test_conf2spec.py @@ -73,15 +73,15 @@ def test_default_generated_specfile(file_regression, config_dir, conf, db): @pytest.mark.parametrize( - ("pypi_version", "rpm_version"), [ + ("version", "rpm_version"), [ ("1.1.0", "1.1.0"), ("1!0.2.13", "1:0.2.13"), ("0.0.2-beta1", "0.0.2~b1"), ("0.5.40-0", "0.5.40^post0"), ] ) -def test_pypi_version_is_converted_to_rpm(pypi_version, rpm_version): - assert conf2spec.convert_version_to_rpm_scheme(pypi_version) == rpm_version +def test_version_is_converted_to_rpm(version, rpm_version): + assert conf2spec.convert_version_to_rpm_scheme(version) == rpm_version @pytest.mark.parametrize( @@ -144,7 +144,7 @@ def test_license_strings(): ] ) def test_source_pypi(version, extension, expected): - fake_config_data = {"pypi_name": "foo", "archive_name": f"foo-{version}.{extension}", "pypi_version": version, "source": "PyPI"} + fake_config_data = {"pypi_name": "foo", "archive_name": f"foo-{version}.{extension}", "version": version, "source": "PyPI"} fake_config = conf2spec.ConfigFile(fake_config_data) assert conf2spec.source(fake_config) == expected @@ -169,5 +169,5 @@ def test_source_local(archive_name, expected): ("0.0.2-beta1", "0.0.2-beta1"), ] ) -def test_pypi_version_or_macro(version, expected): - assert conf2spec.pypi_version_or_macro(version) == expected +def test_python_version_or_macro(version, expected): + assert conf2spec.python_version_or_macro(version) == expected diff --git a/tests/test_configs/customized_aionotion.conf b/tests/test_configs/customized_aionotion.conf index 973ec65..dbbe79e 100644 --- a/tests/test_configs/customized_aionotion.conf +++ b/tests/test_configs/customized_aionotion.conf @@ -1,5 +1,5 @@ -pypi_name = "aionotion" -pypi_version = "2.0.3" +name = "aionotion" +version = "2.0.3" python_name = "python-aionotion" summary = "A simple Python 3 library for Notion Home Monitoring" license = "MIT" diff --git a/tests/test_configs/customized_markdown-it-py.conf b/tests/test_configs/customized_markdown-it-py.conf index 9202cfb..8647b89 100644 --- a/tests/test_configs/customized_markdown-it-py.conf +++ b/tests/test_configs/customized_markdown-it-py.conf @@ -1,5 +1,5 @@ -pypi_name = "markdown-it-py" -pypi_version = "1.1.0" +name = "markdown-it-py" +version = "1.1.0" python_name = "python-markdown-it-py" summary = "Python port of markdown-it" license = "MIT" diff --git a/tests/test_configs/customized_python-sphinx.conf b/tests/test_configs/customized_python-sphinx.conf index 6293159..70ecbb9 100644 --- a/tests/test_configs/customized_python-sphinx.conf +++ b/tests/test_configs/customized_python-sphinx.conf @@ -1,6 +1,6 @@ summary = "Python documentation generator" -pypi_version = "8.1.3" -pypi_name = "sphinx" +version = "8.1.3" +name = "sphinx" python_name = "python-sphinx" url = "https://www.sphinx-doc.org/" source = "PyPI" diff --git a/tests/test_configs/default_python-aionotion.conf b/tests/test_configs/default_python-aionotion.conf index 9b87898..d1e46e5 100644 --- a/tests/test_configs/default_python-aionotion.conf +++ b/tests/test_configs/default_python-aionotion.conf @@ -1,7 +1,7 @@ summary = "A simple Python 3 library for Notion Home Monitoring" license = "MIT" -pypi_name = "aionotion" -pypi_version = "2.0.3" +name = "aionotion" +version = "2.0.3" python_name = "python-aionotion" url = "https://github.com/bachya/aionotion" source = "PyPI" diff --git a/tests/test_configs/default_python-click.conf b/tests/test_configs/default_python-click.conf index 2929701..e7c1a11 100644 --- a/tests/test_configs/default_python-click.conf +++ b/tests/test_configs/default_python-click.conf @@ -1,7 +1,7 @@ summary = "Composable command line interface toolkit" license = "BSD-3-Clause" -pypi_name = "click" -pypi_version = "8.1.7" +name = "click" +version = "8.1.7" python_name = "python-click" url = "https://github.com/pallets/click/" source = "PyPI" diff --git a/tests/test_configs/default_python-local-test.conf b/tests/test_configs/default_python-local-test.conf index 934d21d..4355768 100644 --- a/tests/test_configs/default_python-local-test.conf +++ b/tests/test_configs/default_python-local-test.conf @@ -5,8 +5,8 @@ extras = [ ] license = "MIT AND MIT-0" license_files_present = true -pypi_name = "local-test" -pypi_version = "0.12.2" +name = "local-test" +version = "0.12.2" python_name = "python-local-test" source = "local" summary = "Test package" diff --git a/tests/test_configs/default_python-numpy.conf b/tests/test_configs/default_python-numpy.conf index a702105..6bdbfe4 100644 --- a/tests/test_configs/default_python-numpy.conf +++ b/tests/test_configs/default_python-numpy.conf @@ -1,8 +1,8 @@ archful = true summary = "Fundamental package for array computing in Python" -pypi_version = "1.25.2" +version = "1.25.2" license = "BSD-3-Clause" -pypi_name = "numpy" +name = "numpy" python_name = "python-numpy" url = "https://github.com/numpy/numpy" source = "PyPI" diff --git a/tests/test_configs/default_python-pello.conf b/tests/test_configs/default_python-pello.conf index e9e428e..3288a3b 100644 --- a/tests/test_configs/default_python-pello.conf +++ b/tests/test_configs/default_python-pello.conf @@ -5,8 +5,8 @@ extras = [ ] license = "MIT-0" license_files_present = true -pypi_name = "pello" -pypi_version = "1.0.4" +name = "pello" +version = "1.0.4" python_name = "python-pello" source = "PyPI" summary = "An example Python Hello World package" diff --git a/tests/test_configs/default_python-pytest7.2.conf b/tests/test_configs/default_python-pytest7.2.conf index 361d325..a75ce65 100644 --- a/tests/test_configs/default_python-pytest7.2.conf +++ b/tests/test_configs/default_python-pytest7.2.conf @@ -6,8 +6,8 @@ extras = [ ] license = "MIT" license_files_present = true -pypi_name = "pytest" -pypi_version = "7.2.1" +name = "pytest" +version = "7.2.1" python_name = "python-pytest" source = "PyPI" summary = "pytest: simple powerful testing with Python" diff --git a/tests/test_configs/default_python-pytest7.conf b/tests/test_configs/default_python-pytest7.conf index e132d42..fd96ed1 100644 --- a/tests/test_configs/default_python-pytest7.conf +++ b/tests/test_configs/default_python-pytest7.conf @@ -6,8 +6,8 @@ extras = [ ] license = "MIT" license_files_present = true -pypi_name = "pytest" -pypi_version = "7.4.4" +name = "pytest" +version = "7.4.4" python_name = "python-pytest" source = "PyPI" summary = "pytest: simple powerful testing with Python" diff --git a/tests/test_configs/default_python-urllib3_2.conf b/tests/test_configs/default_python-urllib3_2.conf index 6822e24..9848bc3 100644 --- a/tests/test_configs/default_python-urllib3_2.conf +++ b/tests/test_configs/default_python-urllib3_2.conf @@ -9,8 +9,8 @@ extras = [ ] license = "MIT" license_files_present = true -pypi_name = "urllib3" -pypi_version = "2.3.0" +name = "urllib3" +version = "2.3.0" python_name = "python-urllib3" source = "PyPI" summary = "HTTP library with thread-safe connection pooling, file post, and more." diff --git a/tests/test_configs/default_python3.9-pello.conf b/tests/test_configs/default_python3.9-pello.conf index 6ab62ca..5a425dc 100644 --- a/tests/test_configs/default_python3.9-pello.conf +++ b/tests/test_configs/default_python3.9-pello.conf @@ -1,9 +1,9 @@ python_alt_version = "3.9" archful = false summary = "An example Python Hello World package" -pypi_version = "1.0.4" +version = "1.0.4" license = "MIT-0" -pypi_name = "pello" +name = "pello" python_name = "python3.9-pello" url = "https://github.com/fedora-python/Pello" source = "PyPI" diff --git a/tests/test_pyp2conf.py b/tests/test_pyp2conf.py index beb97c2..a8fff2c 100644 --- a/tests/test_pyp2conf.py +++ b/tests/test_pyp2conf.py @@ -208,12 +208,12 @@ def test_summary_is_generated_if_upstream_data_is_multiline(): assert pkg.summary == "..." -def test_capitalized_underscored_pypi_name_is_normalized(): +def test_capitalized_underscored_name_is_normalized(): fake_pkg_data = { "name": "Awesome_TestPkg", } pkg = prepare_package_info(fake_pkg_data) - assert pkg.pypi_name == "awesome-testpkg" + assert pkg.name == "awesome-testpkg" @pytest.mark.parametrize( @@ -247,12 +247,12 @@ def test_prepare_package_info_pypi_source(): "maintainer": "John Doe", }, "releases": [],} result = prepare_package_info(data["info"]) - assert result.pypi_name == "example" + assert result.name == "example" assert result.summary == "A sample project" assert result.license_files_present is True assert result.license == "MIT" assert result.extras == [] - assert result.pypi_version == "1.0.0" + assert result.version == "1.0.0" assert result.url == "https://example.com" @@ -270,12 +270,12 @@ def test_prepare_package_info_core_metadata(): "metadata_version": "2.1", } result = prepare_package_info(data) - assert result.pypi_name == "example" + assert result.name == "example" assert result.summary == "A sample project" assert result.license_files_present is True assert result.license == "MIT" assert result.extras == [] - assert result.pypi_version == "1.0.0" + assert result.version == "1.0.0" assert result.url == "https://example.com" @@ -284,12 +284,12 @@ def test_prepare_package_info_missing_keys(): "name": "foo", } result = prepare_package_info(data) - assert result.pypi_name == "foo" + assert result.name == "foo" assert result.summary == "..." assert result.license_files_present is False assert result.license is None assert result.extras == [] - assert result.pypi_version == "" + assert result.version == "" assert result.url == "..." @@ -299,12 +299,12 @@ def test_prepare_package_info_only_package_url(): "package_url": "https://example.com", } result = prepare_package_info(data) - assert result.pypi_name == "foo" + assert result.name == "foo" assert result.summary == "..." assert result.license_files_present is False assert result.license is None assert result.extras == [] - assert result.pypi_version == "" + assert result.version == "" assert result.url == "https://example.com" @@ -314,12 +314,12 @@ def test_prepare_package_info_only_project_url(): "project_url": "https://example.com", } result = prepare_package_info(data) - assert result.pypi_name == "foo" + assert result.name == "foo" assert result.summary == "..." assert result.license_files_present is False assert result.license is None assert result.extras == [] - assert result.pypi_version == "" + assert result.version == "" assert result.url == "https://example.com" @@ -331,12 +331,12 @@ def test_prepare_package_info_project_urls_precedence(): "project_urls": {"Homepage": "https://example3.com"}, } result = prepare_package_info(data) - assert result.pypi_name == "foo" + assert result.name == "foo" assert result.summary == "..." assert result.license_files_present is False assert result.license is None assert result.extras == [] - assert result.pypi_version == "" + assert result.version == "" assert result.url == "https://example3.com" @@ -348,12 +348,12 @@ def test_prepare_package_info_home_page_precedence(): "home_page": "https://example3.com", } result = prepare_package_info(data) - assert result.pypi_name == "foo" + assert result.name == "foo" assert result.summary == "..." assert result.license_files_present is False assert result.license is None assert result.extras == [] - assert result.pypi_version == "" + assert result.version == "" assert result.url == "https://example3.com" @@ -364,12 +364,12 @@ def test_prepare_package_info_project_url_precedence(): "package_url": "https://example2.com", } result = prepare_package_info(data) - assert result.pypi_name == "foo" + assert result.name == "foo" assert result.summary == "..." assert result.license_files_present is False assert result.license is None assert result.extras == [] - assert result.pypi_version == "" + assert result.version == "" assert result.url == "https://example1.com" @@ -382,12 +382,12 @@ def test_prepare_package_info_project_url_precedence_with_nulls(): "package_url": "https://example1.com", } result = prepare_package_info(data) - assert result.pypi_name == "foo" + assert result.name == "foo" assert result.summary == "..." assert result.license_files_present is False assert result.license is None assert result.extras == [] - assert result.pypi_version == "" + assert result.version == "" assert result.url == "https://example1.com" @@ -448,12 +448,12 @@ def test_gather_package_info_core_metadata(): "filename": "example-7.0-cp34-abi3-manylinux1_x86_64.whl" }]} result = gather_package_info(data, pypi) - assert result.pypi_name == "example" + assert result.name == "example" assert result.summary == "A sample project" assert result.license_files_present is True assert result.license == "MIT" assert result.extras == [] - assert result.pypi_version == "1.0.0" + assert result.version == "1.0.0" assert result.url == "https://example.com" @@ -497,8 +497,8 @@ def test_create_package_from_pypi(): def test_create_package_from_dir(): pkg = create_package_from_dir("local_test", "tests/local/") - assert pkg.pypi_name == "local-test" - assert pkg.pypi_version == "0.12.2" + assert pkg.name == "local-test" + assert pkg.version == "0.12.2" assert pkg.source == "local" assert pkg.archful is False assert pkg.archive_name.split("/")[-1] == "local_test-0.12.2.tar.gz"