All Projects → symmetryinvestments → Autowrap

symmetryinvestments / Autowrap

Licence: bsd-3-clause
Wrap existing D code for use in Python, Excel, C#

Programming Languages

python
139335 projects - #7 most used programming language
csharp
926 projects
d
599 projects
metaprogramming
66 projects
dlang
54 projects

Projects that are alternatives of or similar to Autowrap

Rows
A common, beautiful interface to tabular data, no matter the format
Stars: ✭ 739 (+1054.69%)
Mutual labels:  excel, data-science
Dataproofer
A proofreader for your data
Stars: ✭ 628 (+881.25%)
Mutual labels:  excel, data-science
Rio
A Swiss-Army Knife for Data I/O
Stars: ✭ 467 (+629.69%)
Mutual labels:  excel, data-science
Janitor
simple tools for data cleaning in R
Stars: ✭ 981 (+1432.81%)
Mutual labels:  excel, data-science
Ai Platform
An open-source platform for automating tasks using machine learning models
Stars: ✭ 61 (-4.69%)
Mutual labels:  data-science
Openrefine
OpenRefine is a free, open source power tool for working with messy data and improving it
Stars: ✭ 8,531 (+13229.69%)
Mutual labels:  data-science
Datascience Projects
A collection of personal data science projects
Stars: ✭ 57 (-10.94%)
Mutual labels:  data-science
Etherscan Ml
Python Data Science and Machine Learning Library for the Ethereum and ERC-20 Blockchain
Stars: ✭ 55 (-14.06%)
Mutual labels:  data-science
Firetable
Excel/Google Sheets like UI for Firebase/Firestore. No more admin portals!
Stars: ✭ 1,115 (+1642.19%)
Mutual labels:  excel
Oreilly Ai K8s Tutorial
Materials for the "AI on Kubernetes" tutorial at O'Reilly AI SF 2018
Stars: ✭ 62 (-3.12%)
Mutual labels:  data-science
Collaborative Deep Learning For Recommender Systems
The hybrid model combining stacked denoising autoencoder with matrix factorization is applied, to predict the customer purchase behavior in the future month according to the purchase history and user information in the Santander dataset.
Stars: ✭ 60 (-6.25%)
Mutual labels:  data-science
Ngx Excel Export
Angular6 application with export data to excel file functionality.
Stars: ✭ 58 (-9.37%)
Mutual labels:  excel
Ntds 2017
Material for the EPFL master course "A Network Tour of Data Science", edition 2017.
Stars: ✭ 61 (-4.69%)
Mutual labels:  data-science
Rumble
⛈️ Rumble 1.11.0 "Banyan Tree"🌳 for Apache Spark | Run queries on your large-scale, messy JSON-like data (JSON, text, CSV, Parquet, ROOT, AVRO, SVM...) | No install required (just a jar to download) | Declarative Machine Learning and more
Stars: ✭ 58 (-9.37%)
Mutual labels:  data-science
Python Hierarchical Clustering Exercises
Exercises for hierarchical clustering with Python 3 and scipy as Jupyter Notebooks
Stars: ✭ 62 (-3.12%)
Mutual labels:  data-science
Drake Examples
Example workflows for the drake R package
Stars: ✭ 57 (-10.94%)
Mutual labels:  data-science
Data Science Best Resources
Carefully curated resource links for data science in one place
Stars: ✭ 1,104 (+1625%)
Mutual labels:  data-science
Superfileview
基于腾讯浏览服务Tbs,使用X5Webkit内核,实现文件的展示功能,支持多种文件格式
Stars: ✭ 1,115 (+1642.19%)
Mutual labels:  excel
Storytelling With Data
Course materials for Dartmouth Course: Storytelling with Data (PSYC 81.09).
Stars: ✭ 59 (-7.81%)
Mutual labels:  data-science
Verticapy
VerticaPy is a Python library that exposes sci-kit like functionality to conduct data science projects on data stored in Vertica, thus taking advantage Vertica’s speed and built-in analytics and machine learning capabilities.
Stars: ✭ 59 (-7.81%)
Mutual labels:  data-science

autowrap

CI Build Status Coverage

