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

Installing Pandana in MacOS 10.15 Catalina #129

Closed
2 tasks done
smmaurer opened this issue Oct 23, 2019 · 7 comments
Closed
2 tasks done

Installing Pandana in MacOS 10.15 Catalina #129

smmaurer opened this issue Oct 23, 2019 · 7 comments

Comments

@smmaurer
Copy link
Member

smmaurer commented Oct 23, 2019

Here are some tips for installing Pandana in MacOS 10.15 Catalina.

Existing installation instructions: http://udst.github.io/pandana/installation.html

Conda

conda install pandana worked for me.

Pip / local compilation

You need to reinstall Command Line Tools, even if you had them before updating to Catalina:
xcode-select --install

Single-threaded (using built-in compiler)

This is failing for me. The conditional in setup.py#L72 is always evaluating to True because of whitespace in the string from the OS, so the -fopenmp flag is added when it shouldn't be.

The fix is to use os.popen('which clang').read().strip(). This lets single-threaded installation succeed on my machine.

Multi-threaded (using Conda toolchain)

The C++ header files are in a new location in Catalina. We don't have to install them separately any more, but we do have to make sure the compilation toolchain can see them.

What eventually worked for me was to replace 'clang' in setup.py#L73 with the following:

'clang --sysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

Fixes for next release

  • update the setup.py#L72 conditional to strip whitespace
  • add a conditional checking for MacOS 10.15 and then adding the --sysroot argument in setup.py#L73
@martjanz
Copy link
Contributor

martjanz commented Nov 7, 2019

Same issue here. My local solution was:

I think enforcing CC on setup.py can be limiting to those who want to specify its own clang binaries. openmp is not supported on default MacOS clang.

@smmaurer
Copy link
Member Author

smmaurer commented Nov 12, 2019

@martjanz Thanks, this is a good point. On my machine it looks like the CC environment variable is empty by default, so we could use the following flow:

  • which clang == /usr/bin/clang

    • system clang, don't use openmp flags
  • which clang != /usr/bin/clang, and CC is empty

    • assume they've installed clang from conda
    • set CC to that one (which is what L73 is doing currently)
    • include the openmp flags
  • otherwise

    • leave CC as whatever they've set it to
    • include the openmp flags

This would give people the flexibility to use whatever compiler they want, if they set the environment variable before running setup.py. But it would keep things simple if they're using the conda toolchain. What do you think?

Also, do you know if setting CXX is actually necessary? I didn't seem to need it with conda's clang.

More to-dos:

  • implement the logic above
  • add comment to the documentation about optionally setting CC
  • add some logging to setup.py explaining which compiler and flags are being used, which should help with diagnosing installation problems

@kymok
Copy link

kymok commented Dec 29, 2019

Hello,

Thank you, I've suceeded to install with your helpful information (I followed @martjanz 's method).
In my case I also needed to modify following line as follows:

https://github.com/UDST/pandana/blob/master/setup.py#L65

# os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.14'

@smmaurer
Copy link
Member Author

smmaurer commented Feb 2, 2020

Adding to this thread..

I needed to install an older version of Pandana on my Mac that's running Catalina, and had a lot of trouble. The pip binaries for Pandana 0.3 won't install, and the build scripts don't work either.

We should probably look into this a little more, and put out a maintenance update for Pandana 0.3 as well. A lot of people still use it.

  • maintenance update so that Pandana v0.3 can be installed in Catalina

What eventually worked for me was to add these arguments to the MacOS build logic in setup.py#L87 of v0.3, mirroring updates that we made in v0.4:

    os.environ['CC'] = 'clang --sysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
    extra_compile_args += ['-D NO_TR1_MEMORY', '-stdlib=libc++']
    extra_link_args += ['-stdlib=libc++']

This StackOverflow answer explains why the sysroot has to be changed for Catalina: https://stackoverflow.com/questions/58278260/cant-compile-a-c-program-on-a-mac-after-upgrading-to-catalina-10-15/58278392#58278392

I still don't feel like I have a complete understanding of what's going on, like why the older binaries don't work anymore. And @cvanoli reported similar problems in MacOS 10.14 Mojave recently, so these changes may not be tied strictly to the OS version.

@smmaurer
Copy link
Member Author

smmaurer commented Jun 7, 2020

PR #137 resolves this in the dev build of Pandana, to be released on pip/conda soon.

I feel like it's probably not worth going back and patching earlier versions so they can compile in MacOS 10.15 Catalina. But I'll leave this issue open and we can revisit if needed.

@zippau
Copy link

zippau commented Jul 12, 2020

PR #137 resolves this in the dev build of Pandana, to be released on pip/conda soon.

I feel like it's probably not worth going back and patching earlier versions so they can compile in MacOS 10.15 Catalina. But I'll leave this issue open and we can revisit if needed.

@smmaurer is there any update to when it will be released on pip/conda? Or advice on how to install the package on MacOS 10.15 without the technical capabilities to compile locally?

@smmaurer
Copy link
Member Author

Hi @zippau, this should be released next week!

But I think only pip install and installations from the GitHub source code were affected by this -- conda install should work fine in MacOS 10.15 even without the fix.

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

No branches or pull requests

5 participants