#50 Add prefix option to pythodistdeps.py
Closed 10 months ago by churchyard. Opened 11 months ago by smani.
Unknown source rawhide  into  rawhide

file modified
+13 -10
@@ -326,6 +326,7 @@

      parser.add_argument('--require-extras-subpackages', action='store_true',

                          help="If there is a dependency on a package with extras functionality, require the extras subpackage")

      parser.add_argument('--package-name', action='store', help="Name of the RPM package that's being inspected. Required for extras requires/provides to work.")

+     parser.add_argument('--namespace', action='store', help="Namespace for the printed Requires, Provides, Recommends and Conflicts")

      parser.add_argument('files', nargs=argparse.REMAINDER, help="Files from the RPM package that are to be inspected, can also be supplied on stdin")

      args = parser.parse_args()

  
@@ -374,6 +375,8 @@

          package_name_parts = args.package_name.rpartition('+')

          extras_subpackage = package_name_parts[2].lower() or None

  

+     namespace = (args.namespace + "({})") if args.namespace else "{}"

+ 

      for f in (args.files or stdin.readlines()):

          f = f.strip()

          lower = f.lower()
@@ -430,31 +433,31 @@

                  extras_suffix = f"[{extras_subpackage}]" if extras_subpackage else ""

                  # If egg/dist metadata says package name is python, we provide python(abi)

                  if dist.normalized_name == 'python':

-                     name = 'python(abi)'

+                     name = namespace.format('python(abi)')

                      if name not in py_deps:

                          py_deps[name] = []

                      py_deps[name].append(('==', dist.py_version))

                  if not args.legacy or not args.majorver_only:

                      if normalized_names_provide_legacy:

-                         name = 'python{}dist({}{})'.format(dist.py_version, dist.legacy_normalized_name, extras_suffix)

+                         name = namespace.format('python{}dist({}{})').format(dist.py_version, dist.legacy_normalized_name, extras_suffix)

                          if name not in py_deps:

                              py_deps[name] = []

                      if normalized_names_provide_pep503:

-                         name_ = 'python{}dist({}{})'.format(dist.py_version, dist.normalized_name, extras_suffix)

+                         name_ = namespace.format('python{}dist({}{})').format(dist.py_version, dist.normalized_name, extras_suffix)

                          if name_ not in py_deps:

                              py_deps[name_] = []

                  if args.majorver_provides or args.majorver_only or \

                          (args.majorver_provides_versions and dist.py_version in args.majorver_provides_versions):

                      if normalized_names_provide_legacy:

-                         pymajor_name = 'python{}dist({}{})'.format(pyver_major, dist.legacy_normalized_name, extras_suffix)

+                         pymajor_name = namespace.format('python{}dist({}{})').format(pyver_major, dist.legacy_normalized_name, extras_suffix)

                          if pymajor_name not in py_deps:

                              py_deps[pymajor_name] = []

                      if normalized_names_provide_pep503:

-                         pymajor_name_ = 'python{}dist({}{})'.format(pyver_major, dist.normalized_name, extras_suffix)

+                         pymajor_name_ = namespace.format('python{}dist({}{})').format(pyver_major, dist.normalized_name, extras_suffix)

                          if pymajor_name_ not in py_deps:

                              py_deps[pymajor_name_] = []

                  if args.legacy or args.legacy_provides:

-                     legacy_name = 'pythonegg({})({})'.format(pyver_major, dist.legacy_normalized_name)

+                     legacy_name = namespace.format('pythonegg({})({})').format(pyver_major, dist.legacy_normalized_name)

                      if legacy_name not in py_deps:

                          py_deps[legacy_name] = []

                  if dist.version:
@@ -477,7 +480,7 @@

                          if spec not in py_deps[legacy_name]:

                              py_deps[legacy_name].append(spec)

              if args.requires or (args.recommends and dist.extras):

-                 name = 'python(abi)'

+                 name = namespace.format('python(abi)')

                  # If egg/dist metadata says package name is python, we don't add dependency on python(abi)

                  if dist.normalized_name == 'python':

                      py_abi = False
@@ -524,12 +527,12 @@

                              dep_normalized_name = dep.legacy_normalized_name

  

                          if args.legacy:

-                             name = 'pythonegg({})({})'.format(pyver_major, dep.legacy_normalized_name)

+                             name = namespace.format('pythonegg({})({})').format(pyver_major, dep.legacy_normalized_name)

                          else:

                              if args.majorver_only:

-                                 name = 'python{}dist({}{})'.format(pyver_major, dep_normalized_name, extras_suffix)

+                                 name = namespace.format('python{}dist({}{})').format(pyver_major, dep_normalized_name, extras_suffix)

                              else:

-                                 name = 'python{}dist({}{})'.format(dist.py_version, dep_normalized_name, extras_suffix)

+                                 name = namespace.format('python{}dist({}{})').format(dist.py_version, dep_normalized_name, extras_suffix)

  

                          if dep.marker and not args.recommends and not extras_subpackage:

                              if not dep.marker.evaluate(get_marker_env(dist, '')):

I'd like to use pythondistdeps.py to autogenerate requires/provides for mingw-python-packages via i.e.

%__mingw32_python3_provides %{_rpmconfigdir}/pythondistdeps.py --provides --normalized-names-format pep503 --package-name %{name} --normalized-names-provide-both --majorver-provides-versions %{mingw32_python3_version} | sed -e 's|^|mingw32_|g'
%__mingw32_python3_requires %{mingw32_python3} %{_rpmconfigdir}/pythondistdeps.py --requires --normalized-names-format pep503 --package-name %{name} %{?!_python_no_extras_requires:--require-extras-subpackages} --console-scripts-nodep-setuptools-since %{mingw32_python3_version} --prefix=mingw32_
%__mingw32_python3_path     ^%{mingw32_python3_sitearch}/[^/]+\.(dist-info|egg-info|egg-link)$

Not particularly urgent, it would be nice to have to automatically catch some broken dependencies due to missing/unpackaged requirements.

Btw, instead of prefix, an alternative would be something like --namespace which would wrap the generated name in <namespace>(<name>), i.e.

mingw32(python(abi)) == 3.10

rather than

mingw32_python(abi) == 3.10

which would be more consistent with the current mingw reqs/provs. If that would work, I'd update the PR accordingly.

Build succeeded.

1 new commit added

  • Support namespace rathen than prefix
11 months ago

Build succeeded.

I am not that keen on mixing %-formating with .format() in a single statement.

1 new commit added

  • Avoid mixing % and format in same statement
11 months ago

Changed to use format only.

Thanks.

I'll wait for https://src.fedoraproject.org/rpms/python-rpm-generators/pull-request/48 before shipping this.

Do you have a copr repo where we could test this together with %__mingw32_python3_provides etc.?

Build succeeded.

I'd appreciate if you could do it, thanks

Hi @churchyard, would it be possible to move ahead with this as I'd like to do some more mingw work soon?

Pull-Request has been closed by churchyard

10 months ago
Metadata