Wrap existing D code for use in other environments such as Python, Excel, and .NET.

Building

To build and test all the code, run ci/test-all.sh

About

There are projects already to make it possible to use D code from Python and from Excel.

In PyD, the functions and data structures must be registered manually, and while the same isn't true of excel-d, the latter wraps everything in the modules reflected on. When writing code specifically for Excel, that is clearly what the user wants (and if not it can be made private). When wrapping pre-existing D code, however, it makes sense to opt-in instead by requiring functions to be wrapped to be marked export. If one wants to wrap all functions regardless of export, use version=AutowrapAlwaysExport.

There is ppyd that makes the effort required to use pyd a lot less but that requires using a UDA. Again, when writing code specifically for Python use this makes sense, but adds a dependency that "dirties" pre-existing D code.

This dub package makes it possible to wrap pre-existing D code "from the outside", imposing no dependencies on the aforementioned body of work.

autowrap also does away with the boilerplate necessary to creating a Python extension with PyD. Things should just work.

To wrap for Python, make a dub dynamicLibrary project with one file:

import autowrap.python;
mixin(
    wrapAll(
        LibraryName("mylibrary"),
        Modules("my.module1", "my.module2", /* ... */),
    )
);

Assuming the dub package name is also "mylibrary", you should get libmylibrary.so/mylibrary.dll. If the former, rename it to mylibrary.so and you'll be able to use it from Python:

import mylibrary

mylibrary.func1()

The camelCase D functions are wrapped by snake_case Python functions, but struct members have the same names.

It is also possible to wrap all functions regardless of their export status on a module-by-module basis. To do so, instead of using a string to designate the module, do this instead:

Modules("my.module1", Module("my.module2", Yes.alwaysExport))

To wrap for Excel:

import autowrap.excel;

mixin(
    wrapAll!(
        "my.module1", "my.module2", /* ... */
    )
);

The camelCase D functions will be PascalCase in Excel.

Python versions

Since autowrap depends on PyD, the version of python to use must be specified. You can either specify the configuration explicity, e.g. subConfiguration "autowrap:python" "python36" or you can use the default env configuration. In order to build using the env configuration your must first set the relevant environment variables using the pyd_set_env_vars.{sh,bat} scripts, which you can copy to your current working directory by running dub run pyd:setup. See the pyd docs for more information.

.NET Support

Autowrap can also generate C# bindings to D libraries. Generating bindings for C# is a two-step process. First we must generate a C# compatible C-interface for the D library, then we build and run a version of the library that emits the corresponding C# interface code.

What Works:

  • Module Functions
  • Primitive Types
    • string
    • wstring
    • dstring
    • byte
    • ubyte
    • short
    • ushort
    • int
    • uint
    • long
    • ulong
    • float
    • double
  • Structs
    • Fields
    • Properties
    • Methods
  • Classes
    • Constructors
    • Fields
    • Properties
    • Methods

1-Dimensional Ranges are implemented but only lightly tested and may not work in all cases. Higher dimensional ranges are not supported.

Generating .NET Interfaces

To generate the C-interface use the following example replacing "csharp" with the dub name of your library (ex: csharp builds to libcsharp.so) and replace "csharp.library" with the name of the module you want to wrap.

import csharp.library;
import autowrap.csharp;

mixin(
    wrapCSharp("csharp",
        Modules(
            Module("csharp.library")
        )
    )
);

To generate the C# interface use the emitCSharp mixin as follows to dump the output to a location of your choice. This mixin creates a void main() function that will need to be executed by running the code. (This is due to the inability of CTFE to write files to the disk.)

mixin(
    emitCSharp(
        Modules(
            Module("csharp.library")
        ),
        OutputFileName("Wrapper.cs"),
        LibraryName("csharp"),
        RootNamespace("csharp")
    )
);

Full Example

module csharp.wrapper;

import csharp.library;
import autowrap.csharp;

immutable Modules modules = Modules(Module("test"));

mixin(
    wrapCSharp(
        Modules(
            Module("csharp.library")
        ),
        OutputFileName("Wrapper.cs"),
        LibraryName("csharp"),
        RootNamespace("csharp")
    )
);

Our sponsors

       

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].