Verified Commit acd6057e authored by Sofus Albert Høgsbro Rose's avatar Sofus Albert Høgsbro Rose
Browse files

Invented a build system (flec) due to general irritation. It's working...

Invented a build system (flec) due to general irritation. It's working extraordinarily well; I have high hopes. Already it has helped fix plenty of packaging-related bugs in openlut! Hope I didn't break CI...
parent 560c979a
*.exr filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.tar.gz filter=lfs diff=lfs merge=lfs -text
*.xcf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.webm filter=lfs diff=lfs merge=lfs -text
*.svg filter=lfs diff=lfs merge=lfs -text
*.exr filter=lfs diff=lfs merge=lfs -text
......@@ -4,41 +4,37 @@ stages:
- build
- test
#~ - deploy
# - review
before_script:
- wget https://github.com/git-lfs/git-lfs/releases/download/v1.5.5/git-lfs-linux-amd64-1.5.5.tar.gz && tar xf git-lfs-linux-amd64-1.5.5.tar.gz && cd git-lfs-1.5.5/ && ./install.sh && cd -
- git lfs install
- pip3 install -U pip setuptools wheel
- pip3 install -r requirements.txt
- python3 setup.py build_ext -i #Need the C++ extension only.
- mkdir testpath
build:
stage: build
script:
- python3 setup.py sdist #Build source distribution.
- python3 setup.py bdist_wheel #Build Linux wheel.
- python3 build source #Build source distribution.
- python3 build wheel #Build Linux wheel.
artifacts:
paths:
- dist
# run tests using the binary built before.
build_docs:
stage: build
script:
- ./mkDocs.sh
artifacts:
paths:
- doc/build/html
#~ build_docs:
#~ stage: build
#~ script:
#~ - ./mkDocs.sh
#~ artifacts:
#~ paths:
#~ - doc/build/html
test:
stage: test
script:
- git lfs pull
- python3 tests/suite.py
#~ test:
#~ stage: test
#~ script:
#~ - git lfs pull
#~ - python3 tests/suite.py
#~ deploy_docs:
#~ stage: deploy
......
[distutils]
index-servers=pypi
[pypi]
repository = https://upload.pypi.org/legacy/
username = so-rose
Contributors
--------------
This is the official list of the project contributors.
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column.
People contributing for an organization should be listed under the organization
that actually holds the copyright to their contributions with an indented '-'.
* Sofus Rose
MIT License
Copyright (c) 2017 Sofus Rose
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
recursive-include openlut *.py
include openlut/lib/olOpt.cpp
# This Makefile is essentially a nice glue layer on top of the Python-based build system.
# Macros
SHELL = /bin/bash
DATE = $(shell date)
DEPSPATH = DEPS
# Python Build
PYTHON = python3
BUILD = $(PYTHON) build
#Main Rules
.PHONY: all debug release run
all:
@$(BUILD) default
run:
@$(BUILD) run
list-targets:
@$(BUILD) --list-targets
# Release Targets
.PHONY: debug release inplace
debug:
@$(BUILD) debug
debug_release:
@$(BUILD) debug_release
release:
@$(BUILD) release
# PyPi Targets
.PHONY: pypi_source pypi
source:
@$(BUILD) source
wheel:
@$(BUILD) wheel
pypi:
@$(BUILD) pypi
# Housekeeping Rules
.PHONY: clean distclean
buildclean:
@$(BUILD) buildclean
clean:
@$(BUILD) clean
distclean:
@$(BUILD) distclean
# Setup and Dependencies
.PHONY: setup unsetup
setup:
@$(BUILD) setup
unsetup:
@$(BUILD) unsetup
......@@ -2,17 +2,25 @@
[![build status](https://git.sofusrose.com/so-rose/openlut/badges/master/build.svg)](https://git.sofusrose.com/so-rose/openlut/commits/master)
**Main Dev Repo**: https://git.sofusrose.com/so-rose/openlut (GitLab)
**Dev Repo** (Please submit Issues here): https://git.sofusrose.com/so-rose/openlut
**Mirror Repo**: https://www.github.com/so-rose/openlut
**PyPi Package**: https://pypi.python.org/pypi/openlut
What is it?
-----
openlut is, at its core, a transform-focused **color management library**, accessible from **Python 3.5+**. It's built on my own color pipeline needs, which includes managing Lookup Tables, Gamma/Gamut functions/matrices, applying color transformations, etc. .
openlut is a practical **color management library/tool** that aims to simplify and unify all the various methods of making accurate color transformations.
Supported transforms include:
* 1D and 3D LUTs
* Color Matrices
* Gamma Function
* CDL Transform
openlut is also a practical tool. Included soon will be a command line utility letting you perform complex color transformations from the comfort of your console. Included already is an OpenGL image viewer, which might grow in the future to play sequences.
It's built on my own color pipeline needs - I needed a simple but close-to-the-math solutions that dealt not with images, but with float arrays.
I wanted it to cover this niche simply and consistently, with batteries included (a library of gamma functions and color gamut matrices).
As a tool, its main feature is that it's exceptionally easy to import, transform, and then save not only images, but also transforms.
Documentation
-----
......@@ -20,45 +28,32 @@ Docs can be found at https://sofusrose.com/openlut. They're a work in progress f
Installation
-----
1. **Get the dependencies!!!** The pip command will break without them.
* **On Debian/Ubuntu**: `sudo apt-get install python3-pip gcc libmagickwand-dev`
* **On Mac**: `brew install python3 gcc imagemagick`
* **All**: Make sure **pip**, **setuptools**, and **wheel** are installed. `pip3 install -U pip setuptools wheel`. It can cause errors if they aren't.
2. Run `pip3 install openlut` *(possibly sudo)*. This step **relies** on the successful installation of deps:
* **Python 3.5**: This is Python. You need Python.
* **gcc**: This is needed to compile the C++ extension.
* **imagemagick**: For all file IO. It's not like I was gonna write that myself :) .
0. **Check Versions**: Ensure you have Python 3.5+ installed.
*Linux: Ignore the AssertionError when building the wheel; it doesn't affect anything.*
Troubleshooting
-----
If python's installed but pip won't install, run `curl https://bootstrap.pypa.io/get-pip.py | python3`
1. **Get System Dependencies** - needing to do this is an unfortunate side effect of PyPi.
* **On Debian/Ubuntu**: `sudo apt-get install python3-pip gcc libmagickwand-dev`
* **On Mac**: `brew install python3 gcc imagemagick`
No Windows support right now - it's the C++ module's fault.
2. **Ensure Core Python Packages are Up To Date**: Simply run `pip3 install --user -U pip setuptools wheel` to do so.
Start an issue if something goes wrong with the library itself!
2. **Install OpenLUT**: Run `pip3 install --user openlut`.
* *This may take awhile, as it must compile the C++ Extension.*
Misc. Systems need, generically:
* Python 3.5+
* Pip
* gcc (with c++14 and openmp support)
Development
-----
1. **Clone the Repository**: This is easy enough to do - just run `git clone https://www.github.com/so-rose/openlut`.
2. **Compile Openlut**: Again, very easy - just run `./build <TARGET>`, where `<TARGET>` is some build target as listed in `./build -l`.
What About OpenColorIO? Why does this exist?
------
OpenColorIO does amazing work - but mostly in the context of large applications, not-simple config files, and self-defined color space
(with the full range of int/float bit depth specifics, etc.)
Troubleshooting
-----
**Pip doesn't work**: If Python is installed, but pip won't run, try running `curl https://bootstrap.pypa.io/get-pip.py | python3`
openlut is all about images and the transforms on images. Everything happens in (0, 1) float space. Large emphasis is placed on managing the
tools themselves as well - composing matrices, resizing LUTs, defining new gamma functions, etc. .
**Doesn't work on Windows**: I'm unsure of how pip compiles C Extensions on Windows, and have little willpower to investigate. If
you need Windows support, PM me and I'll see what I can do about it.
In many ways, OCIO is a system stringing basic operations together. I'd be perfectly plausible to write an OCIO alternative with openlut in the backend.
**Something's broken...**: There may be several bugs. If you start an Issue, then I can investigate.
I Wanna Contribute!
I Want To Contribute!
------
I'm honored! I could use help with:
* Feedback
* Gamma Transfer Functions: The more "batteries" are included, the better!
* D65 XYZ-referenced color matrices (gamut definitions): See above.
Contributions are welcome! Let me know if you have any questions or issues.
openlut - OSS tools for practical color management.
===================================================
|build status|
**Main Dev Repo**: https://git.sofusrose.com/so-rose/openlut (GitLab)
**PyPi Package**: https://pypi.python.org/pypi/openlut
What is it?
-----------
openlut is, at its core, a transform-focused **color management
library**, accessible from **Python 3.5+**. It's built on my own color
pipeline needs, which includes managing Lookup Tables, Gamma/Gamut
functions/matrices, applying color transformations, etc. .
openlut is also a practical tool. Included soon will be a command line
utility letting you perform complex color transformations from the
comfort of your console. Included already is an OpenGL image viewer,
which might grow in the future to play sequences.
I wanted it to cover this niche simply and consistently, with batteries
included (a library of gamma functions and color gamut matrices).
Documentation
-------------
Docs can be found at https://sofusrose.com/openlut. They're a work in
progress for now (ColMap is 100% documented).
Installation
------------
1. **Get the dependencies!!!** The pip command will break without them.
- **On Debian/Ubuntu**:
``sudo apt-get install python3-pip gcc libmagickwand-dev``
- **On Mac**: ``brew install python3 gcc imagemagick``
- **All**: Make sure **pip**, **setuptools**, and **wheel** are
installed. ``pip3 install -U pip setuptools wheel``. It can cause
errors if they aren't.
2. Run ``pip3 install openlut`` *(possibly sudo)*. This step **relies**
on the successful installation of deps:
- **Python 3.5**: This is Python. You need Python.
- **gcc**: This is needed to compile the C++ extension.
- **imagemagick**: For all file IO. It's not like I was gonna write
that myself :) .
*Linux: Ignore the AssertionError when building the wheel; it doesn't
affect anything.*
Troubleshooting
---------------
If python's installed but pip won't install, run
``curl https://bootstrap.pypa.io/get-pip.py | python3``
No Windows support right now - it's the C++ module's fault.
Start an issue if something goes wrong with the library itself!
Misc. Systems need, generically: \* Python 3.5+ \* Pip \* gcc (with
c++14 and openmp support)
What About OpenColorIO? Why does this exist?
--------------------------------------------
OpenColorIO does amazing work - but mostly in the context of large
applications, not-simple config files, and self-defined color space
(with the full range of int/float bit depth specifics, etc.)
openlut is all about images and the transforms on images. Everything
happens in (0, 1) float space. Large emphasis is placed on managing the
tools themselves as well - composing matrices, resizing LUTs, defining
new gamma functions, etc. .
In many ways, OCIO is a system stringing basic operations together. I'd
be perfectly plausible to write an OCIO alternative with openlut in the
backend.
I Wanna Contribute!
-------------------
I'm honored! I could use help with: \* Feedback \* Gamma Transfer
Functions: The more "batteries" are included, the better! \* D65
XYZ-referenced color matrices (gamut definitions): See above.
.. |build status| image:: https://git.sofusrose.com/so-rose/openlut/badges/master/build.svg
:target: https://git.sofusrose.com/so-rose/openlut/commits/master
#!/usr/bin/env python3
'''
The flec build system script.
'''
from __future__ import print_function # Ensure we can use print() if the version check fails because we're on 2.X.
# Minimum Python Version to run Flec
import os, sys
MIN_FLEC_PYTHON = [3, 5] # Minimum python version that Flec will work with.
if not sys.version_info[0] == MIN_FLEC_PYTHON[0] and sys.version_info[1] > MIN_FLEC_PYTHON[1] :
print("The FLEC build system requires a Python version of at least %i.%i to run." % (MIN_FLEC_PYTHON[0], MIN_FLEC_PYTHON[1]))
sys.exit()
# System
sys.dont_write_bytecode = True # We don't want pyc files populating our build system.
import types, argparse
from os import path
# Build Modules
import settings
settings.vmin_flec_python = MIN_FLEC_PYTHON
from packaging import targets
# Main Method
def main() :
# Retrieve the target functions from the dedicated module.
dict_target = {
target: getattr(targets, target)
for target in list(
filter(
lambda x: '__' not in x,
dir(targets)
)
)
if isinstance(getattr(targets, target), types.FunctionType)
if getattr(targets, target).__name__[-len(settings.target_tail):] == settings.target_tail
}
# Create Argument Parser
parser = argparse.ArgumentParser(description='')
# Register Arguments
parser.add_argument(
'target',
nargs='?',
default='default',
const='default',
type=str,
help="Specify the desired build target."
)
parser.add_argument(
'-v',
'--version',
action='store_true',
help="List the version of the program."
)
parser.add_argument(
'-l',
'--list-targets',
action='store_true',
help="See the list of available build targets."
)
# Parse Arguments
args = parser.parse_args()
# ARG: Print Version
if args.version :
print('{}'.format(settings.version))
# ARG: List Targets
elif args.list_targets :
# ~ print(*['{}: {}'.format(target.__name__, target.__doc__) for target in dict_target.values()], sep='\n')
print(
*[
'{}: {}\n'.format(
target.__name__[:-len(settings.target_tail)],
target.__doc__ if target.__doc__ != None else "No Info"
)
for target in dict_target.values()
],
sep='\n'
)
# ARG: Run Target
else :
# Run the corresponding Target
target = args.target
if target in dict_target :
dict_target[target]()
else :
print("Target {} Not Found".format(target))
if __name__ == "__main__" :
main()
### Flec (Flexible Compile) Build System
AFarm's build system is a unique, portable one designed for any system more complex than a pile of Python scripts.
The philosophy is as so:
* **Cross Platform**: As portable as Python itself.
* **Dead Simple**: One easy command compiles & run the cloned code, regardless of what dependencies are installed.
* **Configurable**: Each target is merely a simple Python function. Of course, the build system provides a deep library to simplify common tasks, and to do specific things based on your programming language.
from functools import reduce
from imp import reload
import numpy as np
import openlut as ol
from openlut.lib.files import Log
img = ol.ColMap.open('img_test/rock.exr')
fSeq = img.rgbArr
lut = ol.LUT.lutFunc(ol.gamma.sRGB)
SCRIPT_PATH="$(dirname $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}"))/doc"
make -C "$SCRIPT_PATH" doctest
make -C "$SCRIPT_PATH" html
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment