Skip to content

Cloud Foundry buildpack for the Python Language with extensions for Pillow

License

Notifications You must be signed in to change notification settings

springernature/python-pillow-buildpack

 
 

Repository files navigation

Cloud Foundry Python Buildpack with Pillow support libraries

This is a fork of the Cloudfoundry Python Buildpack that adds extra libraries for more complete Pillow/Pillow-SIMD support.

We've also added libexiv2 and libboost-python in order to support py3exiv2, for image metadata manipulation.

You can use this via:

cf push my_app -b https://github.com/springernature/python-pillow-buildpack

Genereration of library binaries

libwebp

The bundle libwebp was built on an Ubuntu 18.04.5 VM:

sudo apt install build-essential autoconf libtool
WEBP_VERSION=1.2.1
curl -Lso- https://github.com/webmproject/libwebp/archive/v$WEBP_VERSION.tar.gz | tar xzf -
cd libwebp-$WEBP_VERSION
./autogen.sh
./configure --prefix=/home/vcap/deps/0/libwebp && make
sudo rm -rf /home/vcap/deps/0/libwebp
sudo make install
tar czvf libwebp-$WEBP_VERSION-cflinuxfs3.tgz -C /home/vcap/deps/0/libwebp .

libexiv2

Steps to generate the included exiv2-0.27.5-cflinuxfs3.tgz (carried out in an Ubuntu 18.04.6):

Download and decompress sources (Exiv2 Download page).

vagrant@vagrant:~/dev$ wget https://github.com/Exiv2/exiv2/releases/download/v0.27.5/exiv2-0.27.5-Source.tar.gz
[...]
vagrant@vagrant:~/dev$ sha256sum exiv2-0.27.5-Source.tar.gz 
35a58618ab236a901ca4928b0ad8b31007ebdc0386d904409d825024e45ea6e2  exiv2-0.27.5-Source.tar.gz
vagrant@vagrant:~/dev$ tar xf exiv2-0.27.5-Source.tar.gz 
vagrant@vagrant:~/dev$ cd exiv2-0.27.5-Source/

Follow Exiv2 instructions for compiling for Linux:

vagrant@vagrant:~/dev/exiv2-0.27.5-Source$ sudo apt --yes update
[...]
vagrant@vagrant:~/dev/exiv2-0.27.5-Source$ sudo apt install --yes build-essential git clang ccache python3 libxml2-utils cmake python3 libexpat1-dev libz-dev zlib1g-dev libssh-dev libcurl4-openssl-dev libgtest-dev google-mock
vagrant@vagrant:~/dev/exiv2-0.27.5-Source$ mkdir build ; cd build ;
vagrant@vagrant:~/dev/exiv2-0.27.5-Source/build$ cmake -DCMAKE_INSTALL_PREFIX=$PWD/../target .. -G "Unix Makefiles"
[...]
-- ------------------------------------------------------------------
-- CMake Generator:   Unix Makefiles
-- CMAKE_BUILD_TYPE:  
-- Compiler info: GNU (/usr/bin/c++) ; version: 7.5.0
-- CMAKE_CXX_STANDARD:
--  --- Compiler flags --- 
-- General:           
	 -fstack-protector-strong
	 -Wp,-D_GLIBCXX_ASSERTIONS
	 -Wall
	 -Wcast-align
	 -Wpointer-arith
	 -Wformat-security
	 -Wmissing-format-attribute
	 -Woverloaded-virtual
	 -W
-- Extra:              
-- Debug:             -g3 -gstrict-dwarf -O0
-- Release:           -O3 -DNDEBUG
-- RelWithDebInfo:    -O2 -g -DNDEBUG
-- MinSizeRel:        -Os -DNDEBUG
--  --- Linker flags --- 
-- General:           
-- Debug:             
-- Release:           
-- RelWithDebInfo:    
-- MinSizeRel:        
-- 
-- Compiler Options
-- Warnings as errors:                 NO
-- Use extra compiler warning flags:   NO
-- 
-- ------------------------------------------------------------------
-- Building shared library:            YES
-- Building PNG support:               YES
-- XMP metadata support:               YES
-- Building BMFF support:              NO
-- Native language support:            NO
-- Conversion of Windows XP tags:      YES
-- Nikon lens database:                YES
-- Building video support:             NO
-- Building webready support:          NO
-- Building exiv2 command:             YES
-- Building samples:                   YES
-- Building unit tests:                NO
-- Building doc:                       NO
-- Building with coverage flags:       NO
-- Using ccache:                       NO
[...]
vagrant@vagrant:~/dev/exiv2-0.27.5-Source/build$ make
[...]
vagrant@vagrant:~/dev/exiv2-0.27.5-Source/build$ make install
[...]
vagrant@vagrant:~/dev/exiv2-0.27.5-Source/build$ tar czvf exiv2-0.27.5-cflinuxfs3.tgz -C ../target .
[...]
vagrant@vagrant:~/dev/exiv2-0.27.5-Source/build$ sha256sum exiv2-0.27.5-cflinuxfs3.tgz 
0803f8152b8e176ab5b5aeb0c305f70c3ba25c67cc4e2cebba8d10ed14ef40f4  exiv2-0.27.5-cflinuxfs3.tgz
vagrant@vagrant:~/dev/exiv2-0.27.5-Source/build$ 

