From 70fa5f14aa30320b23a3855c1ea92bcc857724f0 Mon Sep 17 00:00:00 2001 From: Victor Rodriguez Date: Fri, 12 Oct 2018 21:05:20 +0000 Subject: [PATCH] Add support for subdir option for setup tools Since there are some python packages that dont have their setup.py in the root of the tarball, this patch helps to fix this issue in build and install section Signed-off-by: Victor Rodriguez --- autospec/specfiles.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/autospec/specfiles.py b/autospec/specfiles.py index f924bb8..cbffe25 100644 --- a/autospec/specfiles.py +++ b/autospec/specfiles.py @@ -975,6 +975,8 @@ class Specfile(object): self.write_prep() self.write_lang_c(export_epoch=True) self.write_variables() + if self.subdir: + self._write_strip("pushd " + self.subdir) self._write_strip("python2 setup.py build -b py2 " + config.extra_configure) self._write_strip("\n") if self.tests_config and not config.config_opts['skip_tests']: @@ -982,6 +984,8 @@ class Specfile(object): # Prevent setuptools from hitting the internet self.write_proxy_exports() self._write_strip(self.tests_config) + if self.subdir: + self._write_strip("popd") self._write_strip("%install") self._write_strip("rm -rf %{buildroot}") self.write_install_prepend() @@ -992,7 +996,11 @@ class Specfile(object): file2 = file.replace("/", "_") self._write_strip("cp " + file + " %{buildroot}/usr/share/package-licenses/" + self.name + "/" + file2 + "\n") + if self.subdir: + self._write_strip("pushd " + self.subdir) self._write_strip("python2 -tt setup.py build -b py2 install --root=%{buildroot}") + if self.subdir: + self._write_strip("popd") self.write_find_lang() def write_distutils3_pattern(self): @@ -1000,6 +1008,8 @@ class Specfile(object): self.write_prep() self.write_lang_c(export_epoch=True) self.write_variables() + if self.subdir: + self._write_strip("pushd " + self.subdir) self._write_strip("python3 setup.py build " + config.extra_configure) self._write_strip("\n") if self.tests_config and not config.config_opts['skip_tests']: @@ -1007,6 +1017,8 @@ class Specfile(object): # Prevent setuptools from hitting the internet self.write_proxy_exports() self._write_strip(self.tests_config) + if self.subdir: + self._write_strip("popd") self._write_strip("%install") self._write_strip("rm -rf %{buildroot}") self.write_install_prepend() @@ -1016,8 +1028,11 @@ class Specfile(object): for file in self.license_files: file2 = file.replace("/", "_") self._write_strip("cp " + file + " %{buildroot}/usr/share/package-licenses/" + self.name + "/" + file2 + "\n") - + if self.subdir: + self._write_strip("pushd " + self.subdir) self._write_strip("python3 -tt setup.py build install --root=%{buildroot}") + if self.subdir: + self._write_strip("popd") self._write_strip("echo ----[ mark ]----") self._write_strip("cat %{buildroot}/usr/lib/python3*/site-packages/*/requires.txt || :") self._write_strip("echo ----[ mark ]----") @@ -1028,6 +1043,8 @@ class Specfile(object): self.write_prep() self.write_lang_c(export_epoch=True) self.write_variables() + if self.subdir: + self._write_strip("pushd " + self.subdir) self._write_strip("python2 setup.py build -b py2 " + config.extra_configure) self._write_strip("python3 setup.py build -b py3 " + config.extra_configure) self._write_strip("\n") @@ -1036,7 +1053,8 @@ class Specfile(object): # Prevent setuptools from hitting the internet self.write_proxy_exports() self._write_strip(self.tests_config) - + if self.subdir: + self._write_strip("popd") self._write_strip("%install") self._write_strip("export SOURCE_DATE_EPOCH={}".format(int(time.time()))) self._write_strip("rm -rf %{buildroot}") @@ -1048,8 +1066,12 @@ class Specfile(object): file2 = file.replace("/", "_") self._write_strip("cp " + file + " %{buildroot}/usr/share/package-licenses/" + self.name + "/" + file2 + "\n") + if self.subdir: + self._write_strip("pushd " + self.subdir) self._write_strip("python2 -tt setup.py build -b py2 install --root=%{buildroot} --force") self._write_strip("python3 -tt setup.py build -b py3 install --root=%{buildroot} --force") + if self.subdir: + self._write_strip("popd") self._write_strip("echo ----[ mark ]----") self._write_strip("cat %{buildroot}/usr/lib/python3*/site-packages/*/requires.txt || :") self._write_strip("echo ----[ mark ]----")