Compare commits

..

8 Commits

Author SHA1 Message Date
William Douglas e822d6e48d Set extractall filter for tarfile
See
https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-11-04 11:40:24 -08:00
William Douglas 9bfe801c96 Fix subdir for pyproject
When using optimized builds for pyproject patterns that also need a
subdir, the path needs to be reset before attempting to change to the
optimized directory.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-11-04 11:13:46 -08:00
K1ngfish3r 412ce5ee2e i blame isort setting(?) 2024-10-27 22:39:42 -07:00
K1ngfish3r 1fa3bdd6e0 add subdir 2024-10-27 22:39:42 -07:00
William Douglas 4ea76c998e Remove %check for setup.py test
setup.py test is gone in 3.13 and projects seem to be doing custom
things for replacements. Until wider per project detection is in
place, just remove the %check section for setup.py.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-10-27 20:28:28 -07:00
Brett T. Warden b2d28bb55a Add path to Qt6 build tools in qmake build_pattern
When using the qmake build pattern, add the path /usr/lib64/qt6/bin/
that contains qmake6 and other Qt6 build tools.
2024-10-14 15:56:05 -07:00
Brett T. Warden 4d029647d7 parse_cmake: Also match hypen in pkg_check_modules(X)
If a cmake file defines a pkgconfig dependency with a hypen in it, make
sure we can handle it:
pkg_check_modules(DBUS-1 REQUIRED dbus-1 IMPORTED_TARGET)

Previously we used \w to match the first term (DBUS-1), which does *not*
match hyphens.
2024-10-01 11:40:23 -07:00
Brett T. Warden 5279a11b53 Split packages from cmake_modules when adding them as buildreqs
When parsing cmake files for find_package dependencies, we match against
entries in cmake_modules. Many of the entries of this file list
multiple packages, separated by space. Split on whitespace so we
actually feed only individual package names to each add_buildreq call.

Otherwise, if cmake_modules provides "extra-cmake-modules png2ico", for
example, and you have "png2ico" in buildreq_ban, the specfile would still
list both extra-cmake-modules and png2ico as build dependencies, because
add_buildreq only compared exact matches.
2024-10-01 11:40:23 -07:00
5 changed files with 20 additions and 37 deletions
+8 -3
View File
@@ -508,7 +508,7 @@ class Requirements(object):
"""Scan a .cmake or CMakeLists.txt file for what's it's actually looking for."""
findpackage = re.compile(r"^[^#]*find_package\((\w+)\b.*\)", re.I)
findpackage_multiline = re.compile(r"^[^#]*find_package\((\w+)\b.*", re.I)
pkgconfig = re.compile(r"^[^#]*pkg_check_modules\s*\(\w+ (.*)\)", re.I)
pkgconfig = re.compile(r"^[^#]*pkg_check_modules\s*\([\w\-]+ (.*)\)", re.I)
pkg_search_modifiers = {'REQUIRED', 'QUIET', 'NO_CMAKE_PATH',
'NO_CMAKE_ENVIRONMENT_PATH', 'IMPORTED_TARGET'}
extractword = re.compile(r'(?:"([^"]+)"|(\S+))(.*)')
@@ -518,8 +518,13 @@ class Requirements(object):
for line in lines:
if match := findpackage.search(line):
module = match.group(1)
if pkg := cmake_modules.get(module):
self.add_buildreq(pkg)
if pkgs := cmake_modules.get(module):
# Some of the entries in cmake_modules list multiple packages, space-separated, so we need to split.
# Otherwise, anything in buildreq_ban would have to match the entire string, not just a single package name.
# For example: Png2Ico, extra-cmake-modules png2ico
# buildreq_ban would have to contain "extra-cmake-modules png2ico" to match, instead of just "png2ico"
for pkg in pkgs.split():
self.add_buildreq(pkg)
elif findpackage_multiline.search(line):
self.findpackage_parse_lines(line, lines, cmake_modules)
-10
View File
@@ -80,19 +80,16 @@ def scan_for_tests(src_dir, config, requirements, content):
"{} test || :\nmodule unload openmpi".format(make_command)
perl_check = "{} TEST_VERBOSE=1 test".format(make_command)
setup_check = """PYTHONPATH=%{buildroot}$(python -c "import sys; print(sys.path[-1])") python setup.py test"""
meson_check = "meson test -C builddir --print-errorlogs"
if config.config_opts.get('allow_test_failures'):
make_check += " || :"
cmake_check += " || :"
perl_check += " || :"
setup_check += " || :"
meson_check += " || :"
testsuites = {
"makecheck": make_check,
"perlcheck": perl_check,
"setup.py": setup_check,
"cmake": "cd clr-build; " + cmake_check,
"meson": meson_check,
}
@@ -145,13 +142,6 @@ def scan_for_tests(src_dir, config, requirements, content):
elif config.default_pattern in ["cpan"] and "Makefile.PL" in files:
tests_config = testsuites["perlcheck"]
elif config.default_pattern == "distutils3" and "setup.py" in files:
with util.open_auto(os.path.join(src_dir, "setup.py"), 'r') as setup_fp:
setup_contents = setup_fp.read()
if "test_suite" in setup_contents or "pbr=True" in setup_contents:
tests_config = testsuites["setup.py"]
elif config.default_pattern == "R":
tests_config = "export _R_CHECK_FORCE_SUGGESTS_=false\n" \
"R CMD check --no-manual --no-examples --no-codoc . " \
+10 -2
View File
@@ -1345,6 +1345,8 @@ class Specfile(object):
self.write_lang_c(export_epoch=True)
self.write_variables()
self.write_profile_payload("autogen")
if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)
self._write_strip("export GOAMD64=v2")
self._write_strip("{0}%autogen {1} {2} {3}"
.format(self.get_profile_use_flags(),
@@ -1353,6 +1355,8 @@ class Specfile(object):
self.config.extra_configure64))
self.write_make_line()
self._write_strip("\n")
if self.config.subdir:
self._write_strip("popd")
if self.config.config_opts['32bit']:
self._write_strip("pushd ../build32/" + self.config.subdir)
self.write_build_prepend()
@@ -1430,6 +1434,9 @@ class Specfile(object):
for module in self.config.pypi_overrides:
self._write_strip(f"pypi-dep-fix.py . {module}")
self._write_strip("python3 -m build --wheel --skip-dependency-check --no-isolation " + self.config.extra_configure)
self._write_strip("\n")
if self.config.subdir:
self._write_strip("popd")
if self.config.config_opts['use_avx2']:
self._write_strip("pushd ../buildavx2/" + self.config.subdir)
@@ -1460,8 +1467,6 @@ class Specfile(object):
self._write_strip("popd")
self._write_strip("\n")
if self.config.subdir:
self._write_strip("popd")
self.write_build_append()
self.write_check()
self._write_strip("%install")
@@ -1825,6 +1830,9 @@ class Specfile(object):
self._write_strip('export QMAKE_CFLAGS_RELEASE=')
self._write_strip('export QMAKE_CXXFLAGS_RELEASE=')
# Add the qt6base tools to the path
self._write_strip('export PATH=/usr/lib64/qt6/bin:$PATH')
if self.config.make_command:
qmake = self.config.make_command
else:
+2 -2
View File
@@ -125,7 +125,7 @@ class Source():
def extract_tar(self, extraction_path):
"""Extract tar in path."""
with tarfile.open(self.path) as content:
content.extractall(path=extraction_path)
content.extractall(path=extraction_path, filter='data')
def extract_bz2(self, extraction_path):
"""Extract plain bz2 file in path."""
@@ -144,7 +144,7 @@ class Source():
def extract_zst(self, extraction_path):
"""Extract zst in path."""
with tarfile.open(fileobj=zstd.open(self.path, 'rb'), mode='r|') as content:
content.extractall(path=extraction_path)
content.extractall(path=extraction_path, filter='data')
def convert_version(ver_str, name):
-20
View File
@@ -152,26 +152,6 @@ class TestTest(unittest.TestCase):
check.os.listdir = listdir_backup
self.assertEqual(check.tests_config, 'make TEST_VERBOSE=1 test')
def test_scan_for_tests_setup(self):
"""
Test scan_for_tests with setup.py suite
"""
reqs = buildreq.Requirements("")
conf = config.Config("")
tcontent = tarball.Content("", "", "", [], conf, "")
listdir_backup = os.listdir
check.os.listdir = mock_generator(['setup.py'])
content = 'test_suite'
m_open = mock_open(read_data=content)
with patch(self.open_name, m_open, create=True):
conf.default_pattern = "distutils3"
check.scan_for_tests('pkgdir', conf, reqs, tcontent)
check.os.listdir = listdir_backup
self.assertEqual(check.tests_config,
'PYTHONPATH=%{buildroot}$(python -c "import sys; print(sys.path[-1])") '
'python setup.py test')
def test_scan_for_tests_cmake(self):
"""
Test scan_for_tests with cmake suite