Skip to main content

A python script to automate building of native dependencies

Project description

build_deps

A python script to automate the building of native dependencies

This script builds native dependencies according to the rules described in a file named dependencies.py. It provides a convenient DSL which helps you to install all your binary as well as header-only dependencies in a project-scoped location with a single command.

After install, the third-party directory will have the following structure:

lib
├── %platform%
    ├── libsomelib1.a
    ├── libsomelib2.a
    ...
...

include
├── some_solitary_header.h
├── lib_with_include_folder
    ├── lib_with_include_folder.h
    ...
...

Example dependencies.py

# dependencies.py

from os import path

# Custom third-party directory name (default: "third-party")
# THIRD_PARTY_DIR = 'dependencies'


# Binary dependency:

def utf8proc(src_path, build_path, platform, actions):
    actions.download(
        "https://github.com/JuliaStrings/utf8proc/archive/v2.5.0.zip")

    # Copy all headers, excluding folders
    actions.copy_headers(exclude_dirs=['test', 'bench'])

    # Run commands are executed in the build path of the current library,
    # so we provide library source path as an argument to cmake:

    actions.run('cmake', [src_path])
    actions.run('cmake', ['--build', '.'])

    # Copy all library binaries found in the current library build folder
    actions.copy_binaries()


# Header-only dependency:

def nlohmann(src_path, build_path, platform, actions):
    actions.download(
        "https://github.com/nlohmann/json/releases/download/v3.9.0/include.zip")
    actions.copy_headers()


# Header-only dependency:

def cxxopts(src_path, build_path, platform, actions):
    actions.download("https://github.com/jarro2783/cxxopts/archive/v2.2.0.zip")
    actions.copy_headers()


# Custom boost setup:

def boost(src_path, build_path, platform, actions):
    actions.download(
        "https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2")
    actions.run('./bootstrap.sh', [
        f'--prefix="{build_path}"',
        '--with-libraries=filesystem'
    ], cwd=src_path)

    actions.run('./b2', ['install'], cwd=src_path)

    actions.copy_binaries(path.join(build_path, 'lib'))
    actions.copy_headers(build_path)


# Library with a custom build process:

def openssl(src_path, build_path, platform, actions):
    actions.download(
        "https://github.com/openssl/openssl/archive/OpenSSL_1_1_1g.zip")
    actions.run(path.join(src_path, 'config'))
    actions.copy_headers(exclude_dirs=['internal'])
    actions.run(_make_cmd(platform))
    actions.run(_make_cmd(platform), ['test'])
    actions.copy_headers(build_path)
    actions.copy_binaries()


# Helper functions must start with an underscore:
def _make_cmd(platform: str):
    if platform.startswith('win'):
        return 'nmake'

    return 'make'

CLI Command Installation

pip3 install build_deps

CLI Usage

$ build-deps -h

usage: build-deps [-h] [--platforms PLATFORMS [PLATFORMS ...]] [--clean]
                     [libraries [libraries ...]]

Builds dependecies from dependencies.py

positional arguments:
  libraries             List of libraries to build. If none is provided, every
                        library will be buit.

optional arguments:
  -h, --help            show this help message and exit
  --platforms PLATFORMS [PLATFORMS ...]
                        List of platofrms to build for. If none is provided,
                        it will be guessed based on the current machine.
  --clean               Clean third-party folder before build


License

See LICENSE (MIT)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

build_deps-0.0.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

build_deps-0.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file build_deps-0.0.1.tar.gz.

File metadata

  • Download URL: build_deps-0.0.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

File hashes

Hashes for build_deps-0.0.1.tar.gz
Algorithm Hash digest
SHA256 bf317f159081b9f90ccf053f5e6ac60dafa86cc00002725958e2ff92c6c0dfc1
MD5 109d220f0e8cc4fe275f9eeb800158bf
BLAKE2b-256 fc9bc0ddb9b52f9eaa10dd9430118fd041cc53626935065a6c1069a7495b37d3

See more details on using hashes here.

File details

Details for the file build_deps-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: build_deps-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

File hashes

Hashes for build_deps-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1bead559cfb38d4783885ed8378013579b8b0de7dd672a5ca35e077df269c339
MD5 281ae8579492488f0c8c552092ba21cd
BLAKE2b-256 cf41ce8ca4814c60e0e06c7bad5611897b2b07b92c68cbd9e0cc046aa898d996

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page