All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libselinux: set CFLAGS for pip installation
@ 2023-04-20 16:27 Christian Göttsche
  2023-04-26 15:01 ` Petr Lautrbach
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Göttsche @ 2023-04-20 16:27 UTC (permalink / raw)
  To: selinux

Explicitly set CFLAGS for the pip install command, similar to calling
setup.py, to ignore known compiler warnings treated as errors, e.g.:

    selinuxswig_python_wrap.c:3593:19: error: 'sidget' is deprecated [-Werror,-Wdeprecated-declarations]
                result = (int)sidget(arg1);
                              ^
    selinuxswig_python_wrap.c:15024:1: error: no previous prototype for function 'PyInit__selinux' [-Werror,-Wmissing-prototypes]
            SWIG_init(void) {
            ^

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
fixes GitHub CI, see https://github.com/SELinuxProject/selinux/pull/388
---
 libselinux/src/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 36d57122..f9a1e5f5 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -187,7 +187,7 @@ install: all
 	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
 
 install-pywrap: pywrap
-	$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
+	CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
 	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
 	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
 
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libselinux: set CFLAGS for pip installation
  2023-04-20 16:27 [PATCH] libselinux: set CFLAGS for pip installation Christian Göttsche
@ 2023-04-26 15:01 ` Petr Lautrbach
  2023-04-26 15:53   ` Petr Lautrbach
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Lautrbach @ 2023-04-26 15:01 UTC (permalink / raw)
  To: Christian Göttsche, selinux

Christian Göttsche <cgzones@googlemail.com> writes:

> Explicitly set CFLAGS for the pip install command, similar to calling
> setup.py, to ignore known compiler warnings treated as errors, e.g.:
>
>     selinuxswig_python_wrap.c:3593:19: error: 'sidget' is deprecated [-Werror,-Wdeprecated-declarations]
>                 result = (int)sidget(arg1);
>                               ^
>     selinuxswig_python_wrap.c:15024:1: error: no previous prototype for function 'PyInit__selinux' [-Werror,-Wmissing-prototypes]
>             SWIG_init(void) {
>             ^
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>


It looks like a problem in build system - selinuxswig_python_wrap.o is
built twice, first time by

pywrap: all selinuxswig_python_exception.i
	CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_ext


clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations -Wno-deprecated-declarations -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-3.9/selinuxswig_python_wrap.o


and second time by

install-pywrap: pywrap
	$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .

clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-cpython-39/selinuxswig_python_wrap.o


I'd expect that it's built only in pywrap target and install-pywrap
would just install it.

There's a difference in the output dir - build/temp.linux-x86_64-3.9 vs build/temp.linux-x86_64-cpython-39




> ---
> fixes GitHub CI, see https://github.com/SELinuxProject/selinux/pull/388
> ---
>  libselinux/src/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index 36d57122..f9a1e5f5 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -187,7 +187,7 @@ install: all
>  	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
>  
>  install-pywrap: pywrap
> -	$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
> +	CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
>  	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
>  	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
>  
> -- 
> 2.40.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libselinux: set CFLAGS for pip installation
  2023-04-26 15:01 ` Petr Lautrbach
@ 2023-04-26 15:53   ` Petr Lautrbach
  2023-05-03 16:24     ` James Carter
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Lautrbach @ 2023-04-26 15:53 UTC (permalink / raw)
  To: Christian Göttsche, selinux

Petr Lautrbach <plautrba@redhat.com> writes:

