UDST / pandana

Pandas Network Analysis by UrbanSim: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:
http://udst.github.io/pandana
GNU Affero General Public License v3.0
386 stars 84 forks source link

Installing Pandana in MacOS 10.15 Catalina #129

Closed smmaurer closed 4 years ago

smmaurer commented 4 years ago

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

martjanz commented 4 years ago

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 commented 4 years ago

@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:

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:

kymok commented 4 years ago

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 commented 4 years ago

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.

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.