Replace +bindir argument with +auto to include all unclassified files to
filelist.
This commit is contained in:
parent
7e5adc9c02
commit
79678f7e72
@ -6,7 +6,7 @@ License: MIT
|
|||||||
|
|
||||||
# Keep the version at zero and increment only release
|
# Keep the version at zero and increment only release
|
||||||
Version: 0
|
Version: 0
|
||||||
Release: 21%{?dist}
|
Release: 22%{?dist}
|
||||||
|
|
||||||
# Macro files
|
# Macro files
|
||||||
Source001: macros.pyproject
|
Source001: macros.pyproject
|
||||||
@ -101,6 +101,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
|||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Aug 06 2020 Tomas Hrnciar <thrnciar@redhat.com> - 0-22
|
||||||
|
- Change %%pyproject_save_files +bindir argument to +auto
|
||||||
|
to list all unclassified files in filelist
|
||||||
|
|
||||||
* Tue Aug 04 2020 Miro Hrončok <mhroncok@redhat.com> - 0-21
|
* Tue Aug 04 2020 Miro Hrončok <mhroncok@redhat.com> - 0-21
|
||||||
- Actually implement %%pyproject_extras_subpkg
|
- Actually implement %%pyproject_extras_subpkg
|
||||||
|
|
||||||
|
@ -203,10 +203,6 @@ def classify_paths(
|
|||||||
paths["metadata"]["files"].append(path)
|
paths["metadata"]["files"].append(path)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if path.parent == bindir:
|
|
||||||
paths["executables"]["files"].append(path)
|
|
||||||
continue
|
|
||||||
|
|
||||||
for sitedir in sitedirs:
|
for sitedir in sitedirs:
|
||||||
if sitedir in path.parents:
|
if sitedir in path.parents:
|
||||||
if path.parent == sitedir:
|
if path.parent == sitedir:
|
||||||
@ -236,21 +232,21 @@ def classify_paths(
|
|||||||
return paths
|
return paths
|
||||||
|
|
||||||
|
|
||||||
def generate_file_list(paths_dict, module_globs, include_executables=False):
|
def generate_file_list(paths_dict, module_globs, include_others=False):
|
||||||
"""
|
"""
|
||||||
This function takes the classified paths_dict and turns it into lines
|
This function takes the classified paths_dict and turns it into lines
|
||||||
for the %files section. Returns list with text lines, no Path objects.
|
for the %files section. Returns list with text lines, no Path objects.
|
||||||
|
|
||||||
Only includes files from modules that match module_globs, metadata and
|
Only includes files from modules that match module_globs, metadata and
|
||||||
optional executables.
|
optionaly all other files.
|
||||||
|
|
||||||
It asserts that all globs match at least one module, raises ValueError otherwise.
|
It asserts that all globs match at least one module, raises ValueError otherwise.
|
||||||
Multiple globs matching identical module(s) are OK.
|
Multiple globs matching identical module(s) are OK.
|
||||||
"""
|
"""
|
||||||
files = set()
|
files = set()
|
||||||
|
|
||||||
if include_executables:
|
if include_others:
|
||||||
files.update(f"{p}" for p in paths_dict["executables"]["files"])
|
files.update(f"{p}" for p in paths_dict["other"]["files"])
|
||||||
|
|
||||||
files.update(f"{p}" for p in paths_dict["metadata"]["files"])
|
files.update(f"{p}" for p in paths_dict["metadata"]["files"])
|
||||||
for macro in "dir", "doc", "license":
|
for macro in "dir", "doc", "license":
|
||||||
@ -286,7 +282,7 @@ def parse_varargs(varargs):
|
|||||||
|
|
||||||
Arguments starting with + are treated as a flags, everything else is a glob
|
Arguments starting with + are treated as a flags, everything else is a glob
|
||||||
|
|
||||||
Returns as set of globs, boolean flag whether to include executables from bindir
|
Returns as set of globs, boolean flag whether to include all the other files
|
||||||
|
|
||||||
Raises ValueError for unknown flags and globs with dots (namespace packages).
|
Raises ValueError for unknown flags and globs with dots (namespace packages).
|
||||||
|
|
||||||
@ -295,8 +291,8 @@ def parse_varargs(varargs):
|
|||||||
>>> parse_varargs(['*'])
|
>>> parse_varargs(['*'])
|
||||||
({'*'}, False)
|
({'*'}, False)
|
||||||
|
|
||||||
>>> mods, bindir = parse_varargs(['requests*', 'kerberos', '+bindir'])
|
>>> mods, auto = parse_varargs(['requests*', 'kerberos', '+auto'])
|
||||||
>>> bindir
|
>>> auto
|
||||||
True
|
True
|
||||||
>>> sorted(mods)
|
>>> sorted(mods)
|
||||||
['kerberos', 'requests*']
|
['kerberos', 'requests*']
|
||||||
@ -307,7 +303,7 @@ def parse_varargs(varargs):
|
|||||||
>>> sorted(mods)
|
>>> sorted(mods)
|
||||||
['tensorf*', 'tldr']
|
['tensorf*', 'tldr']
|
||||||
|
|
||||||
>>> parse_varargs(['+bindir'])
|
>>> parse_varargs(['+auto'])
|
||||||
(set(), True)
|
(set(), True)
|
||||||
|
|
||||||
Bad examples:
|
Bad examples:
|
||||||
@ -337,13 +333,13 @@ def parse_varargs(varargs):
|
|||||||
...
|
...
|
||||||
ValueError: Attempted to use a namespaced package with dot in the glob: my.bad. ...
|
ValueError: Attempted to use a namespaced package with dot in the glob: my.bad. ...
|
||||||
"""
|
"""
|
||||||
include_bindir = False
|
include_auto = False
|
||||||
globs = set()
|
globs = set()
|
||||||
|
|
||||||
for arg in varargs:
|
for arg in varargs:
|
||||||
if arg.startswith("+"):
|
if arg.startswith("+"):
|
||||||
if arg == "+bindir":
|
if arg == "+auto":
|
||||||
include_bindir = True
|
include_auto = True
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Invalid argument: {arg}")
|
raise ValueError(f"Invalid argument: {arg}")
|
||||||
elif "." in arg:
|
elif "." in arg:
|
||||||
@ -356,7 +352,7 @@ def parse_varargs(varargs):
|
|||||||
else:
|
else:
|
||||||
globs.add(arg)
|
globs.add(arg)
|
||||||
|
|
||||||
return globs, include_bindir
|
return globs, include_auto
|
||||||
|
|
||||||
|
|
||||||
def pyproject_save_files(buildroot, sitelib, sitearch, bindir, python_version, varargs):
|
def pyproject_save_files(buildroot, sitelib, sitearch, bindir, python_version, varargs):
|
||||||
@ -369,7 +365,7 @@ def pyproject_save_files(buildroot, sitelib, sitearch, bindir, python_version, v
|
|||||||
# This saves us browsing one directory twice
|
# This saves us browsing one directory twice
|
||||||
sitedirs = sorted({sitelib, sitearch})
|
sitedirs = sorted({sitelib, sitearch})
|
||||||
|
|
||||||
globs, include_bindir = parse_varargs(varargs)
|
globs, include_auto = parse_varargs(varargs)
|
||||||
record_path_real = locate_record(buildroot, sitedirs)
|
record_path_real = locate_record(buildroot, sitedirs)
|
||||||
record_path = BuildrootPath.from_real(record_path_real, root=buildroot)
|
record_path = BuildrootPath.from_real(record_path_real, root=buildroot)
|
||||||
parsed_record = parse_record(record_path, read_record(record_path_real))
|
parsed_record = parse_record(record_path, read_record(record_path_real))
|
||||||
@ -377,7 +373,7 @@ def pyproject_save_files(buildroot, sitelib, sitearch, bindir, python_version, v
|
|||||||
paths_dict = classify_paths(
|
paths_dict = classify_paths(
|
||||||
record_path, parsed_record, sitedirs, bindir, python_version
|
record_path, parsed_record, sitedirs, bindir, python_version
|
||||||
)
|
)
|
||||||
return generate_file_list(paths_dict, globs, include_bindir)
|
return generate_file_list(paths_dict, globs, include_auto)
|
||||||
|
|
||||||
|
|
||||||
def main(cli_args):
|
def main(cli_args):
|
||||||
|
Loading…
Reference in New Issue
Block a user