litxio / ptghci

High-powered REPL for Haskell, inspired by IPython
Other
336 stars 6 forks source link

Compatibility with Python 3.8 #18

Closed nkoturovic closed 1 year ago

nkoturovic commented 4 years ago

1) After update to Python 3.8 on ArchLinux - build failed:

Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1/build/ptghci/ptghci ...
/home/$USER/Desktop/prog/github/ptghci/.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1/build/
libHSptghci-0.1.0.0-6NZdOqpUZLOJGaOa1athdc_p.a(StartPy.p_o):
r2D1G_info: error: undefined reference to 'Py_Main' 
... and so on ... undefined reference to: 'PyRun_SimpleString', 'Py_Initialize' ...
 building failed `gcc' failed in phase `Linker'. (Exit code: 1)

Managed to bypass this error by replacing python-3.8.pc with python-3.8-embed.pc in /usr/lib/pkgconfig, but

2) After successful build and install there is another error: Error: When trying to run ptghci:

Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/home/$USER/Desktop/prog/github/ptghci/.stack-work/install/x86_64-linux-tinfo6/0bf99542257587e572328b589eb8a6228c5591a81be4ab619f974b2f841ad228/8.6.5/share/x86_64-linux-ghc-8.6.5/ptghci-0.1.0.0/pybits/ptghci/app.py", line 45, in __init__
    signal.signal(signal.SIGINT, int_handler)
  File "/usr/lib/python3.8/signal.py", line 4

Sorry for lack of understanding

RichardWarfield commented 4 years ago

Thanks for raising this issue; I wasn't aware that Python 3.8 had changed the pkg-config flags for linking to libpython.

RichardWarfield commented 4 years ago

I pushed a new python3.8 branch; could you try this, using the stack-python3.8.yaml file (stack install --stack-yaml=stack-python3.8.yaml)?

The first issue you ran into is straightforward to fix by using the python3-embed pkg-config package instead of python3. This requires a cabal flag to support both Python 3.8 and earlier, though, thus the new stack.yaml file.

The second issue I have a hard time explaining except as a bug in Python 3.8.0. I check that we're running in the main thread before calling signal.signal, but then Python raises an exception saying "signal only works in main thread" anyway. I've raised an issue on the Python issue tracker; in the mean time, it seems that this issue goes away if I use a non-bound thread to run the Python interpreter. This solution makes me nervous though.

Again, thanks for reporting this issue. If you hadn't pointed out the new -embed pkgconfig package, I would have probably spent hours trying to figure out what had broken with Python 3.8!

nkoturovic commented 4 years ago

Thank you for your quick response!

It works now, with python3.8 branch and new .yaml file. From user point, everything seems to work just fine.

I hope that bug in python3.8 will be tracked and fixed fast, so you could be able to apply more appropriate solution.

Glad I could help a little.