Browse Source

pEpACIDgen Make example extension (synth_shed) a complete py-project

master
heck 5 years ago
parent
commit
6a409c63da
  1. 9
      gen/examples/Makefile
  2. 106
      gen/examples/ext/synth_shed/Makefile
  3. 35
      gen/examples/ext/synth_shed/Makefile.conf
  4. 19
      gen/examples/ext/synth_shed/gen/Makefile
  5. 16
      gen/examples/ext/synth_shed/pyproject.toml
  6. 1
      gen/examples/ext/synth_shed/requirements.txt
  7. 42
      gen/examples/ext/synth_shed/setup.cfg
  8. 26
      gen/examples/ext/synth_shed/setup.py
  9. 46
      gen/examples/ext/synth_shed/synth_shed/Makefile
  10. 12
      gen/examples/ext/synth_shed/synth_shed/Makefile.conf
  11. 25
      gen/examples/ext/synth_shed/synth_shed/gen/Makefile
  12. 2
      gen/examples/ext/synth_shed/synth_shed/gen/config.json
  13. 2
      gen/examples/ext/synth_shed/synth_shed/synth_shed.cc
  14. 9
      gen/examples/ext/synth_shed/tests/test_synth_shed.py
  15. 2
      gen/examples/lib/lib_synth_shed/synth_shed.c

9
gen/examples/Makefile

@ -3,9 +3,14 @@
all:
$(MAKE) -C lib/lib_test/
$(MAKE) -C lib/lib_synth_shed/
$(MAKE) -C ext/synth_shed/
$(MAKE) -C ext/synth_shed/synth_shed/
clean:
$(MAKE) -C lib/lib_test/ clean
$(MAKE) -C lib/lib_synth_shed/ clean
$(MAKE) -C ext/synth_shed/ clean
$(MAKE) -C ext/synth_shed/synth_shed/ clean
clean-all:
$(MAKE) -C lib/lib_test/ clean
$(MAKE) -C lib/lib_synth_shed/ clean
$(MAKE) -C ext/synth_shed/synth_shed/ clean

106
gen/examples/ext/synth_shed/Makefile

@ -1,44 +1,96 @@
include Makefile.conf
TARGET=synth_shed.so
.PHONY: all install-pepacidgen gen compile compile-inplace dist dist-egg dist-whl install install-user \
venv envtest install-test test develop docs clean clean-all clean-docs
TARGET_MODULE_DYN=$(TARGET)
TARGET_MODULE_STATIC=$(TARGET)
all: install
CXX=clang
CXXFLAGS+=-std=c++11 -g
# Install pEpACIDgen from this repo, not from pypi
install-pepacidgen:
pip3 install -r requirements.txt --find-links ../../../dist/
SRCS+=$(wildcard *.cc)
OBJS+=$(SRCS:.cc=.o)
# Build
# =====
gen: install-pepacidgen
$(MAKE) -C synth_shed gen
CXXFLAGS+=$(INCLUDES) -I$(PREFIX)/include
LDFLAGS_DYN+=-undefined dynamic_lookup $(LIBS_PATH) $(LIBS)
LDFLAGS_STATIC+=-undefined dynamic_lookup
compile: gen
python3 setup.py build_ext $(DEBUG_OPT) $(PREFIX_OPT)
$(info -----BUILD INFO----)
$(info SRCS $(SRCS))
$(info OBJS $(OBJS))
compile-inplace: gen
python3 setup.py build_ext $(DEBUG_OPT) $(PREFIX_OPT) --inplace
.PHONY: all gen module_dyn module_static clean
# Packaging
# =========
# create wheel and egg package in dist/
dist: dist-whl dist-egg
static: gen module_static
# create wheel package in dist/
dist-whl: compile
python3 setup.py bdist_wheel
dyn: gen module_dyn
# create egg package in dist/
dist-egg: compile
python3 setup.py bdist_egg
gen:
$(MAKE) -C gen
module_dyn: $(TARGET_MODULE_DYN)
# Installation
# ============
# installs the package system wide
install: compile
pip3 install .
$(TARGET_MODULE_DYN) : $(OBJS)
$(CXX) $(LDFLAGS_DYN) -o $@ $^
# installs the package into your user home
install-user: compile
pip3 install . --user
module_static: $(TARGET_MODULE_STATIC)
$(TARGET_MODULE_STATIC) : $(OBJS) $(LIBS_STATIC)
$(CXX) $(LDFLAGS_STATIC) -o $@ $^
# Envrionment
# ===========
# Creates and activates a new venv that has the LD_LIBRARY_PATH/DYLD_LIBRARY_PATH
# already set for the prefix specified in local.conf
# Only activates venv if already existing
venv:
python3 -m venv $(VENV_DIR)
LD_LIBRARY_PATH=../../lib/lib_synth_shed/ \
DYLD_LIBRARY_PATH=../../lib/lib_synth_shed/ \
bash --rcfile $(VENV_DIR)/bin/activate
# Tests if the current environment is able to load the pEp module
envtest:
python3 -c 'import synth_shed'
# Test
# ====
# Use these targets only in venv created with 'make venv'
install-test: compile
pip3 install .[test]
test:
pytest
# Development
develop: compile
pip install -e .
# Housekeeping
# ============
clean-all: clean
rm -rf $(VENV_DIR)
clean:
$(MAKE) -C gen clean
rm -f $(TARGET)
rm -f $(OBJS)
rm -rf $(BUILD_DIR)
rm -rf $(DIST_DIR)
rm -rf $(PYTHON_ARTIFACTS)
rm -rf $(VERSION_FILE)
rm -rf $(BUILD_INPLACE)
# Makefile based build of C++ parts only
# ======================================
makefile-build:
$(MAKE) -C synth_shed/
makefile-clean:
$(MAKE) -C synth_shed/ clean

35
gen/examples/ext/synth_shed/Makefile.conf

@ -1,23 +1,20 @@
# pyBind11
PREFIX=/Users/heck/local-default
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
# YML2
YML2_PATH=$(HOME)/src/pepbase/default/yml2
YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
YML2_OPTS=--encoding=utf8
# Constants
BUILD_DIR = ./build
DIST_DIR = ./dist
BUILD_INPLACE = ./src/synth_shed/syth_shed.cpython-38-darwin.so
PYTHON_ARTIFACTS += ./.eggs
PYTHON_ARTIFACTS += ./src/syth_shed.egg-info
PYTHON_ARTIFACTS += ./.pytest_cache
VENV_DIR = ./venv
# pEpACIDgen
pEpACIDgen_ROOT=../../../../
# Build config Defaults
PREFIX=
# C Python headers
INCLUDES+=-I/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8
######### Overrides #########
-include $(HERE)local.conf
# example lib
INCLUDES+=-I../../lib/lib_synth_shed
# static lib (.a)
LIBS_STATIC+=../../lib/lib_synth_shed/libsynth_shed.a
# dynamic lib (.so)
LIBS+=-lsynth_shed
LIBS_PATH+=-L../../lib/lib_synth_shed/
ifneq ($(PREFIX),)
PREFIX_OPT += --prefix=$(PREFIX)
endif

19
gen/examples/ext/synth_shed/gen/Makefile

@ -1,19 +0,0 @@
include ../Makefile.conf
YML2_FILE=py_module.yml2
CC_FILE=py_module.cc
.PHONY = yml cc
all: yml cc
yml:
$(pEpACIDgen_ROOT)/bin/pEp_acid_gen $(abspath config.json)
cc : $(YML2_FILE)
$(YML2_PROC) -y $(pEpACIDgen_ROOT)/pEpACIDgen/gen_backend/gen_cc.ysl2 $(YML2_FILE)
clean:
rm -f $(YML2_FILE)
rm -f $(CC_FILE)

16
gen/examples/ext/synth_shed/pyproject.toml

@ -0,0 +1,16 @@
[build-system]
# Preparing for PEP-517/PEP-518, but not in effect yet.
# These requires are not effective yet, setup.cfg is.
requires =[
"setuptools >=39.2.0",
"wheel >= 0.35.1" ]
build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-rP"
testpaths = [
"tests",
]

1
gen/examples/ext/synth_shed/requirements.txt

@ -0,0 +1 @@
pEpACIDgen

42
gen/examples/ext/synth_shed/setup.cfg

@ -0,0 +1,42 @@
[metadata]
name = synth_shed
url = https://pep.foundation
download_url =
ext_package = synth_shed
author = heck
author_email = heck@pep-project.org
maintainer = heck
maintainer_email = heck@pep.foundation
description = pEpACIDgen example extension module
long_description = file: README.md
keywords = pEpACIDgen
license = GNU Affero General Public License
license_files = LICENSE.txt
platforms = linux, macOs
classifiers =
Intended Audience :: Developers
Topic :: Utilities
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Development Status :: 3 - Alpha
[options]
zip_safe = false
include_package_data = true
python_requires = >= 3.6
test_suite = tests
install_requires =
# setup_requires is deprecated/redundant with pyproject.toml, but lets keep both ways around for now
setup_requires =
setuptools >=39.2.0
wheel >= 0.35.1
[options.extras_require]
# To install these dependencies, run pip install .[test]
test =
pytest

26
gen/examples/ext/synth_shed/setup.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# This file is under GNU Affero General Public License 3.0
# see LICENSE.txt
from setuptools import setup, Extension
# import pybind11.setup_helpers
ext_modules = [
Extension(
"synth_shed",
["synth_shed/synth_shed.cc"],
include_dirs=['../../lib/lib_synth_shed',
'/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8',
'/Users/heck/src/adapter/pEpPythonAdapter-new/gen/examples/ext/synth_shed/venv/lib/python3.8/site-packages/pybind11/include'],
extra_compile_args=['-std=c++11'],
libraries=['synth_shed'],
library_dirs=['../../lib/lib_synth_shed/']
)
]
setup(
packages=['synth_shed'],
ext_modules=ext_modules
)

46
gen/examples/ext/synth_shed/synth_shed/Makefile

@ -0,0 +1,46 @@
include Makefile.conf
TARGET=synth_shed.so
TARGET_MODULE_DYN=$(TARGET)
TARGET_MODULE_STATIC=$(TARGET)
CXX=clang
CXXFLAGS+=-std=c++11 -g
SRCS+=$(wildcard *.cc)
OBJS+=$(SRCS:.cc=.o)
CXXFLAGS+=$(INCLUDES)
LDFLAGS_DYN+=-undefined dynamic_lookup $(LIBS_PATH) $(LIBS)
LDFLAGS_STATIC+=-undefined dynamic_lookup
$(info -----BUILD INFO----)
$(info SRCS $(SRCS))
$(info OBJS $(OBJS))
.PHONY: all gen module_dyn module_static clean
all: static
static: gen module_static
dyn: gen module_dyn
gen:
$(MAKE) -C gen
module_dyn: $(TARGET_MODULE_DYN)
$(TARGET_MODULE_DYN) : $(OBJS)
$(CXX) $(LDFLAGS_DYN) -o $@ $^
module_static: $(TARGET_MODULE_STATIC)
$(TARGET_MODULE_STATIC) : $(OBJS) $(LIBS_STATIC)
$(CXX) $(LDFLAGS_STATIC) -o $@ $^
clean:
$(MAKE) -C gen clean
rm -f $(TARGET)
rm -f $(OBJS)

12
gen/examples/ext/synth_shed/synth_shed/Makefile.conf

@ -0,0 +1,12 @@
# pyBind11 and python headers
INCLUDES+=$(shell pybind11-config --includes)
# example lib
INCLUDES+=-I../../../lib/lib_synth_shed
# static lib (.a)
LIBS_STATIC+=../../../lib/lib_synth_shed/libsynth_shed.a
# dynamic lib (.so)
LIBS+=-lsynth_shed
LIBS_PATH+=-L../../../lib/lib_synth_shed/

25
gen/examples/ext/synth_shed/synth_shed/gen/Makefile

@ -0,0 +1,25 @@
include ../Makefile.conf
YML2_FILE=py_module.yml2
YSL2_FILE=$(shell pEp_acid_gen-config)
PYBIND11_FILE=py_module.pybind11
$(info -----SYNTH_SHED GEN----)
$(info YML2_FILE $(YML2_FILE))
$(info YSL2_FILE $(YSL2_FILE))
$(info CC_FILE $(PYBIND11_FILE))
.PHONY = yml pybind11
all: $(PYBIND11_FILE)
$(YML2_FILE): config.json
pEp_acid_gen $^
$(PYBIND11_FILE) : $(YML2_FILE)
yml2proc --encoding=utf8 -y $(YSL2_FILE) $(YML2_FILE)
clean:
rm -f $(YML2_FILE)
rm -f $(PYBIND11_FILE)

2
gen/examples/ext/synth_shed/gen/config.json → gen/examples/ext/synth_shed/synth_shed/gen/config.json

@ -1,6 +1,6 @@
{
"module_name": "synth_shed",
"header_filename": "../../../../examples/lib/lib_synth_shed/synth_shed.h",
"header_filename": "../../../../../examples/lib/lib_synth_shed/synth_shed.h",
"libclang_path": "/opt/local/libexec/llvm-9.0/lib/libclang.dylib",
"variables": [
],

2
gen/examples/ext/synth_shed/synth_shed.cc → gen/examples/ext/synth_shed/synth_shed/synth_shed.cc

@ -7,7 +7,7 @@
using namespace std;
PYBIND11_MODULE(synth_shed, m) {
#include "gen/py_module.cc"
#include "gen/py_module.pybind11"
}

9
gen/examples/ext/synth_shed/tests/test_synth_shed.py

@ -0,0 +1,9 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This file is under GNU Affero General Public License 3.0
# see LICENSE.txt
import synth_shed
def test_synth_shed():
synth_shed

2
gen/examples/lib/lib_synth_shed/synth_shed.c

@ -12,7 +12,7 @@ synth_t* synth_create(const char* name) {
synth_t* new = (synth_t*) malloc(sizeof(synth_t));
assert(new);
if (new != NULL) {
new->model_name = name;
new->model_name = "TESTNAME";
new->osc_count = 1;
new->technolgy = ANALOG;
new->filter.technology = ANALOG;

Loading…
Cancel
Save