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

python-tk #2307

Closed
magnusviri opened this issue Jun 27, 2023 · 7 comments
Closed

python-tk #2307

magnusviri opened this issue Jun 27, 2023 · 7 comments

Comments

@magnusviri
Copy link
Contributor

How do I get python-tk? I tried to build this myself but I think I'm getting in over my head.

@magnusviri
Copy link
Contributor Author

It looks like it is supposed to be part of Python. But it requires tkl.tk/tcl. I got over my head with all of the variables in this code:

                tcltk_version = Formula["tcl-tk"].any_installed_version.major_minor
                ...
                Extension("_tkinter", ["_tkinter.c", "tkappinit.c"],
                          define_macros=[("WITH_APPINIT", 1)],
                          include_dirs=["#{Formula["tcl-tk"].opt_include/"tcl-tk"}"],
                          libraries=["tcl#{tcltk_version}", "tk#{tcltk_version}"],
                          library_dirs=["#{Formula["tcl-tk"].opt_lib}"])
              ]

@jhheider
Copy link
Contributor

jhheider commented Jun 27, 2023

Hopefully most of those are automatic. It looks like they equate to:

env:
  WITH_APPINIT: 1
  CFLAGS:
    - -I {{deps.tcl.tk/tcl.prefix}}/include  ## should be handled by tea automatically
    - -l tcl{{deps.tcl.tk/tcl.version.marketing}}
    - -l tk{{deps.tcl.tk/tcl.version.marketing}}
    - -L {{deps.tcl.tk/tcl.prefix}}/lib      ## should be handled by tea automatically

@magnusviri
Copy link
Contributor Author

I've been trying to add this with no success. Adding WITH_APPINIT worked. Adding the CFLAGS variables produced this error:

+ export WITH_APPINIT=1
+ WITH_APPINIT=1
+ export 'CFLAGS=-I /opt/tea/tcl.tk/tcl/v8.6.13/include -l tcl8.6 -l tk8.6 -L /opt/tea/tcl.tk/tcl/v8.6.13/lib'
+ CFLAGS='-I /opt/tea/tcl.tk/tcl/v8.6.13/include -l tcl8.6 -l tk8.6 -L /opt/tea/tcl.tk/tcl/v8.6.13/lib'
+ export confdir=lib/python3.11/config-3.11-darwin
+ confdir=lib/python3.11/config-3.11-darwin
+ sed -i.bak -e 's|system_lib_dirs = .*|system_lib_dirs = os.getenv("LIBRARY_PATH").split(":")|' ./setup.py
+ sed -i.bak -e 's|system_include_dirs = .*|system_include_dirs = os.getenv("CPATH").split(":")|' ./setup.py
+ ./configure --prefix=/opt/tea/python.org/v3.11.4 --with-ensurepip --enable-ipv6 --disable-loadable-sqlite-extensions --with-system-expat --with-system-ffi --with-system-libmpdec --enable-shared
checking build system type... aarch64-apple-darwin22.5.0
checking host system type... aarch64-apple-darwin22.5.0
checking for Python interpreter freezing... ./_bootstrap_python
checking for python3.11... no
checking for python3.10... no
checking for python3.9... no
checking for python3.8... no
checking for python3.7... no
checking for python3.6... no
checking for python3... python3
checking Python for regen version... Python 3.9.6
checking for pkg-config... /opt/tea/freedesktop.org/pkg-config/v0.29.2/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/james/blablabla/pantry/builds/python.org-3.11.4+darwin':
configure: error: C compiler cannot create executables
See `config.log' for more details

So this line:

  • export 'CFLAGS=-I /opt/tea/tcl.tk/tcl/v8.6.13/include -l tcl8.6 -l tk8.6 -L /opt/tea/tcl.tk/tcl/v8.6.13/lib'

The 2 directories are correct. tcl8.6 is present in lib, but not tk8.6. Here's the contents.

> ls /opt/tea/tcl.tk/tcl/v8.6.13/include
fakemysql.h           itclInt.h             pqStubs.h             tclOO.h               tclThread.h           tdbcInt.h
fakepq.h              itclIntDecls.h        tcl.h                 tclOODecls.h          tclTomMath.h
fakesql.h             itclMigrate2TclCore.h tclDecls.h            tclOOInt.h            tclTomMathDecls.h
itcl.h                itclTclIntStubsFcn.h  tclInt.h              tclOOIntDecls.h       tclUnixPort.h
itcl2TclOO.h          mysqlStubs.h          tclIntDecls.h         tclPlatDecls.h        tdbc.h
itclDecls.h           odbcStubs.h           tclIntPlatDecls.h     tclPort.h             tdbcDecls.h
> ls /opt/tea/tcl.tk/tcl/v8.6.13/lib
itcl4.2.3         libtclstub8.6.a   sqlite3.40.0      tcl8.6            tclooConfig.sh    tdbcmysql1.1.5    tdbcpostgres1.1.5
libtcl8.6.dylib   pkgconfig         tcl8              tclConfig.sh      tdbc1.1.5         tdbcodbc1.1.5     thread2.8.8

@magnusviri
Copy link
Contributor Author

I removed - -l tk{{deps.tcl.tk/tcl.version.marketing}} and it got past the configure command. So I'll keep working on it.

BTW, I'm hoping to get tk added to the standard python. I believe most Python installations include it.

Also, maybe I should open a new issue with this idea. And maybe you guys have already discussed this. Obviously software is versioned. The package definitions are also versioned. tea can detect when it's old software. But I'm not sure tea has a way to detect if something was installed with an old package version or not. So for example, if this is added to all Pythons that tea supports, I'd have to go remove all of my python installations to get the version with tk. I don't know if this makes sense. It seems to me that tea needs to track both the software version and a package.yml version.

@jhheider
Copy link
Contributor

Yes, we're currently in discussions for the best way to handle that. I think it's likely this: https://github.com/teaxyz/cli/issues/622

@magnusviri
Copy link
Contributor Author

I've been working on this because something I was doing was erroring saying it couldn't find tkinter. I thought this was koboldcpp, but I am not getting the error anymore. I updated it. Or maybe something else got rid of the requirement. And I think you guys have tkinter in your python already! I don't know why I was getting errors before. I don't know what I'm doing... I'm just going to close this and re-open if I can figure out what was causing the error.

@jhheider
Copy link
Contributor

yay? that's great if so.

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

No branches or pull requests

2 participants