
12 changed files with 314 additions and 0 deletions
@ -0,0 +1,96 @@ |
|||||
|
include Makefile.conf |
||||
|
|
||||
|
.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 |
||||
|
|
||||
|
all: install |
||||
|
|
||||
|
# Install pEpACIDgen from this repo, not from pypi
|
||||
|
install-pepacidgen: |
||||
|
pip3 install -r requirements.txt --find-links ../../../dist/ |
||||
|
|
||||
|
# Build
|
||||
|
# =====
|
||||
|
gen: install-pepacidgen |
||||
|
$(MAKE) -C lib_test gen |
||||
|
|
||||
|
compile: gen |
||||
|
python3 setup.py build_ext $(DEBUG_OPT) $(PREFIX_OPT) |
||||
|
|
||||
|
compile-inplace: gen |
||||
|
python3 setup.py build_ext $(DEBUG_OPT) $(PREFIX_OPT) --inplace |
||||
|
|
||||
|
# Packaging
|
||||
|
# =========
|
||||
|
# create wheel and egg package in dist/
|
||||
|
dist: dist-whl dist-egg |
||||
|
|
||||
|
# create wheel package in dist/
|
||||
|
dist-whl: compile |
||||
|
python3 setup.py bdist_wheel |
||||
|
|
||||
|
# create egg package in dist/
|
||||
|
dist-egg: compile |
||||
|
python3 setup.py bdist_egg |
||||
|
|
||||
|
|
||||
|
# Installation
|
||||
|
# ============
|
||||
|
# installs the package system wide
|
||||
|
install: compile |
||||
|
pip3 install . |
||||
|
|
||||
|
# installs the package into your user home
|
||||
|
install-user: compile |
||||
|
pip3 install . --user |
||||
|
|
||||
|
|
||||
|
# 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_test/ \
|
||||
|
DYLD_LIBRARY_PATH=../../lib/lib_test/ \
|
||||
|
bash --rcfile $(VENV_DIR)/bin/activate |
||||
|
|
||||
|
# Tests if the current environment is able to load the pEp module
|
||||
|
envtest: |
||||
|
python3 -c 'import lib_test' |
||||
|
|
||||
|
# 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 lib_test/ clean |
||||
|
rm -rf $(BUILD_DIR) |
||||
|
rm -rf $(DIST_DIR) |
||||
|
rm -rf $(PYTHON_ARTIFACTS) |
||||
|
rm -rf $(BUILD_INPLACE) |
||||
|
|
||||
|
|
||||
|
# Makefile based build of C++ parts only
|
||||
|
# ======================================
|
||||
|
makefile-build: |
||||
|
$(MAKE) -C lib_test/ |
||||
|
|
||||
|
makefile-clean: |
||||
|
$(MAKE) -C lib_test/ clean |
@ -0,0 +1,10 @@ |
|||||
|
HERE:=$(dir $(lastword $(MAKEFILE_LIST))) |
||||
|
|
||||
|
# Constants
|
||||
|
BUILD_DIR = ./build |
||||
|
DIST_DIR = ./dist |
||||
|
BUILD_INPLACE = ./lib_test/lib_test.cpython-38-darwin.so |
||||
|
PYTHON_ARTIFACTS += ./.eggs |
||||
|
PYTHON_ARTIFACTS += ./lib_test.egg-info |
||||
|
PYTHON_ARTIFACTS += ./.pytest_cache |
||||
|
VENV_DIR = ./venv |
@ -0,0 +1,47 @@ |
|||||
|
include Makefile.conf |
||||
|
|
||||
|
TARGET=lib_test.so |
||||
|
|
||||
|
# Swap here, for static vs dyn linking
|
||||
|
TARGET_MODULE_DYN=$(TARGET) |
||||
|
TARGET_MODULE_STATIC= |
||||
|
|
||||
|
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 gen-pybind module_dyn module_static clean |
||||
|
|
||||
|
all: gen compile |
||||
|
|
||||
|
gen: |
||||
|
$(MAKE) -C gen |
||||
|
|
||||
|
gen-pybind: |
||||
|
$(MAKE) -C gen pybind |
||||
|
|
||||
|
compile: $(TARGET) |
||||
|
|
||||
|
$(TARGET_MODULE_DYN) : $(OBJS) |
||||
|
$(CXX) $(LDFLAGS_DYN) -o $@ $^ |
||||
|
|
||||
|
$(TARGET_MODULE_STATIC) : $(OBJS) $(LIBS_STATIC) |
||||
|
$(CXX) $(LDFLAGS_STATIC) -o $@ $^ |
||||
|
|
||||
|
clean: |
||||
|
rm -f $(TARGET) |
||||
|
rm -f $(OBJS) |
||||
|
|
||||
|
clean-all: clean |
||||
|
$(MAKE) -C gen clean |
@ -0,0 +1,12 @@ |
|||||
|
# pyBind11 and python headers
|
||||
|
INCLUDES+=$(shell pybind11-config --includes) |
||||
|
|
||||
|
# example lib
|
||||
|
INCLUDES+=-I../../../lib/lib_test |
||||
|
|
||||
|
# static lib (.a)
|
||||
|
LIBS_STATIC+=../../../lib/lib_test/liblib_test.a |
||||
|
|
||||
|
# dynamic lib (.so)
|
||||
|
LIBS+=-llib_test |
||||
|
LIBS_PATH+=-L../../../lib/lib_test/ |
@ -0,0 +1,35 @@ |
|||||
|
include ../Makefile.conf |
||||
|
|
||||
|
YML2_FILE=py_module.yml2 |
||||
|
YSL2_FILE=$(shell pEp_acid_gen-config) |
||||
|
PYBIND11_FILE=py_module.pybind11 |
||||
|
DEBUG_AST_FILE=lib_test.h.ast.json |
||||
|
DEBUG_ACID_FILE=lib_test.h.acid.json |
||||
|
DEBUG_YML_FILE=lib_test.h.acid.yml |
||||
|
|
||||
|
|
||||
|
$(info -----LIB_TEST GEN----) |
||||
|
$(info YML2_FILE $(YML2_FILE)) |
||||
|
$(info YSL2_FILE $(YSL2_FILE)) |
||||
|
$(info CC_FILE $(PYBIND11_FILE)) |
||||
|
|
||||
|
.PHONY = all yml pybind11 |
||||
|
|
||||
|
all: pybind |
||||
|
|
||||
|
yml: $(YML2_FILE) |
||||
|
|
||||
|
pybind: $(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) |
||||
|
rm -f $(DEBUG_AST_FILE) |
||||
|
rm -f $(DEBUG_ACID_FILE) |
||||
|
rm -f $(DEBUG_YML_FILE) |
@ -0,0 +1,13 @@ |
|||||
|
{ |
||||
|
"module_name": "lib_test", |
||||
|
"header_filename": "../../../../../examples/lib/lib_test/lib_test.h", |
||||
|
"libclang_path": "/opt/local/libexec/llvm-9.0/lib/libclang.dylib", |
||||
|
"variables": [ |
||||
|
], |
||||
|
"functions": [ |
||||
|
"filtertype_to_string" |
||||
|
], |
||||
|
"debug_ast" : "True", |
||||
|
"debug_acid" : "True", |
||||
|
"debug_yml" : "True" |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
#include <string> |
||||
|
#include <iostream> |
||||
|
#include <pybind11/pybind11.h> |
||||
|
#include <pybind11/detail/common.h> |
||||
|
#include "lib_test.h" |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
PYBIND11_MODULE(lib_test, m) { |
||||
|
#include "gen/py_module.pybind11" |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,15 @@ |
|||||
|
[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", |
||||
|
] |
@ -0,0 +1,2 @@ |
|||||
|
pEpACIDgen |
||||
|
pyBind11 |
@ -0,0 +1,42 @@ |
|||||
|
[metadata] |
||||
|
name = lib_test |
||||
|
url = https://pep.foundation |
||||
|
download_url = |
||||
|
ext_package = lib_test |
||||
|
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 |
||||
|
|
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# This file is under GNU Affero General Public License 3.0 |
||||
|
# see LICENSE.txt |
||||
|
from setuptools import setup, Extension |
||||
|
|
||||
|
ext_modules = [ |
||||
|
Extension( |
||||
|
"lib_test", |
||||
|
["lib_test/lib_test.cc"], |
||||
|
include_dirs=['../../lib/lib_test', |
||||
|
'/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8', |
||||
|
'venv/lib/python3.8/site-packages/pybind11/include'], |
||||
|
extra_compile_args=['-std=c++11'], |
||||
|
libraries=['lib_test'], |
||||
|
library_dirs=['../../lib/lib_test/'] |
||||
|
) |
||||
|
] |
||||
|
|
||||
|
setup( |
||||
|
packages=['lib_test'], |
||||
|
ext_modules=ext_modules |
||||
|
) |
@ -0,0 +1,6 @@ |
|||||
|
#!/usr/bin/env python3 |
||||
|
# -*- coding: utf-8 -*- |
||||
|
# This file is under GNU Affero General Public License 3.0 |
||||
|
# see LICENSE.txt |
||||
|
import pytest |
||||
|
|
Loading…
Reference in new issue