Skip to content

Commit

Permalink
Deploying to github.io from @ 00e680f 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
parcollet committed Feb 13, 2024
1 parent 17d314a commit eb62696
Show file tree
Hide file tree
Showing 37 changed files with 1,607 additions and 147 deletions.
2 changes: 1 addition & 1 deletion docs/unstable/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 553a643177046a2117ec0602f31df710
config: 92fd138d3374dc0a2aefb40cf0eb3dc6
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file modified docs/unstable/.doctrees/cmake.doctree
Binary file not shown.
Binary file modified docs/unstable/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/unstable/.doctrees/gettingstarted.doctree
Binary file not shown.
Binary file modified docs/unstable/.doctrees/install_packages.doctree
Binary file not shown.
Binary file modified docs/unstable/.doctrees/install_src.doctree
Binary file not shown.
14 changes: 11 additions & 3 deletions docs/unstable/ChangeLog.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
<title>Changelog &mdash; clair - Automatic Python/C++ bindings documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<link rel="stylesheet" href="_static/copybutton.css" type="text/css" />

<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/clipboard.min.js"></script>
<script src="_static/copybutton.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="about.html" />
<link rel="index" title="Index" href="genindex.html" />
Expand Down Expand Up @@ -41,14 +44,19 @@
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="install_packages.html">Packages</a><ul>
<li class="toctree-l3"><a class="reference internal" href="install_packages.html#os-x-brew">OS X (brew)</a></li>
<li class="toctree-l3"><a class="reference internal" href="install_packages.html#os-x-brew">OS X (brew)</a><ul>
<li class="toctree-l4"><a class="reference internal" href="install_packages.html#uninstalling">Uninstalling</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="install_src.html">Compiling from source</a><ul>
<li class="toctree-l3"><a class="reference internal" href="install_src.html#clair">clair</a></li>
<li class="toctree-l3"><a class="reference internal" href="install_src.html#c2py">c2py</a></li>
<li class="toctree-l3"><a class="reference internal" href="install_src.html#c2py">c2py</a><ul>
<li class="toctree-l4"><a class="reference internal" href="install_src.html#cmake-options">CMake options</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="install_src.html#set-environment-variables">Set environment variables</a></li>
<li class="toctree-l3"><a class="reference internal" href="install_src.html#custom-cmake-options">Custom CMake options</a></li>
</ul>
</li>
</ul>
Expand Down
7 changes: 3 additions & 4 deletions docs/unstable/_sources/cmake.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ We introduce an option `GENERATE_PYTHON_BINDINGS` so that the code can not be us
A variant avoiding the installation of c2py
...........................................

It is often convenient to avoid the need to install the `c2py` library completely.
As `c2py` is a very small library, the cost of recompiling it on the fly is negligeable,
but it is often a good strategy to ensure it is compiled with the same compilers, standard libraries etc.
(it is the recommended strategy for e.g. Google Test).
It is often convenient to avoid the need to install the `c2py` library completely.
As `c2py` is a very small library, the cost of recompiling it in each project is negligeable,
but it is often a good strategy to ensure it is compiled with the same compilers, standard libraries, etc.

In order to do this, we can simply modify the `CMakeLists.txt` file as

Expand Down
21 changes: 12 additions & 9 deletions docs/unstable/_sources/gettingstarted.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Let us begin with a simple example in file `my_module.cpp`.

.. literalinclude:: examples/gs1.cpp
:language: cpp
:linenos:

We just compile the C++ file with `clang` using the ``clair`` plugin as

Expand All @@ -22,7 +21,10 @@ We just compile the C++ file with `clang` using the ``clair`` plugin as
# Linux
clang++ -fplugin=clair_c2py.so my_module.cpp -std=c++20 -shared -o my_module.so `c2py_flags`
.. note::

The compiler search for the plugin in DYLD_LIBRARY_PATH (OS X) or LD_LIBRARY_PATH (linux).

That is it. The Python module is ready to use:

.. code-block:: console
Expand Down Expand Up @@ -63,31 +65,32 @@ What happened ?
................

In order to call C++ from Python, some **binding code** has to be generated.
It is a piece of C++ code which "adapt" the C++ functions and classes to the C API of Python.
It is a piece of C++ code which *adapts* the C++ functions and classes to the C API of Python.

The ``clair_c2py`` **compiler plugin** automatizes this task, by modifying the compilation process of LLVM/clang:
when compiling the C++ code `my_module.cpp`, it:
when compiling the C++ code `my_module.cpp` with it, the compiler:

#. parses `my_module.cpp` (the first step of compilation, checking syntax, grammar, ...).
#. generates the C++/Python bindings write them into `my_module.wrap.cxx`.
#. compiles the whole into a Python module `my_module.so`.
#. parses `my_module.cpp` as usual (the first step of a compilation: check syntax and grammar, build the Abstract Syntax Tree or AST).
#. generates the C++/Python bindings (by analyzing the AST) and write them into `my_module.wrap.cxx`.
#. compiles the whole code (source + bindings) into a Python module `my_module.so`.

