Commit Graph

30 Commits

Author SHA1 Message Date
Maciek Starzyk
526b708f9d Update PyPI URLs 2018-09-11 09:49:49 +02:00
Elliott Sales de Andrade
53e0aa034b Update PyPI URLs. 2018-02-07 10:54:31 +01:00
Dean Moldovan
a80af9557d Add a dummy common.h header with a deprecation warning 2017-09-06 15:22:26 +02:00
Henry Schreiner
8b40505575 Utility for redirecting C++ streams to Python (#1009) 2017-08-25 02:12:43 +02:00
Dean Moldovan
1913f252d3 Fix setup.py detail headers and add pip install tests to Travis
The default `install_headers` from `distutils` flattens all the headers
into a single directory -- `detail` subdirectory was lost. This commit
fixes this by overriding the setup with a custom header installer.

Tests are added to Travis to make sure `setup.py sdist` and `pip install`
do not miss any headers and that the directory structure is preserved.

[skip appveyor]
2017-08-24 13:55:43 +02:00
Dean Moldovan
024932b379 Move everything related to internals into a separate detail header 2017-08-23 10:44:52 +02:00
Jason Rhinelander
464d98962d Allow binding factory functions as constructors
This allows you to use:

    cls.def(py::init(&factory_function));

where `factory_function` returns a pointer, holder, or value of the
class type (or a derived type).  Various compile-time checks
(static_asserts) are performed to ensure the function is valid, and
various run-time type checks where necessary.

Some other details of this feature:
- The `py::init` name doesn't conflict with the templated no-argument
  `py::init<...>()`, but keeps the naming consistent: the existing
  templated, no-argument one wraps constructors, the no-template,
  function-argument one wraps factory functions.
- If returning a CppClass (whether by value or pointer) when an CppAlias
  is required (i.e. python-side inheritance and a declared alias), a
  dynamic_cast to the alias is attempted (for the pointer version); if
  it fails, or if returned by value, an Alias(Class &&) constructor
  is invoked.  If this constructor doesn't exist, a runtime error occurs.
- for holder returns when an alias is required, we try a dynamic_cast of
  the wrapped pointer to the alias to see if it is already an alias
  instance; if it isn't, we raise an error.
- `py::init(class_factory, alias_factory)` is also available that takes
  two factories: the first is called when an alias is not needed, the
  second when it is.
- Reimplement factory instance clearing.  The previous implementation
  failed under python-side multiple inheritance: *each* inherited
  type's factory init would clear the instance instead of only setting
  its own type value.  The new implementation here clears just the
  relevant value pointer.
- dealloc is updated to explicitly set the leftover value pointer to
  nullptr and the `holder_constructed` flag to false so that it can be
  used to clear preallocated value without needing to rebuild the
  instance internals data.
- Added various tests to test out new allocation/deallocation code.
- With preallocation now done lazily, init factory holders can
  completely avoid the extra overhead of needing an extra
  allocation/deallocation.
- Updated documentation to make factory constructors the default
  advanced constructor style.
- If an `__init__` is called a second time, we have two choices: we can
  throw away the first instance, replacing it with the second; or we can
  ignore the second call.  The latter is slightly easier, so do that.
2017-08-17 09:33:27 -04:00
Dean Moldovan
f580649871 Move internal headers into detail subdirectory 2017-08-17 04:06:35 +02:00
Dean Moldovan
22c413b196 Add C++ interface for the Python interpreter 2017-05-28 02:12:24 +02:00
Jason Rhinelander
2b941b38b4 Add missing header to setup.py 2017-05-07 12:19:19 -04:00
Dean Moldovan
c91f8bd627 Reimplement static properties by extending PyProperty_Type
Instead of creating a new unique metaclass for each type, the builtin
`property` type is subclassed to support static properties. The new
setter/getters always pass types instead of instances in their `self`
argument. A metaclass is still required to support this behavior, but
it doesn't store any data anymore, so a new one doesn't need to be
created for each class. There is now only one common metaclass which
is shared by all pybind11 types.
2017-02-23 15:45:26 +01:00
Sylvain Corlay
d5ce82b6f5 CMake installation path consistency (#652)
* Add flag for installation of headers under python include directory

* Allow the disabling of distutils install_headers
2017-02-14 13:16:14 +01:00
Wenzel Jakob
0f294e26ac removed mdash characters from setup.py 2017-01-04 15:18:19 +01:00
Wenzel Jakob
2723a38820 minor setup.py updates 2017-01-01 17:14:27 +01:00
Alessandro Bacchini
9f13a30c6e Add missing C++ headers. Sort headers (#540) 2016-12-01 15:22:17 +01:00
Dean Moldovan
a0c1ccf0a9 Port tests to pytest
Use simple asserts and pytest's powerful introspection to make testing
simpler. This merges the old .py/.ref file pairs into simple .py files
where the expected values are right next to the code being tested.

This commit does not touch the C++ part of the code and replicates the
Python tests exactly like the old .ref-file-based approach.
2016-08-19 13:19:38 +02:00
Wenzel Jakob
25c03cecfa stl_bind redesign & cleanup pass 2016-05-16 12:12:58 +02:00
Wenzel Jakob
9e0a0568fe transparent conversion of dense and sparse Eigen types 2016-05-05 21:44:29 +02:00
Wenzel Jakob
8cb6cb33ef minor cleanups in common.h; updated author info and copyright year 2016-04-18 10:53:38 +02:00
Wenzel Jakob
d2385e8fc6 ready for version 1.3 2016-03-08 18:09:50 +01:00
Wenzel Jakob
4f972c0039 Revert of the revert of the python package with version information
This reverts commit bee8f16dbb.
2016-03-01 10:37:37 +01:00
Wenzel Jakob
bee8f16dbb removed 'pybind11' package which ultimately served no purpose 2016-02-22 17:29:30 +01:00
Wenzel Jakob
6f6c3bc7fc fixed tarball link in setup.py, added py 3.6 2016-02-07 17:37:40 +01:00
Sylvain Corlay
97dc81057f Add version info and release instructions for pybind11 2016-02-01 10:23:52 -05:00
Wenzel Jakob
48548ea4a5 general cleanup of the codebase
- new pybind11::base<> attribute to indicate a subclass relationship
- unified infrastructure for parsing variadic arguments in class_ and cpp_function
- use 'handle' and 'object' more consistently everywhere
2016-01-17 22:31:15 +01:00
Wenzel Jakob
678d787ca4 do more work with classes from pytypes.h (especially for STL container casting) 2016-01-17 22:31:15 +01:00
John Kirkham
dc97833f8d setup.py: Fix another dash to be ASCII so pip doesn't complain. 2015-12-04 16:22:25 -05:00
John Kirkham
c40f8c70dc setup.py: Fix dash to be ASCII so pip doesn't complain. 2015-12-04 16:21:23 -05:00
Wenzel Jakob
b456ec789d updated supported python version list in setup.py 2015-10-15 22:43:55 +02:00
Wenzel Jakob
929fd7e694 PyPI setup.py file; v1.0 release 2015-10-15 22:21:50 +02:00