Skip to content

Commit e04dff5

Browse files
committedMar 15, 2016
Example project built with pybind11
0 parents  commit e04dff5

File tree

10 files changed

+972
-0
lines changed

10 files changed

+972
-0
lines changed
 

‎.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.so
2+
MANIFEST
3+
*.py[cod]
4+
*.egg-info
5+
.DS_Store
6+
_build
7+
_generate
8+
build

‎LICENSE

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Copyright (c) 2016 The Pybind Development Team, All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
13+
3. Neither the name of the copyright holder nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
You are under no obligation whatsoever to provide any bug fixes, patches, or
29+
upgrades to the features, functionality or performance of the source code
30+
("Enhancements") to anyone; however, if you choose to make your Enhancements
31+
available either publicly, or directly to the author of this software, without
32+
imposing a separate written license agreement for such Enhancements, then you
33+
hereby grant the following license: a non-exclusive, royalty-free perpetual
34+
license to install, use, modify, prepare derivative works, incorporate into
35+
other computer software, distribute, and sublicense such enhancements or
36+
derivative works thereof, in binary and source code form.

‎README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
pbtest
2+
=====
3+
4+
An example project built with [pybind11](https://github.com/wjakob/pybind11).
5+
6+
Installation
7+
------------
8+
9+
**On Unix (Linux, OS X)**
10+
11+
- clone this repository
12+
- `pip install ./pbtest`
13+
14+
**On Windows (Requires Visual Studio 2015)**
15+
16+
- For Python 3.5:
17+
- clone this repository
18+
- `pip install ./pbtest`
19+
- For earlier versions of Python, including Python 2.7:
20+
21+
Pybind11 requires a C++11 compliant compiler (i.e. Visual Studio 2015 on
22+
Windows). Running a regular `pip install` command will detect the version
23+
of the compiler used to build Python and attempt to build the extension
24+
with it. We must force the use of Visual Studio 2015.
25+
26+
- clone this repository
27+
- `"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64`
28+
- `set DISTUTILS_USE_SDK=1`
29+
- `set MSSdk=1`
30+
- `pip install ./pbtest`
31+
32+
Note that this requires the user building pbtest to have registry edition
33+
rights on the machine, to be able to run the `vcvarsall.bat` script.
34+
35+
36+
Building the documentation
37+
--------------------------
38+
39+
Documentation for the example project is generated using Sphinx. Sphinx has the
40+
ability to automatically inspect the signatures and documentation strings in
41+
the extension module to generate beautiful documentation in a variety formats.
42+
The following command generates HTML-based reference documentation; for other
43+
formats please refer to the Sphinx manual:
44+
45+
- `cd pbtest/docs`
46+
- `make html`
47+
48+
License
49+
-------
50+
51+
pybind11 is provided under a BSD-style license that can be found in the LICENSE
52+
file. By using, distributing, or contributing to this project, you agree to the
53+
terms and conditions of this license.
54+
55+
Test call
56+
---------
57+
58+
```python
59+
import pbtest
60+
pbtest.add(1, 2)
61+
```

‎docs/Makefile

+216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = _build
9+
10+
# User-friendly check for sphinx-build
11+
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
12+
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
13+
endif
14+
15+
# Internal variables.
16+
PAPEROPT_a4 = -D latex_paper_size=a4
17+
PAPEROPT_letter = -D latex_paper_size=letter
18+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
19+
# the i18n builder cannot share the environment and doctrees with the others
20+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
21+
22+
.PHONY: help
23+
help:
24+
@echo "Please use \`make <target>' where <target> is one of"
25+
@echo " html to make standalone HTML files"
26+
@echo " dirhtml to make HTML files named index.html in directories"
27+
@echo " singlehtml to make a single large HTML file"
28+
@echo " pickle to make pickle files"
29+
@echo " json to make JSON files"
30+
@echo " htmlhelp to make HTML files and a HTML help project"
31+
@echo " qthelp to make HTML files and a qthelp project"
32+
@echo " applehelp to make an Apple Help Book"
33+
@echo " devhelp to make HTML files and a Devhelp project"
34+
@echo " epub to make an epub"
35+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
36+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
37+
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
38+
@echo " text to make text files"
39+
@echo " man to make manual pages"
40+
@echo " texinfo to make Texinfo files"
41+
@echo " info to make Texinfo files and run them through makeinfo"
42+
@echo " gettext to make PO message catalogs"
43+
@echo " changes to make an overview of all changed/added/deprecated items"
44+
@echo " xml to make Docutils-native XML files"
45+
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
46+
@echo " linkcheck to check all external links for integrity"
47+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
48+
@echo " coverage to run coverage check of the documentation (if enabled)"
49+
50+
.PHONY: clean
51+
clean:
52+
rm -rf $(BUILDDIR)/*
53+
54+
.PHONY: html
55+
html:
56+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
57+
@echo
58+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
59+
60+
.PHONY: dirhtml
61+
dirhtml:
62+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
63+
@echo
64+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
65+
66+
.PHONY: singlehtml
67+
singlehtml:
68+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
69+
@echo
70+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
71+
72+
.PHONY: pickle
73+
pickle:
74+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
75+
@echo
76+
@echo "Build finished; now you can process the pickle files."
77+
78+
.PHONY: json
79+
json:
80+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
81+
@echo
82+
@echo "Build finished; now you can process the JSON files."
83+
84+
.PHONY: htmlhelp
85+
htmlhelp:
86+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
87+
@echo
88+
@echo "Build finished; now you can run HTML Help Workshop with the" \
89+
".hhp project file in $(BUILDDIR)/htmlhelp."
90+
91+
.PHONY: qthelp
92+
qthelp:
93+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
94+
@echo
95+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
96+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
97+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pbtest.qhcp"
98+
@echo "To view the help file:"
99+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pbtest.qhc"
100+
101+
.PHONY: applehelp
102+
applehelp:
103+
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
104+
@echo
105+
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
106+
@echo "N.B. You won't be able to view it unless you put it in" \
107+
"~/Library/Documentation/Help or install it in your application" \
108+
"bundle."
109+
110+
.PHONY: devhelp
111+
devhelp:
112+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
113+
@echo
114+
@echo "Build finished."
115+
@echo "To view the help file:"
116+
@echo "# mkdir -p $$HOME/.local/share/devhelp/pbtest"
117+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pbtest"
118+
@echo "# devhelp"
119+
120+
.PHONY: epub
121+
epub:
122+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
123+
@echo
124+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
125+
126+
.PHONY: latex
127+
latex:
128+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
129+
@echo
130+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
131+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
132+
"(use \`make latexpdf' here to do that automatically)."
133+
134+
.PHONY: latexpdf
135+
latexpdf:
136+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
137+
@echo "Running LaTeX files through pdflatex..."
138+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
139+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
140+
141+
.PHONY: latexpdfja
142+
latexpdfja:
143+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
144+
@echo "Running LaTeX files through platex and dvipdfmx..."
145+
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
146+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
147+
148+
.PHONY: text
149+
text:
150+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
151+
@echo
152+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
153+
154+
.PHONY: man
155+
man:
156+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
157+
@echo
158+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
159+
160+
.PHONY: texinfo
161+
texinfo:
162+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
163+
@echo
164+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
165+
@echo "Run \`make' in that directory to run these through makeinfo" \
166+
"(use \`make info' here to do that automatically)."
167+
168+
.PHONY: info
169+
info:
170+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
171+
@echo "Running Texinfo files through makeinfo..."
172+
make -C $(BUILDDIR)/texinfo info
173+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
174+
175+
.PHONY: gettext
176+
gettext:
177+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
178+
@echo
179+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
180+
181+
.PHONY: changes
182+
changes:
183+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
184+
@echo
185+
@echo "The overview file is in $(BUILDDIR)/changes."
186+
187+
.PHONY: linkcheck
188+
linkcheck:
189+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
190+
@echo
191+
@echo "Link check complete; look for any errors in the above output " \
192+
"or in $(BUILDDIR)/linkcheck/output.txt."
193+
194+
.PHONY: doctest
195+
doctest:
196+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
197+
@echo "Testing of doctests in the sources finished, look at the " \
198+
"results in $(BUILDDIR)/doctest/output.txt."
199+
200+
.PHONY: coverage
201+
coverage:
202+
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
203+
@echo "Testing of coverage in the sources finished, look at the " \
204+
"results in $(BUILDDIR)/coverage/python.txt."
205+
206+
.PHONY: xml
207+
xml:
208+
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
209+
@echo
210+
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
211+
212+
.PHONY: pseudoxml
213+
pseudoxml:
214+
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
215+
@echo
216+
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

‎docs/conf.py

+294
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# pbtest documentation build configuration file, created by
4+
# sphinx-quickstart on Fri Feb 26 00:29:33 2016.
5+
#
6+
# This file is execfile()d with the current directory set to its
7+
# containing dir.
8+
#
9+
# Note that not all possible configuration values are present in this
10+
# autogenerated file.
11+
#
12+
# All configuration values have a default; values that are commented out
13+
# serve to show the default.
14+
15+
import sys
16+
import os
17+
18+
# If extensions (or modules to document with autodoc) are in another directory,
19+
# add these directories to sys.path here. If the directory is relative to the
20+
# documentation root, use os.path.abspath to make it absolute, like shown here.
21+
#sys.path.insert(0, os.path.abspath('.'))
22+
23+
# -- General configuration ------------------------------------------------
24+
25+
# If your documentation needs a minimal Sphinx version, state it here.
26+
#needs_sphinx = '1.0'
27+
28+
# Add any Sphinx extension module names here, as strings. They can be
29+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30+
# ones.
31+
extensions = [
32+
'sphinx.ext.autodoc',
33+
'sphinx.ext.intersphinx',
34+
'sphinx.ext.autosummary',
35+
'sphinx.ext.napoleon',
36+
]
37+
38+
autosummary_generate = True
39+
40+
# Add any paths that contain templates here, relative to this directory.
41+
templates_path = ['_templates']
42+
43+
# The suffix(es) of source filenames.
44+
# You can specify multiple suffix as a list of string:
45+
# source_suffix = ['.rst', '.md']
46+
source_suffix = '.rst'
47+
48+
# The encoding of source files.
49+
#source_encoding = 'utf-8-sig'
50+
51+
# The master toctree document.
52+
master_doc = 'index'
53+
54+
# General information about the project.
55+
project = u'pbtest'
56+
copyright = u'2016, Sylvain Corlay'
57+
author = u'Sylvain Corlay'
58+
59+
# The version info for the project you're documenting, acts as replacement for
60+
# |version| and |release|, also used in various other places throughout the
61+
# built documents.
62+
#
63+
# The short X.Y version.
64+
version = u'0.0.1'
65+
# The full version, including alpha/beta/rc tags.
66+
release = u'0.0.1'
67+
68+
# The language for content autogenerated by Sphinx. Refer to documentation
69+
# for a list of supported languages.
70+
#
71+
# This is also used if you do content translation via gettext catalogs.
72+
# Usually you set "language" from the command line for these cases.
73+
language = None
74+
75+
# There are two options for replacing |today|: either, you set today to some
76+
# non-false value, then it is used:
77+
#today = ''
78+
# Else, today_fmt is used as the format for a strftime call.
79+
#today_fmt = '%B %d, %Y'
80+
81+
# List of patterns, relative to source directory, that match files and
82+
# directories to ignore when looking for source files.
83+
exclude_patterns = ['_build']
84+
85+
# The reST default role (used for this markup: `text`) to use for all
86+
# documents.
87+
#default_role = None
88+
89+
# If true, '()' will be appended to :func: etc. cross-reference text.
90+
#add_function_parentheses = True
91+
92+
# If true, the current module name will be prepended to all description
93+
# unit titles (such as .. function::).
94+
#add_module_names = True
95+
96+
# If true, sectionauthor and moduleauthor directives will be shown in the
97+
# output. They are ignored by default.
98+
#show_authors = False
99+
100+
# The name of the Pygments (syntax highlighting) style to use.
101+
pygments_style = 'sphinx'
102+
103+
# A list of ignored prefixes for module index sorting.
104+
#modindex_common_prefix = []
105+
106+
# If true, keep warnings as "system message" paragraphs in the built documents.
107+
#keep_warnings = False
108+
109+
# If true, `todo` and `todoList` produce output, else they produce nothing.
110+
todo_include_todos = False
111+
112+
113+
# -- Options for HTML output ----------------------------------------------
114+
115+
# The theme to use for HTML and HTML Help pages. See the documentation for
116+
# a list of builtin themes.
117+
html_theme = 'alabaster'
118+
119+
# Theme options are theme-specific and customize the look and feel of a theme
120+
# further. For a list of options available for each theme, see the
121+
# documentation.
122+
#html_theme_options = {}
123+
124+
# Add any paths that contain custom themes here, relative to this directory.
125+
#html_theme_path = []
126+
127+
# The name for this set of Sphinx documents. If None, it defaults to
128+
# "<project> v<release> documentation".
129+
#html_title = None
130+
131+
# A shorter title for the navigation bar. Default is the same as html_title.
132+
#html_short_title = None
133+
134+
# The name of an image file (relative to this directory) to place at the top
135+
# of the sidebar.
136+
#html_logo = None
137+
138+
# The name of an image file (within the static path) to use as favicon of the
139+
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
140+
# pixels large.
141+
#html_favicon = None
142+
143+
# Add any paths that contain custom static files (such as style sheets) here,
144+
# relative to this directory. They are copied after the builtin static files,
145+
# so a file named "default.css" will overwrite the builtin "default.css".
146+
html_static_path = ['_static']
147+
148+
# Add any extra paths that contain custom files (such as robots.txt or
149+
# .htaccess) here, relative to this directory. These files are copied
150+
# directly to the root of the documentation.
151+
#html_extra_path = []
152+
153+
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
154+
# using the given strftime format.
155+
#html_last_updated_fmt = '%b %d, %Y'
156+
157+
# If true, SmartyPants will be used to convert quotes and dashes to
158+
# typographically correct entities.
159+
#html_use_smartypants = True
160+
161+
# Custom sidebar templates, maps document names to template names.
162+
#html_sidebars = {}
163+
164+
# Additional templates that should be rendered to pages, maps page names to
165+
# template names.
166+
#html_additional_pages = {}
167+
168+
# If false, no module index is generated.
169+
#html_domain_indices = True
170+
171+
# If false, no index is generated.
172+
#html_use_index = True
173+
174+
# If true, the index is split into individual pages for each letter.
175+
#html_split_index = False
176+
177+
# If true, links to the reST sources are added to the pages.
178+
#html_show_sourcelink = True
179+
180+
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
181+
#html_show_sphinx = True
182+
183+
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
184+
#html_show_copyright = True
185+
186+
# If true, an OpenSearch description file will be output, and all pages will
187+
# contain a <link> tag referring to it. The value of this option must be the
188+
# base URL from which the finished HTML is served.
189+
#html_use_opensearch = ''
190+
191+
# This is the file name suffix for HTML files (e.g. ".xhtml").
192+
#html_file_suffix = None
193+
194+
# Language to be used for generating the HTML full-text search index.
195+
# Sphinx supports the following languages:
196+
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
197+
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
198+
#html_search_language = 'en'
199+
200+
# A dictionary with options for the search language support, empty by default.
201+
# Now only 'ja' uses this config value
202+
#html_search_options = {'type': 'default'}
203+
204+
# The name of a javascript file (relative to the configuration directory) that
205+
# implements a search results scorer. If empty, the default will be used.
206+
#html_search_scorer = 'scorer.js'
207+
208+
# Output file base name for HTML help builder.
209+
htmlhelp_basename = 'pbtestdoc'
210+
211+
# -- Options for LaTeX output ---------------------------------------------
212+
213+
latex_elements = {
214+
# The paper size ('letterpaper' or 'a4paper').
215+
#'papersize': 'letterpaper',
216+
217+
# The font size ('10pt', '11pt' or '12pt').
218+
#'pointsize': '10pt',
219+
220+
# Additional stuff for the LaTeX preamble.
221+
#'preamble': '',
222+
223+
# Latex figure (float) alignment
224+
#'figure_align': 'htbp',
225+
}
226+
227+
# Grouping the document tree into LaTeX files. List of tuples
228+
# (source start file, target name, title,
229+
# author, documentclass [howto, manual, or own class]).
230+
latex_documents = [
231+
(master_doc, 'pbtest.tex', u'pbtest Documentation',
232+
u'Sylvain Corlay', 'manual'),
233+
]
234+
235+
# The name of an image file (relative to this directory) to place at the top of
236+
# the title page.
237+
#latex_logo = None
238+
239+
# For "manual" documents, if this is true, then toplevel headings are parts,
240+
# not chapters.
241+
#latex_use_parts = False
242+
243+
# If true, show page references after internal links.
244+
#latex_show_pagerefs = False
245+
246+
# If true, show URL addresses after external links.
247+
#latex_show_urls = False
248+
249+
# Documents to append as an appendix to all manuals.
250+
#latex_appendices = []
251+
252+
# If false, no module index is generated.
253+
#latex_domain_indices = True
254+
255+
256+
# -- Options for manual page output ---------------------------------------
257+
258+
# One entry per manual page. List of tuples
259+
# (source start file, name, description, authors, manual section).
260+
man_pages = [
261+
(master_doc, 'pbtest', u'pbtest Documentation',
262+
[author], 1)
263+
]
264+
265+
# If true, show URL addresses after external links.
266+
#man_show_urls = False
267+
268+
269+
# -- Options for Texinfo output -------------------------------------------
270+
271+
# Grouping the document tree into Texinfo files. List of tuples
272+
# (source start file, target name, title, author,
273+
# dir menu entry, description, category)
274+
texinfo_documents = [
275+
(master_doc, 'pbtest', u'pbtest Documentation',
276+
author, 'pbtest', 'One line description of project.',
277+
'Miscellaneous'),
278+
]
279+
280+
# Documents to append as an appendix to all manuals.
281+
#texinfo_appendices = []
282+
283+
# If false, no module index is generated.
284+
#texinfo_domain_indices = True
285+
286+
# How to display URL addresses: 'footnote', 'no', or 'inline'.
287+
#texinfo_show_urls = 'footnote'
288+
289+
# If true, do not generate a @detailmenu in the "Top" node's menu.
290+
#texinfo_no_detailmenu = False
291+
292+
293+
# Example configuration for intersphinx: refer to the Python standard library.
294+
intersphinx_mapping = {'https://docs.python.org/': None}

‎docs/index.rst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PBTest Documentation
2+
====================
3+
4+
Contents:
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
9+
pbtest
10+

‎docs/make.bat

+263
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
@ECHO OFF
2+
3+
REM Command file for Sphinx documentation
4+
5+
if "%SPHINXBUILD%" == "" (
6+
set SPHINXBUILD=sphinx-build
7+
)
8+
set BUILDDIR=_build
9+
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
10+
set I18NSPHINXOPTS=%SPHINXOPTS% .
11+
if NOT "%PAPER%" == "" (
12+
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
13+
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
14+
)
15+
16+
if "%1" == "" goto help
17+
18+
if "%1" == "help" (
19+
:help
20+
echo.Please use `make ^<target^>` where ^<target^> is one of
21+
echo. html to make standalone HTML files
22+
echo. dirhtml to make HTML files named index.html in directories
23+
echo. singlehtml to make a single large HTML file
24+
echo. pickle to make pickle files
25+
echo. json to make JSON files
26+
echo. htmlhelp to make HTML files and a HTML help project
27+
echo. qthelp to make HTML files and a qthelp project
28+
echo. devhelp to make HTML files and a Devhelp project
29+
echo. epub to make an epub
30+
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
31+
echo. text to make text files
32+
echo. man to make manual pages
33+
echo. texinfo to make Texinfo files
34+
echo. gettext to make PO message catalogs
35+
echo. changes to make an overview over all changed/added/deprecated items
36+
echo. xml to make Docutils-native XML files
37+
echo. pseudoxml to make pseudoxml-XML files for display purposes
38+
echo. linkcheck to check all external links for integrity
39+
echo. doctest to run all doctests embedded in the documentation if enabled
40+
echo. coverage to run coverage check of the documentation if enabled
41+
goto end
42+
)
43+
44+
if "%1" == "clean" (
45+
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
46+
del /q /s %BUILDDIR%\*
47+
goto end
48+
)
49+
50+
51+
REM Check if sphinx-build is available and fallback to Python version if any
52+
%SPHINXBUILD% 1>NUL 2>NUL
53+
if errorlevel 9009 goto sphinx_python
54+
goto sphinx_ok
55+
56+
:sphinx_python
57+
58+
set SPHINXBUILD=python -m sphinx.__init__
59+
%SPHINXBUILD% 2> nul
60+
if errorlevel 9009 (
61+
echo.
62+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
63+
echo.installed, then set the SPHINXBUILD environment variable to point
64+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
65+
echo.may add the Sphinx directory to PATH.
66+
echo.
67+
echo.If you don't have Sphinx installed, grab it from
68+
echo.http://sphinx-doc.org/
69+
exit /b 1
70+
)
71+
72+
:sphinx_ok
73+
74+
75+
if "%1" == "html" (
76+
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
77+
if errorlevel 1 exit /b 1
78+
echo.
79+
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
80+
goto end
81+
)
82+
83+
if "%1" == "dirhtml" (
84+
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
85+
if errorlevel 1 exit /b 1
86+
echo.
87+
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
88+
goto end
89+
)
90+
91+
if "%1" == "singlehtml" (
92+
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
93+
if errorlevel 1 exit /b 1
94+
echo.
95+
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
96+
goto end
97+
)
98+
99+
if "%1" == "pickle" (
100+
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
101+
if errorlevel 1 exit /b 1
102+
echo.
103+
echo.Build finished; now you can process the pickle files.
104+
goto end
105+
)
106+
107+
if "%1" == "json" (
108+
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
109+
if errorlevel 1 exit /b 1
110+
echo.
111+
echo.Build finished; now you can process the JSON files.
112+
goto end
113+
)
114+
115+
if "%1" == "htmlhelp" (
116+
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
117+
if errorlevel 1 exit /b 1
118+
echo.
119+
echo.Build finished; now you can run HTML Help Workshop with the ^
120+
.hhp project file in %BUILDDIR%/htmlhelp.
121+
goto end
122+
)
123+
124+
if "%1" == "qthelp" (
125+
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
126+
if errorlevel 1 exit /b 1
127+
echo.
128+
echo.Build finished; now you can run "qcollectiongenerator" with the ^
129+
.qhcp project file in %BUILDDIR%/qthelp, like this:
130+
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\pbtest.qhcp
131+
echo.To view the help file:
132+
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\pbtest.ghc
133+
goto end
134+
)
135+
136+
if "%1" == "devhelp" (
137+
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
138+
if errorlevel 1 exit /b 1
139+
echo.
140+
echo.Build finished.
141+
goto end
142+
)
143+
144+
if "%1" == "epub" (
145+
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
146+
if errorlevel 1 exit /b 1
147+
echo.
148+
echo.Build finished. The epub file is in %BUILDDIR%/epub.
149+
goto end
150+
)
151+
152+
if "%1" == "latex" (
153+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
154+
if errorlevel 1 exit /b 1
155+
echo.
156+
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
157+
goto end
158+
)
159+
160+
if "%1" == "latexpdf" (
161+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
162+
cd %BUILDDIR%/latex
163+
make all-pdf
164+
cd %~dp0
165+
echo.
166+
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
167+
goto end
168+
)
169+
170+
if "%1" == "latexpdfja" (
171+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
172+
cd %BUILDDIR%/latex
173+
make all-pdf-ja
174+
cd %~dp0
175+
echo.
176+
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
177+
goto end
178+
)
179+
180+
if "%1" == "text" (
181+
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
182+
if errorlevel 1 exit /b 1
183+
echo.
184+
echo.Build finished. The text files are in %BUILDDIR%/text.
185+
goto end
186+
)
187+
188+
if "%1" == "man" (
189+
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
190+
if errorlevel 1 exit /b 1
191+
echo.
192+
echo.Build finished. The manual pages are in %BUILDDIR%/man.
193+
goto end
194+
)
195+
196+
if "%1" == "texinfo" (
197+
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
198+
if errorlevel 1 exit /b 1
199+
echo.
200+
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
201+
goto end
202+
)
203+
204+
if "%1" == "gettext" (
205+
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
206+
if errorlevel 1 exit /b 1
207+
echo.
208+
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
209+
goto end
210+
)
211+
212+
if "%1" == "changes" (
213+
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
214+
if errorlevel 1 exit /b 1
215+
echo.
216+
echo.The overview file is in %BUILDDIR%/changes.
217+
goto end
218+
)
219+
220+
if "%1" == "linkcheck" (
221+
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
222+
if errorlevel 1 exit /b 1
223+
echo.
224+
echo.Link check complete; look for any errors in the above output ^
225+
or in %BUILDDIR%/linkcheck/output.txt.
226+
goto end
227+
)
228+
229+
if "%1" == "doctest" (
230+
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
231+
if errorlevel 1 exit /b 1
232+
echo.
233+
echo.Testing of doctests in the sources finished, look at the ^
234+
results in %BUILDDIR%/doctest/output.txt.
235+
goto end
236+
)
237+
238+
if "%1" == "coverage" (
239+
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
240+
if errorlevel 1 exit /b 1
241+
echo.
242+
echo.Testing of coverage in the sources finished, look at the ^
243+
results in %BUILDDIR%/coverage/python.txt.
244+
goto end
245+
)
246+
247+
if "%1" == "xml" (
248+
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
249+
if errorlevel 1 exit /b 1
250+
echo.
251+
echo.Build finished. The XML files are in %BUILDDIR%/xml.
252+
goto end
253+
)
254+
255+
if "%1" == "pseudoxml" (
256+
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
257+
if errorlevel 1 exit /b 1
258+
echo.
259+
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
260+
goto end
261+
)
262+
263+
:end

‎docs/pbtest.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. automodule:: pbtest

‎py/main.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <pybind11/pybind11.h>
2+
3+
int add(int i, int j) {
4+
return i + j;
5+
}
6+
7+
int subtract(int i, int j) {
8+
return i - j;
9+
}
10+
11+
namespace py = pybind11;
12+
13+
PYBIND11_PLUGIN(pbtest) {
14+
py::module m("pbtest", R"pbdoc(
15+
Pybind11 example plugin
16+
-----------------------
17+
18+
.. currentmodule:: pbtest
19+
20+
.. autosummary::
21+
:toctree: _generate
22+
23+
add
24+
subtract
25+
)pbdoc");
26+
27+
m.def("add", &add, R"pbdoc(
28+
Add two numbers
29+
30+
Some other explanation about the add function.
31+
)pbdoc");
32+
33+
m.def("subtract", &subtract, R"pbdoc(
34+
Subtract two numbers
35+
36+
Some other explanation about the subtract function.
37+
)pbdoc");
38+
39+
return m.ptr();
40+
}

‎setup.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from setuptools import setup, Extension
2+
from setuptools.command.build_ext import build_ext
3+
import sys
4+
5+
ext_modules = [
6+
Extension(
7+
'pbtest',
8+
['py/main.cpp'],
9+
include_dirs=['include'],
10+
language='c++',
11+
),
12+
]
13+
14+
15+
class BuildExt(build_ext):
16+
"""A custom build extension for adding compiler-specific options."""
17+
c_opts = {
18+
'msvc': ['/EHsc'],
19+
'unix': ['-std=c++11'],
20+
}
21+
22+
if sys.platform == 'darwin':
23+
c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
24+
25+
def build_extensions(self):
26+
ct = self.compiler.compiler_type
27+
opts = self.c_opts.get(ct, [])
28+
for ext in self.extensions:
29+
ext.extra_compile_args = opts
30+
build_ext.build_extensions(self)
31+
32+
setup(
33+
name='pbtest',
34+
version='0.0.1',
35+
author='Sylvain Corlay',
36+
author_email='sylvain.corlay@gmail.com',
37+
url='https://github.com/SylvainCorlay/pbtest',
38+
description='A test project using pybind11',
39+
long_description='',
40+
ext_modules=ext_modules,
41+
install_requires=['pybind11'],
42+
cmdclass={'build_ext': BuildExt},
43+
)

0 commit comments

Comments
 (0)
Please sign in to comment.