-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Modules/Setup #89711
Comments
When trying to compile a completely static CPython interpreter I ran into the following issues:
And the following modules are completely missing from the file:
|
Status is now:
And the following modules are completely missing from the file:
|
I started https://github.com/python/cpython/compare/main...tiran:configure_pkgconfig?expand=1 to integrate pkg-config with configure. The patchset also contains examples how to pass flags from configure into Makefile and Modules/Setup. |
I added several missing module definitions in #29164 math/cmath conflict when _math.c is included twice. |
I ran into another problem. In shared mode, Modules/Setup places the shared modules in ./Modules/ instead of the build directory ./build/lib.something/. The ./Modules/ directory is not on sys.path. getpath.c only adds the build dir to sys.path. It takes the value from ./pybuilddir.txt. The file is generated by sysconfig.py. $ make
...
*** WARNING: renaming "_asyncio" since importing it failed: No module named 'math' The following modules found by detect_modules() in setup.py, have been $ find -name 'math*.so'
./Modules/math.cpython-311-x86_64-linux-gnu.so |
FYI: I've been working with a fixed Setup file in PyRun for a long while. There are indeed a number of modules missing from Setup, since the whole logic was left behind a bit after things moved to setup.py. The issue with _math.o is actually in the main Makefile.pre.in. The version listed there does not match the Makefile lines added via Setup. For PyRun, I had to comment out the one in Makefile.pre.in and then only add one instance to the math module and not the cmath one. This avoids a (harmless) warning during the build. I'm not sure what the _math.o entry exists in Makefile.pre.in. It's only needed by those two modules, AFAIK. Here's the list of modules I had to add in the past (taken from the 3.10 port): """ # _decimal needs more complex setup, punting on this for now # _opcode # _ctypes needs to build libffi first - punting on this # _lsprof # _sqlite3 # bz2 # lzma # Note: Adding this can cause serious issues, since the needed lib isn't #_lzma _lzmamodule.c -llzma # multiprocessing # Optional add-on for multiprocessing to use shared memory
#POSIXSHMEM_LIBS=rt
POSIXSHMEM_LIBS=
_posixshmem \
_multiprocessing/posixshmem.c \
-I$(srcdir)/Modules/_multiprocessing \
$(POSIXSHMEM_LIBS) # queue Not all modules are included, since I did not need all missing ones. |
PR #73365 or #73367 address the issue with _math.o PR #73350 adds the missing modules and also introduces pkg-config lookups for dependencies. Brett and I discussed that we have to introduce conditionals to Modules/Setup to make use of the AM_CONDITIONALs from PR #73350. We also have to figure out how to deal with system-libmpdec and system-cffi. |
I'm using a very simple conditional logic in Setup, which is based In Setup: # @if macosx: TIME_DEFS= In Makefile: # Install the custom Modules/Setup file
if test "$(MACOSX_PLATFORM)"; then \
sed -e 's/# @if macosx: *//' \
$(PYRUNDIR)/$(MODULESSETUP) > $(PYTHONDIR)/Modules/Setup; \
elif test "$(FREEBSD_PLATFORM)"; then \
sed -e 's/# @if freebsd: *//' \
$(PYRUNDIR)/$(MODULESSETUP) > $(PYTHONDIR)/Modules/Setup; \
else \
sed -e 's/# @if not macosx: *//' \
-e 's/# @if not freebsd: *//' \
$(PYRUNDIR)/$(MODULESSETUP) > $(PYTHONDIR)/Modules/Setup; \
fi; Setup used to be templated as well in the past, but that logic was removed |
On 23.10.2021 20:04, Christian Heimes wrote: I think those patches are both taking things a bit too far. This is a build problem, not a code problem. It's perfectly The catch is that the makesetup logic is not smart enough to only The entry in Makefile.pre.in should not be needed, since the logic BTW: There's a simple trick to avoid the makesetup issue: simply |
The trick would move the math function back into the core. Mark moved the math functions out of the core on purpose, see bpo-7518. |
On 23.10.2021 21:30, Christian Heimes wrote:
I don't follow you. With the _math.o target in Makefile.pre.in, And yes, it does export a symbol, but _Py_log1p is not going to The trick is essentially not changing the 3.10 status quo. It And it removes the warning of having multiple _math.o targets OTOH, _math.h and .c are really small, so perhaps it's better Today, only the _Py_log1p() code is actually used and then only |
New changeset ece916e by Christian Heimes in branch 'main': |
Brett, we can use AM_CONDITIONAL() to conditionally enable/disable a feature and AC_CONFIG_FILES() to create a Modules/Setup from a template: Example: The conditional AM_CONDITIONAL([HAVE_SCPROXY], [test "$ac_sys_system" = "Darwin"]) sets HAVE_SCPROXY_FALSE and HAVE_NIS_SCPROXY based on the check. On macOS:
On Linux:
We can either do something like:
or:
|
Typo, the last line should read "@HAVE_SCPROXY_FALSE@_scproxy" |
On 26.10.2021 16:17, Christian Heimes wrote:
I think it would be more helpful (and generate a lot fewer such Some other things: I saw that you stripped off lots of -I and -L options from the Setup You also removed the structure of the listings, which makes things Since Setup is a (potentially) hand edited file, it's good to leave |
Brett removed a lot of stuff in 01cf4fb to make the file more readable. I removed unnecessary -D, -I, and -L to make the file even more readable. You can pass custom flags to ./configure. Setup should not be edited by hand. Customizations go to Setup.local. |
On 26.10.2021 19:42, Christian Heimes wrote:
Could Brett or you please add those notes back ? There's no other place Regarding the -I and -L flags, my question was whether these are I've gone through the Makefile and found that these are already Please be careful when moving e.g. -I or -L options which point to Having the -D defined in the relevant code is a lot better. Thanks
Editing Setup.local instead of Setup is not documented anywhere ?! |
On 26.10.2021 20:47, Marc-Andre Lemburg wrote:
I could also edit the file and add those back, after you're done |
I'm seeing some weird breakage in the deadsnakes builds, presumably due to this change:
https://github.com/deadsnakes/python3.11-nightly/actions/runs/1389342824 I believe this is due to https://github.com/python/cpython/pull/29225/files#diff-aac314cb71e95912e95795a4f4a278f2e75a5bc28e93f52e338185c8e7f7d7eaL225 |
It really depends on what "details" you're referring to. Most of what I removed were things like "Module by <person>", or saying _json.c is for "json accelerator" which is obvious to me. Anything that seemed pertinent to compilation I left in. So if there's something you specifically want to add back in that you think is important then please feel free to as I'm done editing the file for my purposes at the moment. |
On 27.10.2021 22:58, Brett Cannon wrote:
I had already listed some of those details.
Will do. |
@christian are you using this issue for your pkg-config work, or should I close this? |
Modules/Setup
#29115Modules/Setup
easier to read #29143Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: