Skip to content
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

Updating brew install command to build _tkinter #893

Merged
merged 7 commits into from
Jun 13, 2022

Conversation

izumiberat
Copy link
Contributor

I am using Mac OS Catalina 10.15.7.
This is to avoid getting the following message:

The necessary bits to build these optional modules were not found:
_tkinter

The solution was provided by @erlend-aasland.
Issue number: python/cpython#93659

I am using Mac OS Catalina 10.15.7.
This is to avoid getting the following message:
> The necessary bits to build these optional modules were not found:
> _tkinter
Copy link

@bxsx bxsx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both instructions for 3.11+ and 3.7-3.9 work in 3.10. I suggest using the latest (and simplified) version for 3.10.

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Jun 13, 2022

Both instructions for 3.11+ and 3.7-3.9 work in 3.10. I suggest using the latest (and simplified) version for 3.10.

No. Please read up on the previous discussion. We changed configure and setup.py in 3.11. You can not use the same instructions on 3.10 (and before) and in 3.11 and newer.

Also, if you build in-tree (as I expect you do), you need to clean everything when you switch between revisions. This is extremely important. You can clean your source tree by executing git clean -fdx. Here's a quick-n-dirty recipe on how to switch between revisions and compile:

$ git clone https://github.com/python/cpython.git cpython.git
$ cd cpython.git
$ ./configure && make
$ git checkout origin/3.10
$ git clean -fdx  # <= this is important! make clean is _not_ enough
$ ./configure && make

@bxsx
Copy link

bxsx commented Jun 13, 2022

@erlend-aasland

I did the following:

$ rm -rf cpython
$ git clone https://github.com/python/cpython
$ cd cpython
$ git checkout origin/3.10
$ PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" ./configure --with-pydebug --with-openssl=$(brew --prefix openssl@1.1)
$ make -j
$ ./python.exe --version

Selected output:

CC='gcc' LDSHARED='gcc -bundle -undefined dynamic_lookup    ' OPT='-g -O0 -Wall' 	_TCLTK_INCLUDES='-I/opt/homebrew/Cellar/tcl-tk/8.6.12_1/include' _TCLTK_LIBS='-L/opt/homebrew/Cellar/tcl-tk/8.6.12_1/lib -ltk8.6 -ltkstub8.6 -ltcl8.6 -ltclstub8.6' 	./python.exe -E ./setup.py  build
gcc -Wno-unused-result -Wsign-compare -g -O0 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -DWITH_APPINIT=1 -I./Include -I. -I/Users/bxsx/+dev/opensource/cpython/Include -I/Users/bxsx/+dev/opensource/cpython -c /Users/bxsx/+dev/opensource/cpython/Modules/_tkinter.c -o build/temp.macosx-12.4-arm64-3.10-pydebug/Users/bxsx/+dev/opensource/cpython/Modules/_tkinter.o -I/opt/homebrew/Cellar/tcl-tk/8.6.12_1/include
gcc -Wno-unused-result -Wsign-compare -g -O0 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -DWITH_APPINIT=1 -I./Include -I. -I/Users/bxsx/+dev/opensource/cpython/Include -I/Users/bxsx/+dev/opensource/cpython -c /Users/bxsx/+dev/opensource/cpython/Modules/tkappinit.c -o build/temp.macosx-12.4-arm64-3.10-pydebug/Users/bxsx/+dev/opensource/cpython/Modules/tkappinit.o -I/opt/homebrew/Cellar/tcl-tk/8.6.12_1/include
gcc -bundle -undefined dynamic_lookup build/temp.macosx-12.4-arm64-3.10-pydebug/Users/bxsx/+dev/opensource/cpython/Modules/_tkinter.o build/temp.macosx-12.4-arm64-3.10-pydebug/Users/bxsx/+dev/opensource/cpython/Modules/tkappinit.o -L/usr/local/lib -o build/lib.macosx-12.4-arm64-3.10-pydebug/_tkinter.cpython-310d-darwin.so -L/opt/homebrew/Cellar/tcl-tk/8.6.12_1/lib -ltk8.6 -ltkstub8.6 -ltcl8.6 -ltclstub8.6
Python 3.10.5+

Running ./python.exe -m tkinter behaves the same way as in 3.11:

Therefore, I still believe that the instructions for 3.11+ works in 3.10.

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Jun 13, 2022

Ah, yes, there were basic support for pkg-config for Tcl/Tk in configure in 3.10. My bad. However, using --with-tcl-* also works in 3.10. Both approaches works just fine; both get the job done (which is the point of importance). I don't want to touch the PR more than needed now. The PR is correct as it stands now. I'll wait for Ezio's final thumbs up before merging.

@bxsx
Copy link

bxsx commented Jun 13, 2022

I think the point is to have a nice and compact way to get the job done.

$ PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
     ./configure --with-pydebug --with-openssl=$(brew --prefix openssl)

vs

$ export PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig"
$ ./configure --with-pydebug \
               --with-openssl=$(brew --prefix openssl) \
               --with-tcltk-libs="$(pkg-config --libs tcl tk)" \
               --with-tcltk-includes="$(pkg-config --cflags tcl tk)"

They are not the same. The latter includes 2 commands instead of 1 command to run + forces PKG_CONFIG_PATH variable to be exported. So the developer experience is much different.
We will also be shading the latter in the future, so it's good to promote the new way to configure the build as the instructions will be updated anyway (like with 3.9 EOL).

I would agree it doesn't matter if it takes a lot of effort, but the fix is already here: #893 (review)

@erlend-aasland
Copy link
Contributor

I think the point is to have a nice and compact way to get the job done.

I've updated the instructions to include 3.10. Thanks.

Copy link
Member

@ezio-melotti ezio-melotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good to me. I don't think the 3.6 section needs to be included, so you can remove that.

@erlend-aasland erlend-aasland merged commit 0932bf2 into python:main Jun 13, 2022
@erlend-aasland
Copy link
Contributor

Thanks all, for helping improving the devguide!

@izumiberat izumiberat deleted the patch-3 branch June 13, 2022 19:43
AA-Turner pushed a commit to AA-Turner/devguide that referenced this pull request Jun 17, 2022
…cl/Tk (python#893)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants