tbarnetlamb / hyphen Goto Github PK
View Code? Open in Web Editor NEWhyphen - access Haskell modules from Python
License: GNU General Public License v2.0
hyphen - access Haskell modules from Python
License: GNU General Public License v2.0
It appears that the distutils package is deprecated error is no longer giving warnings, but returning a non-zero exit code (1) on Ubuntu 22.04.1 as such I cannot install. I'll see what I can do to give options shortly.
If you like here is the whole error.
``/home/user/hyphen/hyphen/build-extn.py:3: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
import sys, distutils.sysconfig, os, os.path, subprocess, optparse
/home/user/hyphen/hyphen/build-extn.py:3: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
import sys, distutils.sysconfig, os, os.path, subprocess, optparse
[ 2 of 12] Compiling HyphenKinds ( /home/user/hyphen/hyphen/lowlevel_src/HyphenKinds.hs, /home/user/hyphen/hyphen/lowlevel_inter/HyphenKinds.o )
/home/user/hyphen/hyphen/lowlevel_src/HyphenKinds.hs:9:1: error:
Could not find module ‘Data.Hashable’
Use -v (or :set -v
in ghci) to see a list of the files searched for.
|
9 | import Data.Hashable
| ^^^^^^^^^^^^^^^^^^^^
Traceback (most recent call last):
File "/home/user/hyphen/hyphen/build-extn.py", line 130, in
subprocess.check_call(invocation + ['-no-link'])
File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ghc', '-dynamic', '-shared', '-fPIC', '-no-hs-main', '-fwarn-unused-imports', '-cpp', '/home/user/hyphen/hyphen/lowlevel_src/Hyphen.hs', '/home/user/hyphen/hyphen/lowlevel_src/hyphen_c.c', '-i/home/user/hyphen/hyphen/lowlevel_src', '-hidir', '/home/user/hyphen/hyphen/lowlevel_inter', '-odir', '/home/user/hyphen/hyphen/lowlevel_inter', '-I/usr/include/python3.10', '-package', 'ghc', '-lHSrts_thr-ghc8.8.4\n', '-lpython3.10', '-no-link']' returned non-zero exit status 1.
Hello mate, I am not sure where can I find the "hs", I managed to use "pip install hs" and so on, unfortunately, I failled. Could you please tell me how to install it. thx!
I'm trying to get scripts to install automatically, what all would I need to check to see that it worked properly, could I just tell python to add two numbers together, but in Haskell and if it works, everything is good, or is there some other "section" that I need to check?
Thanks!
Hi!
It's possible this is obvious to the experienced, but I've gone back and forth and can't seem to resolve this issue, even when modifying the cabal file to expose Kind.
Here's the error trace.
Insights would be much appreciated. I've read through every haskell-from-python site out there...
Kind regards
[11 of 12] Compiling HyphenGHC ( /Users/kodiak/haskell/hyphen-master/hyphen/lowlevel_src/HyphenGHC.hs, /Users/kodiak/haskell/hyphen-master/hyphen/lowlevel_inter/HyphenGHC.o )
/Users/kodiak/haskell/hyphen-master/hyphen/lowlevel_src/HyphenGHC.hs:44:1: error:
Could not find module ‘Kind’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
44 | import qualified Kind as GHCKind
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Traceback (most recent call last):
File "/Users/kodiak/haskell/hyphen-master/hyphen/build-extn.py", line 130, in <module>
subprocess.check_call(invocation + ['-no-link'])
File "/Users/kodiak/anaconda3/lib/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ghc', '-dynamic', '-shared', '-fPIC', '-no-hs-main', '-fwarn-unused-imports', '-cpp', '/Users/kodiak/haskell/hyphen-master/hyphen/lowlevel_src/Hyphen.hs', '/Users/kodiak/haskell/hyphen-master/hyphen/lowlevel_src/hyphen_c.c', '-i/Users/kodiak/haskell/hyphen-master/hyphen/lowlevel_src', '-hidir', '/Users/kodiak/haskell/hyphen-master/hyphen/lowlevel_inter', '-odir', '/Users/kodiak/haskell/hyphen-master/hyphen/lowlevel_inter', '-I/Users/kodiak/anaconda3/include/python3.6m', '-package', 'ghc', '-lHSrts_thr-ghc8.10.1\n', '-lpython3.6', '-no-link']' returned non-zero exit status 1.
(base) MacBook-Pro:testhyphen kodiak$
I'm trying to build a wrapper for some haskell functions to be used in python, I would like to use this package as a dependency. Is there a way to do that? I assume I could make some .batch files for each OS, but I was wondering if there was a simpler way that may have been implemented without updating the build.md. thanks!
hyphen seems like a very cool project. I wanted to try it out just to get a feel for its behavior. I was unable to build a working version though. Here's a transcript of my effort:
[exarkun@magnon:~/Work/python/hyphen]$ nix-shell -p python3 'haskellPackages.ghcWithPackages (hs: with hs; [ hashable unordered-containers ghc-paths ])'
[nix-shell:~/Work/python/hyphen]$ python --version
Python 3.9.6
[nix-shell:~/Work/python/hyphen]$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7
[nix-shell:~/Work/python/hyphen]$ python hyphen/build-extn.py
[ 1 of 12] Compiling HyphenBase ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HyphenBase.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HyphenBase.o )
[ 2 of 12] Compiling HyphenKinds ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HyphenKinds.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HyphenKinds.o )
[ 3 of 12] Compiling HyphenTyCon ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HyphenTyCon.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HyphenTyCon.o )
[ 4 of 12] Compiling HsType ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HsType.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HsType.o )
[ 5 of 12] Compiling HyphenUnify ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HyphenUnify.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HyphenUnify.o )
[ 6 of 12] Compiling PythonBase ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/PythonBase.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/PythonBase.o )
[ 7 of 12] Compiling HsObjRaw ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HsObjRaw.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HsObjRaw.o )
[ 8 of 12] Compiling HyphenWrapping ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HyphenWrapping.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HyphenWrapping.o )
[ 9 of 12] Compiling Pythonate ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/Pythonate.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/Pythonate.o )
[10 of 12] Compiling HyphenExceptions ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HyphenExceptions.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HyphenExceptions.o )
[11 of 12] Compiling HyphenGHC ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/HyphenGHC.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/HyphenGHC.o )
[12 of 12] Compiling Hyphen ( /home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/Hyphen.hs, /home/exarkun/Work/python/hyphen/hyphen/lowlevel_inter/Hyphen.o )
/home/exarkun/Work/python/hyphen/hyphen/lowlevel_src/Hyphen.hs:1030:5: warning: [-Wdeprecations]
In the use of ‘defaultCleanupHandler’ (imported from GHC):
Deprecated: "Cleanup is now done by runGhc/runGhcT"
|
1030 | GHC.defaultCleanupHandler flags $ return 0
| ^^^^^^^^^^^^^^^^^^^^^^^^^
Linking /home/exarkun/Work/python/hyphen/hyphen/hslowlevel.cpython-39-x86_64-linux-gnu.so ...
[nix-shell:~/Work/python/hyphen]$ python
Python 3.9.6 (default, Jun 28 2021, 08:57:49)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hyphen
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/exarkun/Work/python/hyphen/hyphen/__init__.py", line 23, in <module>
caches.precache_modules([
File "/home/exarkun/Work/python/hyphen/hyphen/caches.py", line 40, in precache_modules
module_cache.update(hslowlevel.import_lib(*names))
hyphen.HsException: Could not find module ‘Data.Hashable’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
I got this error output when running the build script.
ubuntu@ip-172-31-35-17:~/hyphen$ python3 hyphen/build-extn.py
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c: In function ‘c_installHaskellCtrlCHandler’:
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c:435:19: error:
error: ‘SIGINT’ undeclared (first use in this function); did you mean ‘T_UINT’?
if (PyOS_getsig(SIGINT) == python_siginthandler && haskell_siginthandler)
^~~~~~
T_UINT
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c:435:19: error:
note: each undeclared identifier is reported only once for each function it appears in
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c: In function ‘c_reinstallPythonCtrlCHandler’:
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c:447:19: error:
error: ‘SIGINT’ undeclared (first use in this function); did you mean ‘T_UINT’?
if (PyOS_getsig(SIGINT) == &compound_sigint_handler && python_siginthandler)
^~~~~~
T_UINT
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c: In function ‘PyInit_hslowlevel’:
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c:1401:39: error:
error: ‘SIGINT’ undeclared (first use in this function); did you mean ‘T_UINT’?
python_siginthandler = PyOS_getsig(SIGINT);
^~~~~~
T_UINT
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c: In function ‘pyhs_free’:
/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c:1445:50: error:
error: ‘SIGINT’ undeclared (first use in this function); did you mean ‘T_UINT’?
PyOS_sighandler_t sigint_handler = PyOS_getsig(SIGINT);
^~~~~~
T_UINT
gcc' failed in phase
C Compiler'. (Exit code: 1)
Traceback (most recent call last):
File "hyphen/build-extn.py", line 130, in
subprocess.check_call(invocation + ['-no-link'])
File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ghc', '-dynamic', '-shared', '-fPIC', '-no-hs-main', '-fwarn-unused-imports', '-cpp', '/home/ubuntu/hyphen/hyphen/lowlevel_src/Hyphen.hs', '/home/ubuntu/hyphen/hyphen/lowlevel_src/hyphen_c.c', '-i/home/ubuntu/hyphen/hyphen/lowlevel_src', '-hidir', '/home/ubuntu/hyphen/hyphen/lowlevel_inter', '-odir', '/home/ubuntu/hyphen/hyphen/lowlevel_inter', '-I/usr/include/python3.6m', '-package', 'ghc', '-lHSrts_thr-ghc8.0.2\n', '-lpython3.6m', '-no-link']' returned non-zero exit status 1.
I fixed it by adding #include <signal.h> to line 4 on hyphen/lowlevel_src/hyphen_c.c. I've forked & pushed updated branch to my fork at https://github.com/sjwhitmore/hyphen/tree/include-signal-h if you'd like to see the code. Thanks!
Hi!
Running
import hyphen
hyphen.find_and_load_haskell_source()
import hs.Tryit
Getting this error:
Traceback (most recent call last):
File "/home/ai/haskell/hyphen/test_in_place.py", line 7, in
hyphen.find_and_load_haskell_source()
File "/home/ai/haskell/hyphen/hyphen/source_loading.py", line 136, in find_and_load_haskell_source
fetch_source_modules(found_modules)
File "/home/ai/haskell/hyphen/hyphen/caches.py", line 51, in fetch_source_modules
module_cache.update(hslowlevel.import_src(*paths))
hyphen.HsException: : fatal:
cannot find object file ‘/home/ai/haskell/hyphen/Test.dyn_o’
while linking an interpreted expression
Is there any workaround to get this to work?
Help much appreciated for this noob ;-)
Kind regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.