#204 rust2rpm: split off core functionality and cargo-inspector
Merged 2 years ago by zbyszek. Opened 2 years ago by decathorpe.
Unknown source main  into  main

file modified
-1
@@ -1,4 +1,3 @@

- from .metadata import *

  from . import licensing

  

  __version__ = '21'

file modified
+2 -1
@@ -20,7 +20,8 @@

  import requests

  import tqdm

  

- from . import Metadata, cfg, licensing, generator

+ from . import cfg, licensing, generator

+ from .core.metadata import Metadata

  

  DEFAULT_EDITOR = "vi"

  XDG_CACHE_HOME = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache"))

empty or binary file added
rust2rpm/core/inspector.py rust2rpm/inspector.py
file renamed
+8 -5
@@ -1,11 +1,11 @@

  import argparse

  import glob

  import os

+ import shlex

+ import subprocess

  import sys

  

- from . import Metadata

- from .metadata import normalize_deps, Dependency

- from .__main__ import exit_on_common_errors

+ from rust2rpm.core.metadata import Metadata, Dependency

  

  

  def _get_binaries(cargo_toml):
@@ -50,7 +50,6 @@

      raise FileNotFoundError(f'Cargo.toml not found for binary {binary_or_cargo_toml}')

  

  

- @exit_on_common_errors()

  def main():

      parser = argparse.ArgumentParser()

      group = parser.add_mutually_exclusive_group(required=True)
@@ -140,4 +139,8 @@

  

  

  if __name__ == "__main__":

-     main()

+     try:

+         main()

+     except subprocess.CalledProcessError as e:

+         cmd = shlex.join(e.cmd)

+         sys.exit(f"Subcommand failed with code {e.returncode}: {cmd}")

rust2rpm/core/metadata.py rust2rpm/metadata.py
file renamed
file was moved with no change to the file
file modified
+2 -1
@@ -2,7 +2,8 @@

  

  import jinja2

  

- from . import __version__, metadata, licensing

+ from . import __version__, licensing

+ from .core import metadata

  

  def to_list(s):

      if not s:

file modified
+6 -3
@@ -16,7 +16,10 @@

      license="MIT",

      keywords="rust cargo rpm",

  

-     packages=["rust2rpm"],

+     packages=[

+         "rust2rpm",

+         "rust2rpm.core",

+     ],

      package_data={

          "rust2rpm": [

              "spdx_to_fedora.csv",
@@ -27,11 +30,11 @@

      entry_points={

          "console_scripts": [

              "rust2rpm = rust2rpm.__main__:main",

-             "cargo-inspector = rust2rpm.inspector:main",

+             "cargo-inspector = rust2rpm.core.inspector:main",

          ],

      },

      install_requires=[

-         # CLI tool

+         # rust2rpm

          "jinja2",

          "requests",

          "tqdm",

This PR splits the rust2rpm python package into two parts: rust2rpm and rust2rpm.core.
This change trims the dependency tree of cargo-inspector (and the RPM macros for Rust packaging) to only python3 and no third-party python packages.

The packaging will need to be adapted to take advantage of this, and also to ensure that

  • both rust2rpm and rust2rpm.core end up being valid, importable python packages
  • cargo-inspector and rust2rpm keep working after this package split
  • cargo-inspector works with only python3-rust2rpm-core installed (that's the whole point)

rebased onto 093eef7

2 years ago

I can make a COPR with test builds to make sure the packaging works as expected, since this is a bigger-than-usual change.

I can make a COPR with test builds to make sure the packaging works as expected

Nah, there's plenty of other changes to do. We can always test things at the end.

Pull-Request has been merged by zbyszek

2 years ago

Makes sense. Let's do some pre-release testing once v22 is almost ready.