> Christian Göttsche <cgzones@googlemail.com> writes:
>
>> Explicitly set CFLAGS for the pip install command, similar to calling
>> setup.py, to ignore known compiler warnings treated as errors, e.g.:
>>
>>     selinuxswig_python_wrap.c:3593:19: error: 'sidget' is deprecated [-Werror,-Wdeprecated-declarations]
>>                 result = (int)sidget(arg1);
>>                               ^
>>     selinuxswig_python_wrap.c:15024:1: error: no previous prototype for function 'PyInit__selinux' [-Werror,-Wmissing-prototypes]
>>             SWIG_init(void) {
>>             ^
>>
>> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
>
> It looks like a problem in build system - selinuxswig_python_wrap.o is
> built twice, first time by
>
> pywrap: all selinuxswig_python_exception.i
> 	CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_ext
>
>
> clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations -Wno-deprecated-declarations -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-3.9/selinuxswig_python_wrap.o
>
>
> and second time by
>
> install-pywrap: pywrap
> 	$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
>
> clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-cpython-39/selinuxswig_python_wrap.o
>
>
> I'd expect that it's built only in pywrap target and install-pywrap
> would just install it.

So according to the internet, pip install does all setup.py operations
[build_ext, build, install, ...] on it's own and therefore pywrap target
with `setup.py build` seems to be useless.

But your change is necessary.

Acked-by: Petr Lautrbach <lautrbach@redhat.com>




>
>
>> ---
>> fixes GitHub CI, see https://github.com/SELinuxProject/selinux/pull/388
>> ---
>>  libselinux/src/Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>> index 36d57122..f9a1e5f5 100644
>> --- a/libselinux/src/Makefile
>> +++ b/libselinux/src/Makefile
>> @@ -187,7 +187,7 @@ install: all
>>  	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
>>  
>>  install-pywrap: pywrap
>> -	$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
>> +	CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
>>  	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
>>  	ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
>>  
>> -- 
>> 2.40.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libselinux: set CFLAGS for pip installation
  2023-04-26 15:53   ` Petr Lautrbach
@ 2023-05-03 16:24     ` James Carter
  0 siblings, 0 replies; 4+ messages in thread
From: James Carter @ 2023-05-03 16:24 UTC (permalink / raw)
  To: Petr Lautrbach; +Cc: Christian Göttsche, selinux

On Wed, Apr 26, 2023 at 12:06 PM Petr Lautrbach <plautrba@redhat.com> wrote:
>
> Petr Lautrbach <plautrba@redhat.com> writes:
>
> > Christian Göttsche <cgzones@googlemail.com> writes:
> >
> >> Explicitly set CFLAGS for the pip install command, similar to calling
> >> setup.py, to ignore known compiler warnings treated as errors, e.g.:
> >>
> >>     selinuxswig_python_wrap.c:3593:19: error: 'sidget' is deprecated [-Werror,-Wdeprecated-declarations]
> >>                 result = (int)sidget(arg1);
> >>                               ^
> >>     selinuxswig_python_wrap.c:15024:1: error: no previous prototype for function 'PyInit__selinux' [-Werror,-Wmissing-prototypes]
> >>             SWIG_init(void) {
> >>             ^
> >>
> >> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> >
> >
> > It looks like a problem in build system - selinuxswig_python_wrap.o is
> > built twice, first time by
> >
> > pywrap: all selinuxswig_python_exception.i
> >       CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_ext
> >
> >
> > clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations -Wno-deprecated-declarations -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-3.9/selinuxswig_python_wrap.o
> >
> >
> > and second time by
> >
> > install-pywrap: pywrap
> >       $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
> >
> > clang -fdeclspec -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I/tmp/destdir/usr/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -fPIC -I../include -I/opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-cpython-39/selinuxswig_python_wrap.o
> >
> >
> > I'd expect that it's built only in pywrap target and install-pywrap
> > would just install it.
>
> So according to the internet, pip install does all setup.py operations
> [build_ext, build, install, ...] on it's own and therefore pywrap target
> with `setup.py build` seems to be useless.
>
> But your change is necessary.
>
> Acked-by: Petr Lautrbach <lautrbach@redhat.com>
>

Merged.
Thanks,
Jim

>
>
>
> >
> >
> >> ---
> >> fixes GitHub CI, see https://github.com/SELinuxProject/selinux/pull/388
> >> ---
> >>  libselinux/src/Makefile | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> >> index 36d57122..f9a1e5f5 100644
> >> --- a/libselinux/src/Makefile
> >> +++ b/libselinux/src/Makefile
> >> @@ -187,7 +187,7 @@ install: all
> >>      ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
> >>
> >>  install-pywrap: pywrap
> >> -    $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
> >> +    CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
> >>      install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
> >>      ln -sf --relative $(DESTDIR)$(PYTHONLIBDIR)/selinux/_selinux$(PYCEXT) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
> >>
> >> --
> >> 2.40.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-03 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-20 16:27 [PATCH] libselinux: set CFLAGS for pip installation Christian Göttsche
2023-04-26 15:01 ` Petr Lautrbach
2023-04-26 15:53   ` Petr Lautrbach
2023-05-03 16:24     ` James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.