Skip to content

Commit

Permalink
[dev] refactoring for pip-compatible packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
d-leroy committed Jul 5, 2023
1 parent 06b6755 commit 6f450b8
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 4 deletions.
29 changes: 29 additions & 0 deletions experimental/scihook-cppgen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Scihook-CppGen



# Features



# Installation

Installing is done in the standard way :

..code:: bash

# From a tar archive
pip install path/to/scihook-cppgen.tar

# From download sources
git clone git@.../scihook-cppgen.git
cd scihook-cppgen
pip install .

Previous commands should install `SciHook-CppGen` as well as other dependencies
on which the project depends.

# Test



1 change: 1 addition & 0 deletions experimental/scihook-cppgen/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Dorian Leroy"""
__email__ = "[email protected]"
__version__ = "0.0.1"
__version__ = "0.1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ def scihook(ctx):
@scihook.command()
@click.option("--dry-run", "-dr", is_flag=True, help="Print file content to be generated instead of generating it")
@click.option("--output-path", "-o", help="Output path of generated files (defaults to current folder)", default='.')
@click.option("--include-prefix", "-ip", help="Include path prefix for generated files (defaults to empty path)", default='')
@click.argument("compile-commands-path")
@click.argument("source-files-paths", nargs=-1)
@click.pass_context
def genctx(ctx, dry_run, output_path, compile_commands_path, source_files_paths):
def genctx(ctx, dry_run, output_path, include_prefix, compile_commands_path, source_files_paths):
gen_targets = parser.parse(compile_commands_path, source_files_paths)
for t in gen_targets:
generator.generate_context_file(
t['qualified_name'],
t['includes'],
t['structs'],
output_path,
include_prefix,
dry_run)

scihook.add_command(genctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import sys

def generate_context_file(qualified_name, includes, structs, output_path, dry_run):
def generate_context_file(qualified_name, includes, structs, output_path, include_prefix, dry_run):
path_to_templates = f'{os.path.dirname(os.path.abspath(sys.argv[0]))}/'

tpl_contexts = Template(filename=f'{path_to_templates}/contexts_template.mako')
Expand All @@ -17,6 +17,7 @@ def generate_context_file(qualified_name, includes, structs, output_path, dry_ru
tpl_triggers = Template(filename=f'{path_to_templates}/trigger_template.mako')
text_triggers = tpl_triggers.render(
qualified_name=qualified_name,
include_prefix=include_prefix,
structs=structs,
base_event=f"{'_'.join([s.upper() for s in qualified_name])}",
header=f"{'_'.join([s.upper() for s in qualified_name])}TRIGGERS_H"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef ${header}
#define ${header}

#include <${f"{qualified_name[-1]}ExecutionContexts.h"}>
#include <${f"{include_prefix}/" if include_prefix else ''}${f"{qualified_name[-1]}ExecutionContexts.h"}>

<% len_structs = len(structs) - 1 %>\
#define DECLARE_${'_'.join([s.upper() for s in qualified_name])}_EVENTS ${'\\'}
Expand Down
44 changes: 44 additions & 0 deletions experimental/scihook-cppgen/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""The setup script."""

from setuptools import setup, find_packages

from scihook_cppgen import __version__


with open("README.md") as readme_file:
readme = readme_file.read()

requirements = [
"Click",
"clang",
"libclang",
"Mako"
]

setup(
author="Dorian Leroy",
author_email="[email protected]",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
],
description="An instrumentation generator for SciHook",
entry_points={"console_scripts": ["cppgen=scihook_cppgen.cli.cli:cppgen"]},
python_requires=">=3",
install_requires=requirements,
long_description=readme,
include_package_data=True,
keywords="scihook-cppgen",
name="scihook-cppgen",
packages=find_packages(),
version=__version__,
zip_safe=False,
)

0 comments on commit 6f450b8

Please sign in to comment.