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 <victor.rodriguez.bahena@intel.com>
This commit is contained in:
Victor Rodriguez
2018-10-12 21:05:20 +00:00
committed by William Douglas
parent a1dfe80fb3
commit 70fa5f14aa
+24 -2
View File
@@ -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 ]----")