From d76285f84e4ef7feb41f14f56d360c46e8134eff Mon Sep 17 00:00:00 2001 From: "Michal J. Gajda" Date: Mon, 30 Jul 2018 17:39:42 +0200 Subject: [PATCH 1/6] Update to GHC 8.4, and LTS 11.2 --- HaPy-haskell/.gitignore | 1 + HaPy-haskell/Foreign/HaPy.hs | 2 +- HaPy-haskell/HaPy.cabal | 6 ++-- HaPy-haskell/stack.yaml | 64 ++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 HaPy-haskell/.gitignore create mode 100644 HaPy-haskell/stack.yaml diff --git a/HaPy-haskell/.gitignore b/HaPy-haskell/.gitignore new file mode 100644 index 0000000..8ee1bf9 --- /dev/null +++ b/HaPy-haskell/.gitignore @@ -0,0 +1 @@ +.stack-work diff --git a/HaPy-haskell/Foreign/HaPy.hs b/HaPy-haskell/Foreign/HaPy.hs index 55469cd..b6711a8 100644 --- a/HaPy-haskell/Foreign/HaPy.hs +++ b/HaPy-haskell/Foreign/HaPy.hs @@ -90,7 +90,7 @@ toForeignExp _ exp = fail "conversion failed: unknown type!" makeFunction :: (String -> String) -> (Name -> [FType] -> ClauseQ) -> ([FType] -> TypeQ) -> Name -> DecsQ makeFunction changeName makeClause makeType origName = do - VarI _ t _ _ <- reify origName + VarI _ t _ <- reify origName let types = map fromHaskellType $ toTypeList t name = mkName . changeName . nameBase $ origName cl = makeClause origName types diff --git a/HaPy-haskell/HaPy.cabal b/HaPy-haskell/HaPy.cabal index 443aae2..a2adda4 100644 --- a/HaPy-haskell/HaPy.cabal +++ b/HaPy-haskell/HaPy.cabal @@ -1,5 +1,5 @@ name: HaPy -version: 0.1.1.1 +version: 0.1.1.3 synopsis: Haskell bindings for Python description: Call Haskell functions from Python! homepage: https://github.com/sakana/HaPy @@ -18,6 +18,6 @@ library Foreign.HaPy.Internal extensions: TemplateHaskell c-sources: HaPy_init.c - build-depends: base >= 4.5 && < 4.9, + build-depends: base >= 4.5 && < 4.12, th-lift >= 0.5 && < 0.8, - template-haskell >= 2.7.0.0 && < 2.11.0.0 + template-haskell >= 2.7.0.0 && < 2.14.0.0 diff --git a/HaPy-haskell/stack.yaml b/HaPy-haskell/stack.yaml new file mode 100644 index 0000000..8e9fe75 --- /dev/null +++ b/HaPy-haskell/stack.yaml @@ -0,0 +1,64 @@ +# This file was automatically generated by 'stack init' +# +# Some commonly used options have been documented as comments in this file. +# For advanced use and comprehensive documentation of the format, please see: +# https://docs.haskellstack.org/en/stable/yaml_configuration/ + +# Resolver to choose a 'specific' stackage snapshot or a compiler version. +# A snapshot resolver dictates the compiler version and the set of packages +# to be used for project dependencies. For example: +# +# resolver: lts-3.5 +# resolver: nightly-2015-09-21 +# resolver: ghc-7.10.2 +# +# The location of a snapshot can be provided as a file or url. Stack assumes +# a snapshot provided as a file might change, whereas a url resource does not. +# +# resolver: ./custom-snapshot.yaml +# resolver: https://example.com/snapshots/2018-01-01.yaml +resolver: lts-12.4 + +# User packages to be built. +# Various formats can be used as shown in the example below. +# +# packages: +# - some-directory +# - https://example.com/foo/bar/baz-0.0.2.tar.gz +# - location: +# git: https://github.com/commercialhaskell/stack.git +# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# subdirs: +# - auto-update +# - wai +packages: +- . +# Dependency packages to be pulled from upstream that are not in the resolver +# using the same syntax as the packages field. +# (e.g., acme-missiles-0.3) +# extra-deps: [] + +# Override default flag values for local packages and extra-deps +# flags: {} + +# Extra package databases containing global packages +# extra-package-dbs: [] + +# Control whether we use the GHC we find on the path +# system-ghc: true +# +# Require a specific version of stack, using version ranges +# require-stack-version: -any # Default +# require-stack-version: ">=1.8" +# +# Override the architecture used by stack, especially useful on Windows +# arch: i386 +# arch: x86_64 +# +# Extra directories used by stack for building +# extra-include-dirs: [/path/to/dir] +# extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor From 0b39fbc83e9d58d6d47d5c977aa3f25c2ca5be18 Mon Sep 17 00:00:00 2001 From: "Michal J. Gajda" Date: Tue, 31 Jul 2018 02:25:06 +0200 Subject: [PATCH 2/6] Updated example to Stack and GHC 8.4.3 --- example/Makefile | 2 +- example/haskell/.gitignore | 1 + example/haskell/ExampleModule.cabal | 6 ++++-- example/haskell/stack.yaml | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 example/haskell/.gitignore create mode 100644 example/haskell/stack.yaml diff --git a/example/Makefile b/example/Makefile index 0a0bb5e..9934b0e 100644 --- a/example/Makefile +++ b/example/Makefile @@ -12,7 +12,7 @@ endif @echo endif @echo '>>> sudo pip install hapy-ffi' - @sudo pip install hapy-ffi + @pip install hapy-ffi @echo @$(MAKE) -C haskell all @echo diff --git a/example/haskell/.gitignore b/example/haskell/.gitignore new file mode 100644 index 0000000..8ee1bf9 --- /dev/null +++ b/example/haskell/.gitignore @@ -0,0 +1 @@ +.stack-work diff --git a/example/haskell/ExampleModule.cabal b/example/haskell/ExampleModule.cabal index 9870161..9ef7b5b 100644 --- a/example/haskell/ExampleModule.cabal +++ b/example/haskell/ExampleModule.cabal @@ -13,9 +13,11 @@ cabal-version: >=1.10 library exposed-modules: ExampleModule, Export other-extensions: ForeignFunctionInterface, TemplateHaskell - build-depends: base >=4.6 && <4.8, HaPy == 0.1.* + build-depends: base >=4.6 && <4.12, HaPy == 0.1.* default-language: Haskell2010 -- *** change this to your GHC version *** -- the make script will do this automatically - extra-libraries: HSrts-ghc7.8.2 + --extra-libraries: HSrts-ghc + extra-libraries: HSrts_l + ghc-options: -dynamic -shared -fPIC -dylib-install-name=ExampleModule diff --git a/example/haskell/stack.yaml b/example/haskell/stack.yaml new file mode 100644 index 0000000..bef51c2 --- /dev/null +++ b/example/haskell/stack.yaml @@ -0,0 +1,4 @@ +resolver: lts-12.4 +packages: +- . +- ../../HaPy-haskell From 9981d946e754f152f3205fd05637e3724bc9059b Mon Sep 17 00:00:00 2001 From: "Michal J. Gajda" Date: Tue, 31 Jul 2018 02:26:14 +0200 Subject: [PATCH 3/6] Added more troubleshooting information. --- HaPy-python/.gitignore | 2 ++ README.md | 7 ++++++- changelog | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 HaPy-python/.gitignore create mode 100644 changelog diff --git a/HaPy-python/.gitignore b/HaPy-python/.gitignore new file mode 100644 index 0000000..52e4e61 --- /dev/null +++ b/HaPy-python/.gitignore @@ -0,0 +1,2 @@ +*.pyc +*.pyo diff --git a/README.md b/README.md index 703aca6..5ff35c0 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,14 @@ Common Errors: * Error: `Missing C library: HSrts-ghc7.8.2` (or similar) --> The version of the GHC RTS library that you specified in your cabal file doesn't match the version of GHC you're running. * When running your Python project: * `Symbol not found: _stg_IND_STATIC_info` or `undefined symbol: stg_forkOnzh` --> The GHC RTS library isn't specified as one of the extra-libraries in the cabal file of your Haskell project. See the [General Installation and Usage](#os-xgeneral-installation-and-usage) section above. + * ImportError on HaPy --> You need to install HaPy Python library to your PYTHONPATH. + * Cannot find ExampleModule error --> You probably need to put libHSExampleModule*.dylib or .so on your path or in this directory by symlink: + ``` + $ ln -s `find ../ -iname '*.dylib'` . + ``` + * dlopen error on `_stg_*` symbol --> Please check that `extra-libs:` section in `../haskell/*.cabal` file contains proper GHC RTS library reference (name varies between GHC versions.) * Anything else: please make an issue and I'll take a look! - FAQ: ----- None yet! Feel free to start an issue if there's something you don't understand. diff --git a/changelog b/changelog new file mode 100644 index 0000000..200d063 --- /dev/null +++ b/changelog @@ -0,0 +1,2 @@ +0.1.1.3 Jul 30 2018 + * Update to GHC 8.4, and Stack LTS 11.2 From 3f8165a65ac30852ebe37ac27895eecbd668fd1f Mon Sep 17 00:00:00 2001 From: "Michal J. Gajda" Date: Tue, 31 Jul 2018 03:06:27 +0200 Subject: [PATCH 4/6] Bump up version number due to TemplateHaskell breaking change. --- HaPy-haskell/HaPy.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HaPy-haskell/HaPy.cabal b/HaPy-haskell/HaPy.cabal index a2adda4..0d593b0 100644 --- a/HaPy-haskell/HaPy.cabal +++ b/HaPy-haskell/HaPy.cabal @@ -1,5 +1,5 @@ name: HaPy -version: 0.1.1.3 +version: 0.2.0.0 synopsis: Haskell bindings for Python description: Call Haskell functions from Python! homepage: https://github.com/sakana/HaPy @@ -20,4 +20,4 @@ library c-sources: HaPy_init.c build-depends: base >= 4.5 && < 4.12, th-lift >= 0.5 && < 0.8, - template-haskell >= 2.7.0.0 && < 2.14.0.0 + template-haskell >= 2.11.0.0 && < 2.14.0.0 From 6cff807eca9d78772c6150aa16dfd8e54209f91f Mon Sep 17 00:00:00 2001 From: "Michal J. Gajda" Date: Tue, 31 Jul 2018 03:07:02 +0200 Subject: [PATCH 5/6] Update Example dependencies. --- example/haskell/ExampleModule.cabal | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/example/haskell/ExampleModule.cabal b/example/haskell/ExampleModule.cabal index 9ef7b5b..d719257 100644 --- a/example/haskell/ExampleModule.cabal +++ b/example/haskell/ExampleModule.cabal @@ -13,11 +13,14 @@ cabal-version: >=1.10 library exposed-modules: ExampleModule, Export other-extensions: ForeignFunctionInterface, TemplateHaskell - build-depends: base >=4.6 && <4.12, HaPy == 0.1.* + build-depends: base >=4.6 && <4.12, HaPy == 0.2.* default-language: Haskell2010 -- *** change this to your GHC version *** -- the make script will do this automatically --extra-libraries: HSrts-ghc - extra-libraries: HSrts_l - ghc-options: -dynamic -shared -fPIC -dylib-install-name=ExampleModule + --extra-libraries: HSrts_l + extra-libraries: HSrts + --ghc-options: -fPIC -pie -dynamic -shared -dylib-install-name=ExampleModule + ghc-options: -shared + -- Mac: -fPIC From 74b46bd600c30b207e3b0b8fc82c0ef3ad89f926 Mon Sep 17 00:00:00 2001 From: "Michal J. Gajda" Date: Mon, 19 Apr 2021 15:26:38 +0200 Subject: [PATCH 6/6] Bumped major version number. --- HaPy-haskell/HaPy.cabal | 2 +- HaPy-haskell/stack.yaml | 61 ----------------------------------------- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/HaPy-haskell/HaPy.cabal b/HaPy-haskell/HaPy.cabal index 0d593b0..3e248c3 100644 --- a/HaPy-haskell/HaPy.cabal +++ b/HaPy-haskell/HaPy.cabal @@ -1,5 +1,5 @@ name: HaPy -version: 0.2.0.0 +version: 0.3.0.0 synopsis: Haskell bindings for Python description: Call Haskell functions from Python! homepage: https://github.com/sakana/HaPy diff --git a/HaPy-haskell/stack.yaml b/HaPy-haskell/stack.yaml index 8e9fe75..98f23cb 100644 --- a/HaPy-haskell/stack.yaml +++ b/HaPy-haskell/stack.yaml @@ -1,64 +1,3 @@ -# This file was automatically generated by 'stack init' -# -# Some commonly used options have been documented as comments in this file. -# For advanced use and comprehensive documentation of the format, please see: -# https://docs.haskellstack.org/en/stable/yaml_configuration/ - -# Resolver to choose a 'specific' stackage snapshot or a compiler version. -# A snapshot resolver dictates the compiler version and the set of packages -# to be used for project dependencies. For example: -# -# resolver: lts-3.5 -# resolver: nightly-2015-09-21 -# resolver: ghc-7.10.2 -# -# The location of a snapshot can be provided as a file or url. Stack assumes -# a snapshot provided as a file might change, whereas a url resource does not. -# -# resolver: ./custom-snapshot.yaml -# resolver: https://example.com/snapshots/2018-01-01.yaml resolver: lts-12.4 - -# User packages to be built. -# Various formats can be used as shown in the example below. -# -# packages: -# - some-directory -# - https://example.com/foo/bar/baz-0.0.2.tar.gz -# - location: -# git: https://github.com/commercialhaskell/stack.git -# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# subdirs: -# - auto-update -# - wai packages: - . -# Dependency packages to be pulled from upstream that are not in the resolver -# using the same syntax as the packages field. -# (e.g., acme-missiles-0.3) -# extra-deps: [] - -# Override default flag values for local packages and extra-deps -# flags: {} - -# Extra package databases containing global packages -# extra-package-dbs: [] - -# Control whether we use the GHC we find on the path -# system-ghc: true -# -# Require a specific version of stack, using version ranges -# require-stack-version: -any # Default -# require-stack-version: ">=1.8" -# -# Override the architecture used by stack, especially useful on Windows -# arch: i386 -# arch: x86_64 -# -# Extra directories used by stack for building -# extra-include-dirs: [/path/to/dir] -# extra-lib-dirs: [/path/to/dir] -# -# Allow a newer minor version of GHC than the snapshot specifies -# compiler-check: newer-minor