libboost-python

vagrant@vagrant:~/dev$ wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz
[...]
vagrant@vagrant:~/dev$ sha256sum boost_1_80_0.tar.gz 
4b2136f98bdd1f5857f1c3dea9ac2018effe65286cf251534b6ae20cc45e1847  boost_1_80_0.tar.gz
vagrant@vagrant:~/dev$ tar xf boost_1_80_0.tar.gz
vagrant@vagrant:~/dev$ cd boost_1_80_0/
vagrant@vagrant:~$ sudo apt install build-essential software-properties-common 
[...]
vagrant@vagrant:~$ sudo add-apt-repository ppa:deadsnakes/ppa
[...]
vagrant@vagrant:~$ sudo apt install python3.10-dev
[...]
vagrant@vagrant:~/dev/boost_1_80_0$ ./bootstrap.sh --prefix=$PWD/../boost-target --with-python-version=3.10 --with-python=/usr/bin/python3.10
[...]
vagrant@vagrant:~/dev/boost_1_80_0$ ./b2 --with-python install
Performing configuration checks

    - default address-model    : 64-bit [1]
    - default architecture     : x86 [1]

[1] gcc-7

Component configuration:

    - atomic                   : not building
    - chrono                   : not building
    - container                : not building
    - context                  : not building
    - contract                 : not building
    - coroutine                : not building
    - date_time                : not building
    - exception                : not building
    - fiber                    : not building
    - filesystem               : not building
    - graph                    : not building
    - graph_parallel           : not building
    - headers                  : not building
    - iostreams                : not building
    - json                     : not building
    - locale                   : not building
    - log                      : not building
    - math                     : not building
    - mpi                      : not building
    - nowide                   : not building
    - program_options          : not building
    - python                   : building
    - random                   : not building
    - regex                    : not building
    - serialization            : not building
    - stacktrace               : not building
    - system                   : not building
    - test                     : not building
    - thread                   : not building
    - timer                    : not building
    - type_erasure             : not building
    - wave                     : not building

...patience...
[...]
vagrant@vagrant:~/dev/boost_1_80_0$ tar czvf libboost-python-1.80.0-cflinuxfs3.tgz -C ../boost-target .
[...]
vagrant@vagrant:~/dev/boost_1_80_0$ sha256sum libboost-python-1.80.0-cflinuxfs3.tgz 
8e08c79067c7116107f4b16aafb98aae6d1f1b63e8d582048fa914b565f143b9  libboost-python-1.80.0-cflinuxfs3.tgz

Cloud Foundry Python Buildpack

CF Slack Join us on Slack

A Cloud Foundry buildpack for Python based apps.

This buildpack supports running Django and Flask apps.

Buildpack User Documentation

Official buildpack documentation can be found at python buildpack docs.

Building the Buildpack

To build this buildpack, run the following commands from the buildpack's directory:

  1. Source the .envrc file in the buildpack directory.

    source .envrc

    To simplify the process in the future, install direnv which will automatically source .envrc when you change directories.

  2. Install buildpack-packager

    go install github.com/cloudfoundry/libbuildpack/packager/buildpack-packager
  3. Build the buildpack

    buildpack-packager build [ --cached=(true|false) ]
  4. Use in Cloud Foundry

    Upload the buildpack to your Cloud Foundry and optionally specify it by name

    cf create-buildpack [BUILDPACK_NAME] [BUILDPACK_ZIP_FILE_PATH] 1
    cf push my_app [-b BUILDPACK_NAME]

Testing

Buildpacks use the Cutlass framework for running integration tests.

To test this buildpack, run the following commands from the buildpack's directory:

  1. Source the .envrc file in the buildpack directory.

    source .envrc

    To simplify the process in the future, install direnv which will automatically source .envrc when you change directories.

  2. Run unit tests

    ./scripts/unit.sh
  3. Run integration tests

    Buildpacks use the Cutlass framework for running integration tests against Cloud Foundry. Before running the integration tests, you need to login to your Cloud Foundry using the cf cli:

    cf login -a https://api.your-cf.com -u [email protected] -p pa55woRD

    Note that your user requires permissions to run cf create-buildpack and cf update-buildpack. To run the integration tests, run the following command from the buildpack's directory:

    ./scripts/integration.sh
  4. Note: To run the network tests, you must have Docker installed.

Contributing

Find our guidelines here.

Help and Support

Join the #buildpacks channel in our Slack community if you need any further assistance.

Reporting Issues

Open a GitHub issue on this project here.

Active Development

The project backlog is on Pivotal Tracker.

Languages

  • Go 85.3%
  • Shell 8.5%
  • Python 6.0%
  • Procfile 0.2%