Skip to content

Instantly share code, notes, and snippets.

@jorgejesus
Created January 23, 2025 09:04
Show Gist options
  • Save jorgejesus/97790d3c78117c707fde5f0b68937f05 to your computer and use it in GitHub Desktop.
Save jorgejesus/97790d3c78117c707fde5f0b68937f05 to your computer and use it in GitHub Desktop.
mapscript build and wheels creation
# mapserver 8.4.0 and mapscript build for independ project install (pip)
# assuming mapserver, mapscript, gdal, proj dependies installed
# using pyenv for virtual env and python 3.13.1 install using pyenv
# This gist is copy paste from a README.md so never tested as full sequence bash
# Get mapserver code and set the pyenv python version to be used by mapserver (globally)
wget https://github.com/MapServer/MapServer/releases/download/rel-8-4-0/mapserver-8.4.0.tar.gz
tar -xvzf mapserver-8.4.0.tar.gz
cd mapserver-8.4.0
mkdir build && cd build
pyenv virtualenv 3.13.1 mapserver-313
pyenv local mapserver-313
pyenv shell mapserver-313
# A generic cmake, change it as needed
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DWITH_PROJ=ON -DWITH_OGR=ON -DWITH_GEOS=ON \
-DWITH_FRIBIDI=ON -DWITH_HARFBUZZ=ON \
-DWITH_CAIRO=ON -DWITH_WMS=ON -DWITH_WFS=ON \
-DWITH_WCS=ON -DWITH_CURL=ON \
-DWITH_THREAD_SAFETY=ON -DWITH_PYTHON=ON
cmake --build . --target all
sudo cmake --install .
sudo ldconfig
mapserv -v
# MapServer version 8.4.0 PROJ version 9.3 GDAL version 3.10
# OUTPUT=PNG OUTPUT=JPEG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE
# SUPPORTS=CAIRO SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER
# SUPPORTS=WFS_SERVER SUPPORTS=WCS_SERVER SUPPORTS=OGCAPI_SERVER SUPPORTS=FASTCGI
# SUPPORTS=THREADS SUPPORTS=GEOS SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS
# INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE INPUT=FLATGEOBUF
# the mapscript folder has build code but it just gives errors and problems,
# delete it and make a wheel
rm -rf src/mapscript/python/mapscript.egg-info
rm -rf src/mapscript/python/build
cmake --build . --target pythonmapscript-wheel
ls src/mapscript/python/dist/
# mapscript-8.4.0-cp313-cp313-linux_x86_64.whl
cp src/mapscript/python/dist/mapscript-8.4.0-cp313-cp313-linux_x86_64.whl ~/my-project/
# then on a project (my-project/mapserver-code) that will implement wheels
cd ~/my-project
pyenv virtualenv 3.13.1 my-project
pyenv local my-project
pyenv shell my-project
pyenv activate my-project
# my pyenv has some path problem, better to be certain
# hat we use the proper pip
pyenv which pip
# ~/.pyenv/versions/cc.mapserver-313/bin/pip
~/.pyenv/versions/cc.mapserver-313/bin/pip install mapscript-8.4.0-cp313-cp313-linux_x86_64.whl
# Testing
python -c "import mapscript; print(mapscript.msGetVersion())"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment