enzet / map-machine

Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
MIT License
503 stars 31 forks source link

Problem installing on MacOS 12.5.1 #142

Closed jmizv closed 1 year ago

jmizv commented 2 years ago

I've followed the guide but when doing

pip install git+https://github.com/enzet/map-machine 

it gives:

Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.9/site-packages (from packaging->pytest>=6.2.2->map-machine==0.1.7) (3.0.9)
Collecting pycparser
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Building wheels for collected packages: map-machine, pycairo
  Building wheel for map-machine (setup.py) ... done
  Created wheel for map-machine: filename=map_machine-0.1.7-py3-none-any.whl size=333798 sha256=134e042bae68245edf8695960775b193b4ef6614de9993751d6e0c63117cab01
  Stored in directory: /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-ephem-wheel-cache-zcfaglk1/wheels/51/bc/a0/2848bfb9dca60648426211589d4840a81e192d7b5eb70770cd
  Building wheel for pycairo (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pycairo (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-11-x86_64-cpython-39
      creating build/lib.macosx-11-x86_64-cpython-39/cairo
      copying cairo/__init__.py -> build/lib.macosx-11-x86_64-cpython-39/cairo
      copying cairo/__init__.pyi -> build/lib.macosx-11-x86_64-cpython-39/cairo
      copying cairo/py.typed -> build/lib.macosx-11-x86_64-cpython-39/cairo
      running build_ext
      building 'cairo._cairo' extension
      creating build/temp.macosx-11-x86_64-cpython-39
      creating build/temp.macosx-11-x86_64-cpython-39/cairo
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -DPYCAIRO_VERSION_MAJOR=1 -DPYCAIRO_VERSION_MINOR=21 -DPYCAIRO_VERSION_MICRO=0 -I/usr/local/Cellar/libffi/3.4.2/include -I/usr/local/Cellar/cairo/1.16.0_5/include/cairo -I/usr/local/Cellar/glib/2.72.2/include -I/usr/local/Cellar/glib/2.72.2/include/glib-2.0 -I/usr/local/Cellar/glib/2.72.2/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.45/include -I/usr/local/Cellar/pixman/0.40.0/include/pixman-1 -I/usr/local/Cellar/fontconfig/2.14.0/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/libpng/1.6.37/include/libpng16 -I/usr/local/Cellar/libxcb/1.15/include -I/usr/local/Cellar/libxrender/0.9.10/include -I/usr/local/Cellar/libxext/1.3.4/include -I/usr/local/Cellar/libx11/1.8.1/include -I/usr/local/Cellar/libxcb/1.15/include -I/usr/local/Cellar/libxau/1.0.9/include -I/usr/local/Cellar/libxdmcp/1.1.3/include -I/usr/local/Cellar/xorgproto/2022.1/include -I/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c cairo/bufferproxy.c -o build/temp.macosx-11-x86_64-cpython-39/cairo/bufferproxy.o -Wall -Warray-bounds -Wcast-align -Wconversion -Wextra -Wformat=2 -Wformat-nonliteral -Wformat-security -Wimplicit-function-declaration -Winit-self -Winline -Wmissing-format-attribute -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-arith -Wreturn-type -Wshadow -Wsign-compare -Wstrict-aliasing -Wundef -Wswitch-default -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-command-line-argument -fno-strict-aliasing -fvisibility=hidden -std=c99
      clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11'
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycairo
Successfully built map-machine
Failed to build pycairo
ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
WARNING: There was an error checking the latest version of pip.

Not sure where I have control over the parameter MACOSX_DEPLOYMENT_TARGET? Do I need to increse it to 12?

enzet commented 2 years ago

Hi, @jmizv!

Looks like this is an Xcode—clang-related issue, which I'm not familiar with.

Not sure where I have control over the parameter MACOSX_DEPLOYMENT_TARGET? Do I need to increse it to 12?

Some guys on Stack Overflow recommend this. Some also recommend export SYSTEM_VERSION_COMPAT=1. At least changing environment variables seems safe.

enzet commented 2 years ago

Could you please tell me, how you plan to use the project? If you are OK with SVG images and are not going to generate PNG tiles, I may create a special branch without cairo dependency. What do you think?

jmizv commented 1 year ago

Hi @enzet, thanks for reaching out. I'm not really sure how to use the project. I was just curios and tried to experiment with it. No real goal. So let me try your suggestions with the env variable.

enzet commented 1 year ago

Hey, @jmizv!

I've created a branch no-cairo without cairo dependency. This version of Map Machine does not support PNG tile generation (i.e., tile and server commands) but supports SVG file generation (i.e., render command) and everything else from the standard Map Machine version.

All you need to try this version is to add @no-cairo to the pip install command:

pip install git+https://github.com/enzet/map-machine@no-cairo

This version however still depends on GEOS library. Please, check whether there will be any problems with this.

Hope this will help.

jmizv commented 1 year ago

Hi @enzet thanks! I've tried your suggestion but it does not seem successful:

user@MB IdeaProjects % pip3 install git+https://github.com/enzet/map-machine@no-cairo
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting git+https://github.com/enzet/map-machine@no-cairo
  Cloning https://github.com/enzet/map-machine (to revision no-cairo) to /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-req-build-u__r1z4o
  Running command git clone --filter=blob:none --quiet https://github.com/enzet/map-machine /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-req-build-u__r1z4o
  Running command git checkout -b no-cairo --track origin/no-cairo
  Zu neuem Branch 'no-cairo' gewechselt
  Branch 'no-cairo' folgt nun Remote-Branch 'no-cairo' von 'origin'.
  Resolved https://github.com/enzet/map-machine to commit 40186aa736c7df52171584bfa39401ab670d9bcd
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      running egg_info
      creating /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-pip-egg-info-6o_inrdt/map_machine.egg-info
      writing /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-pip-egg-info-6o_inrdt/map_machine.egg-info/PKG-INFO
      writing dependency_links to /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-pip-egg-info-6o_inrdt/map_machine.egg-info/dependency_links.txt
      writing entry points to /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-pip-egg-info-6o_inrdt/map_machine.egg-info/entry_points.txt
      writing requirements to /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-pip-egg-info-6o_inrdt/map_machine.egg-info/requires.txt
      writing top-level names to /private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-pip-egg-info-6o_inrdt/map_machine.egg-info/top_level.txt
      writing manifest file '/private/var/folders/_b/_n1p01v12_d0vjn_s33_whv80000gn/T/pip-pip-egg-info-6o_inrdt/map_machine.egg-info/SOURCES.txt'
      error: package directory 'map_machine/slippy' does not exist
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
enzet commented 1 year ago

Sorry, my bad. I forgot to remove a package from setup.py. It is fixed now. Could you please try one more time?

You may need to run pip uninstall map-machine if it was partially installed.

jmizv commented 1 year ago

Hi @enzet thanks, now it seems to have worked. At least the install command succeeded without error.

And even better:

user@MB IdeaProjects % map-machine render -b=2.284,48.860,2.290,48.865
INFO Getting https://api.openstreetmap.org/api/0.6/map...
INFO Constructing ways...
INFO Constructing nodes...
INFO Drawing ways...
INFO Drawing main icons...
INFO Drawing extra icons...
INFO Drawing texts...
INFO Writing output SVG to out/map.svg...

This gave me a really nice SVG file. Thanks for your efforts 👍 I'm more than fine for the moment without any PNG support here.

enzet commented 1 year ago

Wonderful! Thank you for the issue. I supposed, that libraries could become a problem.