Reusing the bindings without clang
..................................

While the generation of the bindings requires LLVM/clang and the clair plugin,
they can reused with any `C++20` compiler. For example, with ``gcc``.
they can reused with any `C++20` compiler. For example, with ``gcc``:

.. code-block:: bash
g++ my_module.wrap.cxx -std=c++20 -shared -o my_module.so `c2py_flags`
(the bindings automatically include the original source file `my_module.cpp`).
(the binding file includes the original source file `my_module.cpp`).

.. note::

On some machines (OS X), check that this c2py has been compiled with gcc too.
On some machines (OS X), beware that c2py must be compiled with gcc (in particular the same std C++ library).
For any project beyond a simple demo, it is recommended to use CMake setup, Cf :ref:`cmake`.

A typical workflow is therefore:

Expand Down
15 changes: 13 additions & 2 deletions docs/unstable/_sources/install_packages.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@ Experimental packages of ``c2py`` and ``clair`` are::

They are built from source from the GitHub parcollet/ccq repository.


.. note::

The DYLD_LIBRARY_PATH must be set e.g.::
To use the plugin as in the example below,
the DYLD_LIBRARY_PATH must be set e.g.::

export DYLD_LIBRARY_PATH=/opt/homebrew/lib/:$DYLD_LIBRARY_PATH

for clang to find its plugins in brew directory as in the documentation examples.

Alternatively, you can provide the full path to the plugin.
This setup is not necessary to use the CMake targets.

Uninstalling
............

In order to uninstall all formulas from the `parcollet/ccq` tap, you can use::

brew uninstall `brew list --full-name -1|grep ccq`


45 changes: 23 additions & 22 deletions docs/unstable/_sources/install_src.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ Compiling from source
clair
-----

#. Download the source code of the latest stable version by cloning the ``c2py`` repository from GitHub::
#. Download the source code of the latest stable version by cloning the ``clair`` repository from GitHub::

$ git clone https://github.com/flatironinstitute/clair clair.src

#. If you want a particular version, check it out, e.g. (use `git tag` go to see the available version)::
#. [Optional] If you want a particular version, check it out, e.g. (use `git tag` go to see the available version)::

$ git checkout 1.1.0
$ git checkout v0.1

#. Call cmake, including any additional custom CMake options, see below::

$ cmake -B clair.build -S clair.src -DCMAKE_INSTALL_PREFIX=path_to_install_dir
$ cmake -B clair.build -S clair.src -DCMAKE_INSTALL_PREFIX=path_to_clair_install_dir

#. Compile the code, run the tests and install the application (here with 8 cores, change accordingly)::

$ cd clair.build
$ make -j 8
$ ctest -j 8
$ make -j 8 install
Expand All @@ -47,41 +48,41 @@ To install ``c2py``, follow the same procedure as for ``clair``, replacing ``cla

$ git clone https://github.com/flatironinstitute/c2py c2py.src

#. If you want a particular version, check it out, e.g. (use `git tag` go to see the available version)::
#. [Optional] If you want a particular version, check it out, e.g. (use `git tag` go to see the available version)::

$ git checkout 1.1.0
$ git checkout v0.1

#. Call cmake, including any additional custom CMake options, see below::

$ cmake -B c2py.build -S c2py.src -DCMAKE_INSTALL_PREFIX=path_to_install_dir
$ cmake -B c2py.build -S c2py.src -DCMAKE_INSTALL_PREFIX=path_to_c2py_install_dir

#. Compile the code, run the tests and install the application (here with 8 cores, change accordingly)::

$ cd clair.build
$ make -j 8
$ ctest -j 8
$ make -j 8 install

CMake options
.............

Set environment variables
-------------------------

To the proper paths into your current shell environment with::

$ source path_to_install_dir/share/clair/clairvars.sh
$ source path_to_install_dir/share/c2py/c2pyvars.sh


Custom CMake options
--------------------

The compilation of ``clair`` can be configured using CMake-options::
The following CMake-options are available for ``clair``::

cmake ... -DOPTION1=value1 -DOPTION2=value2

+-----------------------------------------------------------------+-----------------------------------------------+
| Options | Syntax |
+=================================================================+===============================================+
| Specify an installation path | -DCMAKE_INSTALL_PREFIX=path_to_clair |
+-----------------------------------------------------------------+-----------------------------------------------+
| Build the documentation | -DBuild_Documentation=ON |
+-----------------------------------------------------------------+-----------------------------------------------+


Set environment variables
-------------------------

To load the proper paths into your current shell environment with::

$ source path_to_clair_install_dir/share/clair/clairvars.sh
$ source path_to_c2py_install_dir/share/c2py/c2pyvars.sh


4 changes: 4 additions & 0 deletions docs/unstable/_static/check-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eb62696

Please sign in to comment.