summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Command/Commands.hs9
-rw-r--r--src/compiler/GF/Main.hs2
-rw-r--r--src/compiler/GF/Text/Coding.hs2
-rw-r--r--src/runtime/haskell-bind/pgf2.cabal2
-rw-r--r--src/runtime/haskell/Data/Binary/Get.hs2
-rw-r--r--src/runtime/haskell/pgf.cabal2
-rw-r--r--src/runtime/python/README.org152
-rw-r--r--src/www/index.html2
8 files changed, 167 insertions, 6 deletions
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs
index 2f2e802e0..a6c66594f 100644
--- a/src/compiler/GF/Command/Commands.hs
+++ b/src/compiler/GF/Command/Commands.hs
@@ -4,6 +4,7 @@ module GF.Command.Commands (
options,flags,
) where
import Prelude hiding (putStrLn,(<>)) -- GHC 8.4.1 clash with Text.PrettyPrint
+import System.Info(os)
import PGF
@@ -882,11 +883,15 @@ pgfCommands = Map.fromList [
Right ty -> ty
Nothing -> error ("Can't parse '"++str++"' as a type")
optViewFormat opts = valStrOpts "format" "png" opts
- optViewGraph opts = valStrOpts "view" "open" opts
+ optViewGraph opts = valStrOpts "view" open_cmd opts
optNum opts = valIntOpts "number" 1 opts
optNumInf opts = valIntOpts "number" 1000000000 opts ---- 10^9
takeOptNum opts = take (optNumInf opts)
+ open_cmd | os == "linux" = "xdg-open"
+ | os == "mingw32" = "start"
+ | otherwise = "open"
+
returnFromExprs es = return $ case es of
[] -> pipeMessage "no trees found"
_ -> fromExprs es
@@ -1022,4 +1027,4 @@ stanzas = map unlines . chop . lines where
#if !(MIN_VERSION_base(4,9,0))
errorWithoutStackTrace = error
-#endif \ No newline at end of file
+#endif
diff --git a/src/compiler/GF/Main.hs b/src/compiler/GF/Main.hs
index 7d4500c7b..1b90430d6 100644
--- a/src/compiler/GF/Main.hs
+++ b/src/compiler/GF/Main.hs
@@ -16,6 +16,7 @@ import Data.Version
import System.Directory
import System.Environment (getArgs)
import System.Exit
+import GHC.IO.Encoding
-- import GF.System.Console (setConsoleEncoding)
-- | Run the GF main program, taking arguments from the command line.
@@ -23,6 +24,7 @@ import System.Exit
-- Run @gf --help@ for usage info.
main :: IO ()
main = do
+ setLocaleEncoding utf8
-- setConsoleEncoding
uncurry mainOpts =<< getOptions
diff --git a/src/compiler/GF/Text/Coding.hs b/src/compiler/GF/Text/Coding.hs
index bac7938c0..2a89427fe 100644
--- a/src/compiler/GF/Text/Coding.hs
+++ b/src/compiler/GF/Text/Coding.hs
@@ -38,7 +38,7 @@ decodeUnicode :: TextEncoding -> ByteString -> String
decodeUnicode enc bs = unsafePerformIO $ decodeUnicodeIO enc bs
decodeUnicodeIO enc (PS fptr l len) = do
- let bbuf = Buffer{bufRaw=fptr, bufState=ReadBuffer, bufSize=len, bufL=l, bufR=l+len}
+ let bbuf = (emptyBuffer fptr len ReadBuffer) { bufL=l, bufR=l+len }
cbuf <- newCharBuffer 128 WriteBuffer
case enc of
TextEncoding {mkTextDecoder=mk} -> do decoder <- mk
diff --git a/src/runtime/haskell-bind/pgf2.cabal b/src/runtime/haskell-bind/pgf2.cabal
index 1d5f61991..83c990bf3 100644
--- a/src/runtime/haskell-bind/pgf2.cabal
+++ b/src/runtime/haskell-bind/pgf2.cabal
@@ -26,7 +26,7 @@ library
PGF2.Expr,
PGF2.Type
build-depends:
- base >= 4.9.1 && < 4.15,
+ base >= 4.9.1 && < 4.16,
containers >= 0.5.7 && < 0.7,
pretty >= 1.1.3 && < 1.2
default-language: Haskell2010
diff --git a/src/runtime/haskell/Data/Binary/Get.hs b/src/runtime/haskell/Data/Binary/Get.hs
index 54f17ae95..895789061 100644
--- a/src/runtime/haskell/Data/Binary/Get.hs
+++ b/src/runtime/haskell/Data/Binary/Get.hs
@@ -1,4 +1,6 @@
{-# LANGUAGE CPP, MagicHash #-}
+-- This module makes profiling a lot slower, so don't add automatic cost centres
+{-# OPTIONS_GHC -fno-prof-auto #-}
-- for unboxed shifts
-----------------------------------------------------------------------------
diff --git a/src/runtime/haskell/pgf.cabal b/src/runtime/haskell/pgf.cabal
index 41e67f6ae..cb5841a1c 100644
--- a/src/runtime/haskell/pgf.cabal
+++ b/src/runtime/haskell/pgf.cabal
@@ -15,7 +15,7 @@ library
default-language: Haskell2010
build-depends:
array >= 0.5.1 && < 0.6,
- base >= 4.9.1 && < 4.15,
+ base >= 4.9.1 && < 4.16,
bytestring >= 0.10.8 && < 0.11,
containers >= 0.5.7 && < 0.7,
ghc-prim >= 0.5.0 && < 0.7,
diff --git a/src/runtime/python/README.org b/src/runtime/python/README.org
new file mode 100644
index 000000000..86584dc01
--- /dev/null
+++ b/src/runtime/python/README.org
@@ -0,0 +1,152 @@
+* INSTALL
+
+You will need the python-devel package or similar.
+
+You must have installed the PGF C runtime (see ../c/INSTALL)
+
+#+begin_src sh
+ $ python setup.py build
+ $ sudo python setup.py install
+#+end_src
+
+* Apple Silicon
+
+The following install instructions were written with the following config in mind:
+
+| OS | Hardware | GF |
+|-----------------------+----------+--------------------------+
+| MacOS Monterey 12.2.1 | Apple M1 | 3.11 from binary package |
+
+We assume that you may have installed GF as a binary package downloaded from Github.
+
+From that starting point, try all the solutions below, in sequence, until you achieve success.
+
+** Validation Goal
+
+Our goal is to be able to
+- run python 3
+- import pgf
+- type "pgf."
+- hit tab
+
+and get this:
+
+#+begin_example
+ >>> import pgf
+ >>> pgf.
+ pgf.BIND( pgf.Concr( pgf.Iter( pgf.PGFError( pgf.Type( pgf.readExpr( pgf.readType(
+ pgf.Bracket( pgf.Expr( pgf.PGF( pgf.ParseError( pgf.TypeError( pgf.readPGF(
+#+end_example
+
+When that works, we can consider the Python PGF bindings to be installed successfully.
+
+** The GF binary package won't install
+
+We assume you've tried [[https://github.com/GrammaticalFramework/gf-core/releases][downloading a binary package]].
+
+If MacOS is being secure, go to System Preferences, Security & Privacy, General, and click Open Anyway.
+
+** gu/mem.h file not found
+
+Maybe you tried running something like ~pip install pgf~ or ~pip3 install pgf~.
+
+Did you get this error?
+
+#+begin_example
+ python3 setup.py build
+ running build
+ running build_ext
+ creating build/temp.macosx-12-arm64-3.9
+ clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c pypgf.c -o build/temp.macosx-12-arm64-3.9/pypgf.o -std=c99
+ pypgf.c:5:10: fatal error: 'gu/mem.h' file not found
+ #include <gu/mem.h>
+ ^~~~~~~~~~
+ 1 error generated.
+ error: command '/usr/bin/clang' failed with exit code 1
+#+end_example
+
+Solution:
+
+#+begin_example
+ $ EXTRA_INCLUDE_DIRS=/usr/local/include EXTRA_LIB_DIRS=/usr/local/lib pip install pgf
+#+end_example
+
+This should tell the build where to find the include and lib files it needs to compile:
+
+#+begin_example
+ $ ls /usr/local/include/gu
+ assert.h choice.h enum.h file.h hash.h map.h out.h seq.h sysdeps.h utf8.h
+ bits.h defs.h exn.h fun.h in.h mem.h prime.h string.h ucs.h variant.h
+
+ $ ls /usr/local/lib/libgu*
+ /usr/local/lib/libgu.0.dylib /usr/local/lib/libgu.a /usr/local/lib/libgu.dylib /usr/local/lib/libgu.la
+#+end_example
+
+If those files don't exist, or you get the following error, you will need to rebuild the C runtime.
+
+** symbol not found in flat namespace
+
+Did you get this error?
+
+#+begin_example
+ Python 3.9.10 (main, Jan 15 2022, 11:40:53)
+ [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
+ Type "help", "copyright", "credits" or "license" for more information.
+ >>> import pgf
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/pgf.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_gu_alloc_variant'
+#+end_example
+
+This may be a sign that you're trying to get binaries and libraries compiled with different compilers to play nicely. We're trying to get three things to align:
+
+- the Python interpreter
+- the C runtime libraries
+- the Python pgf libraries
+
+Solution:
+
+Maybe your Python isn't the Apple-provided Python. In the above error message we see ~python3~ is provided by Homebrew. Assuming you prefer to keep things this way, we'll try to rebuild things to match your Python.
+
+Rebuilding needs a C compiler. The Apple-provided system ~clang~ is preferred. If you have multiple ~clang~ compilers installed, try disabling the others. For example, if your ~clang~ was provided by nix, run ~nix-env --uninstall clang~. Similarly for brew.
+
+Then try rebuilding the C runtime.
+
+** How to re-build the C runtime
+
+Maybe the C runtime is missing from ~/usr/local/lib~, or maybe the version you have installed is causing the "symbol not found" error.
+
+Build the C runtime by following the instructions in ~gf-core/src/runtime/c/INSTALL~.
+
+After a successful ~make install~, rebuild the Python bindings.
+
+** How to re-build the Python bindings using pip
+
+Sometimes a ~pip install pgf~ will decline to recompile, because a cached wheel exists.
+
+To return to a more pristine state,
+
+#+begin_example
+ pip uninstall pgf
+ pip cache remove pgf
+#+end_example
+
+You may need to ~sudo~ some of the above commands.
+
+Then you can repeat
+
+#+begin_example
+ $ EXTRA_INCLUDE_DIRS=/usr/local/include EXTRA_LIB_DIRS=/usr/local/lib pip install pgf
+#+end_example
+
+** How to re-build the Python bindings manually
+
+If the ~pip install pgf~ just isn't working, try building it directly in ~gf-core/src/runtime/python~:
+
+#+begin_example
+ $ python setup.py build
+ $ sudo python setup.py install
+#+end_example
+
+You may need to add the ~EXTRA~ environment prefixes as shown in previous commands.
+
diff --git a/src/www/index.html b/src/www/index.html
index c660d4055..425c134ef 100644
--- a/src/www/index.html
+++ b/src/www/index.html
@@ -22,7 +22,7 @@
(bilingual document editor)
<!--<li><a href="wc.html">Wide Coverage Translation Demo</a>-->
<li><a href="gfmorpho/">Word inflection with smart paradigms</a>
- <li><a href="https://cloud.grammaticalframework.org/wordnet">GF WordNet</a> (an online browser and editor for the WordNet lexicon)</li>
+ <li><a href="wordnet/">GF WordNet</a> (an online browser and editor for the WordNet lexicon)</li>
</ul>
<h2>Documentation</h2>