grumpyhome / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
420 stars 18 forks source link

Build fails under pyenv: build/bin/grumpc: line 18: A Python -> Go transcompiler.: command not found #24

Closed alanjds closed 6 years ago

alanjds commented 6 years ago

I cloned grumpy and run method 1, but it cause error

➜  grumpy git:(master) echo "print 'hello, world'" | make run
build/src/grumpy/lib/__builtin__/module.go:1: syntax error: package statement must be first
make: *** [build/pkg/darwin_amd64/grumpy/lib/__builtin__.a] Error 1
alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 03:09 GMT


Can you paste the result of:

$ head build/src/grumpy/lib/__builtin__/module.go

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 03:11 GMT


here you are

➜  grumpy git:(master) head build/src/grumpy/lib/__builtin__/module.go
Version: ImageMagick 6.9.5-1 Q16 x86_64 2016-07-11 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules 
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
Usage: import [options ...] [ file ]

Image Settings:
  -adjoin              join images into a single multi-image file
  -border              include window border in the output image
alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 03:38 GMT


That's very odd. It looks like some random program has generated the module.go file, not grumpc, the Grumpy compiler. There must be something unexpected in your environment. I would suggest rm -rf build and then make run again.

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 04:12 GMT


Now I met error like it

➜  grumpy git:(master) rm -rf build
➜  grumpy git:(master) echo "print 'hello, world'" | make run
build/bin/grumpc: line 18: A Python -> Go transcompiler.: command not found
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.
from: can't read /var/mail/grumpy.compiler
from: can't read /var/mail/grumpy.compiler
from: can't read /var/mail/grumpy.compiler
build/bin/grumpc: line 30: syntax error near unexpected token `('
build/bin/grumpc: line 30: `parser = argparse.ArgumentParser()'
make: *** [build/src/grumpy/lib/__builtin__/module.go] Error 2
alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 04:21 GMT


import is screen shot command by imagemagick, looks like your shell doing something different.

Try git checkout 3adaa1a949115466e9ea204e4173e79ba8059870 before latest Makefile update. and try to make clean and make, to make sure that is not the case

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 04:24 GMT


Now it works! What's the problem?

➜  grumpy git:(master) git checkout 3adaa1a
Note: checking out '3adaa1a'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 3adaa1a... make itertools.chain be a class and from_iterable a classmethod of chain
➜  grumpy git:(3adaa1a) rm -rf build
➜  grumpy git:(3adaa1a) make clean
➜  grumpy git:(3adaa1a) echo "print 'hello, world'" | make run
hello, world
alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 04:32 GMT


@trotterdylan, Looks like there is some issue with recent Makefile changes. I can't think of which one though.

@growingdever , what is your python -V, python2 -V, env python -V?

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 04:33 GMT


I'm using pyenv. Global python, python2 version is 2.7.12

alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 04:38 GMT


@growingdever Could you paste the output of: $ head build/bin/grumpc

alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 04:43 GMT


Looks like shebang is lost, so may be another sed issue

grumpy% sh build/bin/grumpc
build/bin/grumpc: 18: build/bin/grumpc: A Python -> Go transcompiler.: not found
alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 04:44 GMT


➜  grumpy git:(3adaa1a) head build/bin/grumpc 
#!/usr/bin/env python
# coding=utf-8

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 04:44 GMT


What you get when you type /usr/bin/env python -V or /usr/bin/env python?

alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 04:47 GMT


@growingdever I meant what is $ head build/bin/grumpc at HEAD, when things are broken.

Thanks for your help debugging this.

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 04:48 GMT


➜  grumpy git:(3adaa1a) /usr/bin/env python -V
Python 2.7.12
alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 04:49 GMT


@S-YOU I think you're right that the shebang line is gone and it's being interpreted as a sh script.

alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 05:00 GMT


@trotterdylan,

His head output show there is still #!/usr/bin/env python and /usr/bin/env python -V correct though, I am not sure it something different under pyenv, virtualenv.

alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 05:01 GMT


@S-YOU But I think that shebang line is from 3adaa1a, before the Makefile change.

alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 05:02 GMT


I see, does make run change those shebang on the fly?

alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 05:08 GMT


make run depends on make all, which moves tools/grumpc -> build/bin/grumpc and changes the shebang.

alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 05:11 GMT


@growingdever , I think we need head build/bin/grumpc and /usr/bin/env python -V from master, not that commit.

Please do git checkout master and make clean, make, head build/bin/grumpc, /usr/bin/env python -V

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 05:13 GMT


make failed.

➜  grumpy git:(master) make clean
➜  grumpy git:(master) make
build/bin/grumpc: line 18: A Python -> Go transcompiler.: command not found
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.
import: delegate library support not built-in `' (X11) @ error/import.c/ImportImageCommand/1297.
from: can't read /var/mail/grumpy.compiler
from: can't read /var/mail/grumpy.compiler
from: can't read /var/mail/grumpy.compiler
build/bin/grumpc: line 30: syntax error near unexpected token `('
build/bin/grumpc: line 30: `parser = argparse.ArgumentParser()'
make: *** [build/src/grumpy/lib/__builtin__/module.go] Error 2
➜  grumpy git:(master) head build/bin/grumpc
#!/Users/juhongjung/.pyenv/shims/python
# coding=utf-8

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
➜  grumpy git:(master) /usr/bin/env python -V
Python 2.7.12
alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 05:17 GMT


how about ls -la ~/.pyenv/shims/python* and ~/.pyenv/shims/python -V

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 05:24 GMT


I don't configure any python versions for grumpy.

➜  grumpy git:(master) /usr/bin/env python -V
Python 2.7.12
➜  grumpy git:(master) ls -la ~/.pyenv/shims/python*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python-config*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python2*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python2-config*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python2.6*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python2.6-config*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python2.7*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python2.7-config*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python3*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python3-config*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python3.4*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python3.4-config*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python3.4m*
-rwxr-xr-x  1 juhongjung  staff   414B Jul 12  2016 /Users/juhongjung/.pyenv/shims/python3.4m-config*
➜  grumpy git:(master) ~/.pyenv/shims/python -V
Python 2.7.12
➜  grumpy git:(master) pyenv local
pyenv: no local version configured for this directory
➜  grumpy git:(master) pyenv version
2.7.12 (set by /Users/juhongjung/.pyenv/version)
alanjds commented 6 years ago

Comment by S-YOU Friday Jan 13, 2017 at 05:29 GMT


looks like those python binary are shell scripts 414B so, this is pyenv specific

@trotterdylan, may be instead of replacing the whole shebang, but just change python part to basename $(PYTHON_BIN)?

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 05:36 GMT


Yes. It's shell script.

➜  grumpy git:(master) cat ~/.pyenv/shims/python
#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x

program="${0##*/}"
if [[ "$program" = "python"* ]]; then
  for arg; do
    case "$arg" in
    -c* | -- ) break ;;
    */* )
      if [ -f "$arg" ]; then
        export PYENV_FILE_ARG="$arg"
        break
      fi
      ;;
    esac
  done
fi

export PYENV_ROOT="/Users/juhongjung/.pyenv"
exec "/Users/juhongjung/.pyenv/libexec/pyenv" exec "$program" "$@"
alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 05:38 GMT


If you have a system install of Python you might be able to work around this by specifying it as the PYTHON variable to make. First make clean, then make PYTHON=/usr/bin/python or make PYTHON=/usr/bin/python run

alanjds commented 6 years ago

Comment by toughrogrammer Friday Jan 13, 2017 at 05:42 GMT


Right. make works well with python path option.

alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 13, 2017 at 05:43 GMT


Thanks for reporting this. I think I'll need to try pyenv to reproduce this issue so I may not get around to it right away.

alanjds commented 6 years ago

Closing in favor of #25. It was imported correctly.