Bug 2153037 - python-setuptools: Unclear how CCompiler.has_function works for functions with parameters
Summary: python-setuptools: Unclear how CCompiler.has_function works for functions wit...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-setuptools
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Python Maintainers
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 2144132
Blocks: PortingToModernCHelpNeeded 2153038 2167481 2168154
TreeView+ depends on / blocked
 
Reported: 2022-12-13 20:53 UTC by Florian Weimer
Modified: 2023-04-21 01:04 UTC (History)
6 users (show)

Fixed In Version: python-setuptools-67.6.1-1.fc39
Clone Of:
Environment:
Last Closed: 2023-04-21 01:04:23 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github pypa distutils pull 195 0 None open distutils.ccompiler: Make has_function work with more C99 compilers 2022-12-21 00:35:52 UTC
Github pypa setuptools issues 3648 0 None open Unclear how CCompiler.has_function works for functions with parameters 2022-12-13 20:53:15 UTC

Description Florian Weimer 2022-12-13 20:53:16 UTC
python-yappi has this in setup.py:

if os.name == 'posix' and sys.platform != 'darwin':
    compiler = new_compiler()
    if compiler.has_function('timer_create', libraries=('rt', )):
        user_macros.append(('LIB_RT_AVAILABLE', '1'))
        user_libraries.append('rt')

As described in the Github issue, this only works as long as the compiler supports implicit function declarations. Future compilers probably won't, so we need to solve this somehow, probably with a generic change inside python-setuptools.

This example also shows why adding include files do not solve the issue: timer_create expects several arguments. The has_function implementation has no realistic way of knowing the required argument types, so this just can't work as designed.

Comment 1 Miro Hrončok 2022-12-21 00:35:52 UTC
Thanks for the upstream PR.

https://github.com/pypa/distutils/pull/195

Comment 2 Florian Weimer 2022-12-21 07:36:26 UTC
(In reply to Miro Hrončok from comment #1)
> Thanks for the upstream PR.
> 
> https://github.com/pypa/distutils/pull/195

Any suggestions how we can move this along? Thanks.

Comment 3 Miro Hrončok 2022-12-21 10:56:06 UTC
Python-maint triages Fedora bugzillas every other week. The next triage is happening today and should hopefully result in somebody from the team taking care of this.


I suppose we need to backport this to setuptools and Python 3.11 as well, correct? Can that be done after the holidays?


Technically, we probably need to backport this to all Pythons, but practically we can do that only when somebody asks us to do so.

Comment 4 Florian Weimer 2022-12-21 10:59:11 UTC
(In reply to Miro Hrončok from comment #3)
> Python-maint triages Fedora bugzillas every other week. The next triage is
> happening today and should hopefully result in somebody from the team taking
> care of this.

I'm mostly concerned with the upstream side. If that's implied by the Fedora triage, that's great.

> I suppose we need to backport this to setuptools and Python 3.11 as well,
> correct? Can that be done after the holidays?

It's not that urgent. I will ping this bug once it starts to block the C99 porting work for real. There are still many other packages that need fixing.

Comment 5 Miro Hrončok 2022-12-21 13:27:58 UTC
We've talked about this bugzilla on the triage. Nobody wants to touch distutils, but we agreed that we will backport your patch once it is needed.

As far as setuptools upstream goes, we are afraid that it won't get merged until actual users will report problems.

Comment 7 Miro Hrončok 2023-02-06 18:34:05 UTC
With https://github.com/pypa/distutils/pull/195 merged, what is the timeline/priority to get this merged into python-setuptools and for python3.11?

Note that https://fedoraproject.org/wiki/Changes/PortingToModernC is targeted for F40 and https://fedoraproject.org/wiki/Changes/Python3.12 is targeted for F39, so a backport for python.11 might not be needed and we will likely update python-setuptools in time for Fedora 40 branching many times.

Comment 8 Miro Hrončok 2023-02-07 10:44:38 UTC
https://setuptools.pypa.io/en/latest/history.html#v67-2-0

> Merge with distutils@8c3c3d29, including fix for sysconfig.get_python_inc() (pypa/distutils#178), fix for segfault on MinGW (pypa/distutils#196), and better has_function support (pypa/distutils#195).

Comment 9 Ben Cotton 2023-02-07 15:00:46 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 10 Florian Weimer 2023-02-07 18:35:55 UTC
(In reply to Miro Hrončok from comment #7)
> With https://github.com/pypa/distutils/pull/195 merged, what is the
> timeline/priority to get this merged into python-setuptools and for
> python3.11?
> 
> Note that https://fedoraproject.org/wiki/Changes/PortingToModernC is
> targeted for F40 and https://fedoraproject.org/wiki/Changes/Python3.12 is
> targeted for F39, so a backport for python.11 might not be needed and we
> will likely update python-setuptools in time for Fedora 40 branching many
> times.

My hope is that we can get Fedora 39 as C99-clean as possible quite early in the cycle, maybe in a couple of weeks. Once all the necessary fixes are in place, I want to inject additional build flags for almost all packages, so that package maintainers can reap the benefits even before GCC 14 lands.

Having has_function fixed would definitely help with that (likewise the C99 fixes for Python itself).

Comment 11 Charalampos Stratakis 2023-04-21 01:04:23 UTC
setuptools has been updated in rawhide.


Note You need to log in before you can comment on or make changes to this bug.