Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scons syntax error during brew installation #477

Closed
xianshiuci opened this issue Sep 26, 2017 · 12 comments
Closed

Scons syntax error during brew installation #477

xianshiuci opened this issue Sep 26, 2017 · 12 comments

Comments

@xianshiuci
Copy link

xianshiuci commented Sep 26, 2017

Cantera version

2.3.0

Operating System

macOS Sierra Version 10.12.6

Python/MATLAB version

MATLAB

I was following the official installation instruction of Cantera/macOS/MATLAB. When I executed the command "brew install cantera --without-test --with-matlab=/Applications/MATLAB_R2016a.app/", it outputs:

==> Installing cantera from homebrew/science
==> Downloading https://github.com/Cantera/cantera/archive/v2.3.0.tar.gz
==> Downloading from https://codeload.github.com/Cantera/cantera/tar.gz/v2.3.0
######################################################################## 100.0%
==> Downloading https://pypi.python.org/packages/2f/ae/0bb6ca970b949d97ca622641532d4a26395322172adaf645149ebef664eb/Cython
######################################################################## 100.0%
==> python -c import setuptools... --no-user-cfg install --prefix=/private/tmp/cantera-20170925-65966-1wz8h9j/cantera-2.3.
==> /usr/local/opt/scons/bin/scons build prefix=/usr/local/Cellar/cantera/2.3.0 python_package=full CC=/usr/bin/clang CXX=
Last 15 lines from /Users/Xian/Library/Logs/Homebrew/cantera/02.scons:
f90_interface=n
system_sundials=n
extra_inc_dirs=/usr/local/include/eigen3
matlab_path=/Applications/MATLAB_R2016a.app/
python3_package=n

scons: Reading SConscript files ...
  File "/private/tmp/cantera-20170925-65966-1wz8h9j/cantera-2.3.0/SConstruct", line 44

    print __doc__

                ^

SyntaxError: invalid syntax


READ THIS: https://docs.brew.sh/Troubleshooting.html

These open issues may also help:
Migrate most notable formulae to core https://github.com/Homebrew/homebrew-science/issues/6331
Siconos 4.0.0 (new formula) https://github.com/Homebrew/homebrew-science/pull/3755

It seems that Scons is not able to read the SConstruct file. I did some research and could not figure out why. Any experience regarding this issue?

@bryanwweber
Copy link
Member

It's possible that this has to do with SCons 3.0.0 (finally) supporting Python 3. Can you tell what version of SCons is installed, and what version of Python?

@bryanwweber
Copy link
Member

This has been noted on the official SCons Twitter: https://twitter.com/SConsProject/status/910235501269061632

@xianshiuci
Copy link
Author

Thanks @bryanwweber for figuring this out. Could you please guide me through how I can fix this issue? I am trying with "brew edit cantera" and it has not been any luck.

@bryanwweber
Copy link
Member

You need to make sure that SCons 2.5.1 is installed by brew, but I'm not sure how to do that. What version of SCons do you have installed (which scons and scons --version) and which version of Python are you using to do the install (which python and python --version)?

@xianshiuci
Copy link
Author

And yes. I installed Scons through Homebrew and the version is 3.0.0. And although I did not intend to build the Python3 version, when I "brew install cantera --with-matlab...." without "--with-python3", the python 3 was automatically added anyway.

I don't know whether this has forced Scons to use Python3 instead of Python2. I have Python2 installed and "which python" returns the brew installed python 2.7.14.

@bryanwweber
Copy link
Member

What do you mean the python 3 was added automatically? The configuration you posted shows that python3_package='n'...

@xianshiuci
Copy link
Author

OK. See the following output:

DN0a6251db:~ Xian$ pip install numpy
Requirement already satisfied: numpy in /usr/local/lib/python2.7/site-packages
DN0a6251db:~ Xian$ brew install cantera --with-matlab=/Applications/MATLAB_R2016a.app/
==> Installing cantera from homebrew/science
==> Installing dependencies for homebrew/science/cantera: numpy
==> Installing homebrew/science/cantera dependency: numpy
==> Installing dependencies for numpy: python3
==> Installing numpy dependency: python3
==> Downloading https://homebrew.bintray.com/bottles/python3-3.6.2.sierra.bottle.tar.gz

Two things:
1, As you can see, numpy has been already installed from "pip install numpy". When I try to install cantera, it asks again for numpy and then python3. That's what I mean by "python 3 was added automatically".
2. I wonder whether it has anything to do with Scons 3.0.0. I am looking into how I can reverse back to 2.5.1.

@xianshiuci
Copy link
Author

xianshiuci commented Sep 26, 2017

By the way, a recent update on Homebrew states that the python formula no longer shadows the system copy of Python and by default must be called as python2. This is mentioned in the caveats section when you install python from Homebrew:

This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.zshrc:
  export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Pip and setuptools have been installed. To update them
  pip2 install --upgrade pip setuptools

You can install Python packages with
  pip2 install <package>

With this change, the tutorial on macOS-Cantera-MATLAB seems to be obsolete. Since Homebrew will not overwrite the link for python, you can no longer change the default python from "/usr/bin/python" to "/usr/local/bin/python". Instead, in order to call Homebrew python, you have to "export PATH="/usr/local/opt/python/libexec/bin:$PATH" indicated in the caveats.

I am not sure whether this is related to the installation issue I have. Just want to give all the information I have so far. Now when I do "which python", it returns:

DN0a6251db:~ Xian$ which python
/usr/local/opt/python/libexec/bin/python

@xianshiuci
Copy link
Author

Hi @bryanwweber , I wonder whether you know how to add
2to3 --fix-print --write SConstruct
in the form of *.rb syntax to the brew installation script "brew edit cantera". If it works, it will convert the Cantera SConstruct to be readable by Scons 3.0.0. It may require specification of file location, etc..

This may be the easiest solution at this moment, as I cannot really get Scons 2.5.1 to work with Homebrew. The download link is not even working on Scons website.

@bryanwweber
Copy link
Member

Unfortunately, I don't have any experience with the Homebrew recipes. @speth will have to help out 😄 Sorry!

Your other option is to build from the source, which is all that Homebrew is doing anyways in this case. Follow the instructions starting here: http://cantera.org/docs/sphinx/html/compiling/installation-reqs.html#os-x-macos but rather than installing scons with Homebrew, install it with pip (just make sure it's the pip used by Python 2, you can do pip install scons=2.5.1 I think).

@speth
Copy link
Member

speth commented Sep 27, 2017

Print statements are only the beginning of getting Cantera's build scripts to work with SCons 3.0. The workaround for the time being will certainly need to be building from source with an older version of SCons, not using Homebrew.

@xianshiuci
Copy link
Author

Thanks for the help @bryanwweber @speth . Yeah I have tried pip install scons==2.5.1 but then Homebrew would try to overwrite it. I guess the direct compilation is the only option at this moment. I will explore how it can be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants