Re: [C++-sig] Compiling boost python

2020-04-30 Thread Andrew Voelkel
The examples all use cmake, and there is a cmake extension for pybind11 that 
takes care of a number of things for you. From the docs:

For C++ codebases that have an existing CMake-based build system, a Python 
extension module can be created with just a few lines of code:
cmake_minimum_required(VERSION 2.8.12)
project(example)

add_subdirectory(pybind11)
pybind11_add_module(example example.cpp)

More here:

https://pybind11.readthedocs.io/en/stable/compiling.html#building-with-cmake


From: Cplusplus-sig 
 on behalf of 
Alain O' Miniussi 
Reply-To: Development of Python/C++ integration 
Date: Thursday, April 30, 2020 at 8:30 AM
To: Development of Python/C++ integration 
Subject: Re: [C++-sig] Compiling boost python

But having one more lib outside boost means one more dependency.

The sad thing is that dropping support for "the oldest and buggiest of compiler 
specimens" in Boost would be rational to do, there are plenty of old Boost 
releases for those.
How the cmake support for pybind ?

- On 29 Avr 20, at 20:09, Andrew Voelkel  wrote:

This blurb might help with that question:

The main issue with Boost.Python—and the reason for creating such a similar 
project—is Boost. Boost is an enormously large and complex suite of utility 
libraries that works with almost every C++ compiler in existence. This 
compatibility has its cost: arcane template tricks and workarounds are 
necessary to support the oldest and buggiest of compiler specimens. Now that 
C++11-compatible compilers are widely available, this heavy machinery has 
become an excessively large and unnecessary dependency. Think of this library 
as a tiny self-contained version of Boost.Python with everything stripped away 
that isn’t relevant for binding generation. Without comments, the core header 
files only require ~4K lines of code and depend on Python (2.7 or 3.x, or 
PyPy2.7 >= 5.7) and the C++ standard library. This compact implementation was 
possible thanks to some of the new C++11 language features (specifically: 
tuples, lambda functions and variadic templates). Since its creation, this 
library has grown beyond Boost.Python in many ways, leading to dramatically 
simpler binding code in many common situations.


  *   Andy

From: Cplusplus-sig 
 on behalf of 
Torsten Knüppel 
Reply-To: Development of Python/C++ integration 
Date: Wednesday, April 29, 2020 at 8:15 AM
To: Development of Python/C++ integration 
Subject: Re: [C++-sig] Re: Compiling boost python

Hi Andy,

thanks for the quick reply. I only came across pybind recently when I was 
encountering some dependency issues with boost.python<http://boost.python> and 
looked for an alternative. It looks really useful, but I hesitated to make the 
switch - but I think I will do it sooner or later. Maybe one question regarding 
pybind - is it easy to create bindings for different Python versions?
Am 29.04.20, 16:42 schrieb Andrew Voelkel :
Have you considered using pybind11? It’s the same basic idea as boost.python, 
but it is cleaner, much better supported and documented, and has a large user 
community. I just discovered this lately, have been using it, and I’m thrilled 
with it. The only catch is that you need to be compiling with at least a C++11 
compiler, but that is a pretty low bar these days.


  *   Andy

From: Cplusplus-sig 
 on behalf of 
Torsten Knüppel 
Reply-To: Development of Python/C++ integration 
Date: Wednesday, April 29, 2020 at 7:34 AM
To: "cplusplus-sig@python.org" 
Subject: [C++-sig] Compiling boost python

Dear all,

I'm trying to compile boost.python with a version of python, that I've 
downloaded and built myself.
Is the "No-install quickstart"-page 
(https://www.boost.org/doc/libs/1_73_0/libs/python/doc/html/building/no_install_quickstart.html)
 still updated, because some of the links are broken and
I honestly don't understand what is going on there.
Some questions that I have:
 - What is the bjam "build driver"? When I go to Section 5 of the boost Getting 
Started page - they mention something about an easy install option and another 
one for custom binaries.
  The entire page mentions neither bjam, nor "build driver".
 - I manage to build boost, by first running the bootstrap script and then 
calling b2 - if I select e.g. graph - it is built and copied into the correct 
directory, that I've specified. However,
   it doesn't work with my own Python folder.
  I wrote a small script to automate all steps:

#wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz
#tar -xvf boost_1_73_0.tar.gz
cd boost_1_73_0
./bootstrap.sh --prefix=../build_boost --with-libraries=python 
-with-python-root=../Python-3.6.10 --with-python-version=3.6
./b2 install -d+2
echo "using python : : ../Python-3.6.10/python ;" > user-config.jam

My folder structure is as follows:

buildBoost.sh (the script above)
 /Python-3.6.10 (contains the python source code and binaries that

Re: [C++-sig] Compiling boost python

2020-04-29 Thread Andrew Voelkel
This blurb might help with that question:

The main issue with Boost.Python—and the reason for creating such a similar 
project—is Boost. Boost is an enormously large and complex suite of utility 
libraries that works with almost every C++ compiler in existence. This 
compatibility has its cost: arcane template tricks and workarounds are 
necessary to support the oldest and buggiest of compiler specimens. Now that 
C++11-compatible compilers are widely available, this heavy machinery has 
become an excessively large and unnecessary dependency. Think of this library 
as a tiny self-contained version of Boost.Python with everything stripped away 
that isn’t relevant for binding generation. Without comments, the core header 
files only require ~4K lines of code and depend on Python (2.7 or 3.x, or 
PyPy2.7 >= 5.7) and the C++ standard library. This compact implementation was 
possible thanks to some of the new C++11 language features (specifically: 
tuples, lambda functions and variadic templates). Since its creation, this 
library has grown beyond Boost.Python in many ways, leading to dramatically 
simpler binding code in many common situations.


  *   Andy

From: Cplusplus-sig 
 on behalf of 
Torsten Knüppel 
Reply-To: Development of Python/C++ integration 
Date: Wednesday, April 29, 2020 at 8:15 AM
To: Development of Python/C++ integration 
Subject: Re: [C++-sig] Re: Compiling boost python

Hi Andy,

thanks for the quick reply. I only came across pybind recently when I was 
encountering some dependency issues with boost.python<http://boost.python> and 
looked for an alternative. It looks really useful, but I hesitated to make the 
switch - but I think I will do it sooner or later. Maybe one question regarding 
pybind - is it easy to create bindings for different Python versions?
Am 29.04.20, 16:42 schrieb Andrew Voelkel :
Have you considered using pybind11? It’s the same basic idea as boost.python, 
but it is cleaner, much better supported and documented, and has a large user 
community. I just discovered this lately, have been using it, and I’m thrilled 
with it. The only catch is that you need to be compiling with at least a C++11 
compiler, but that is a pretty low bar these days.


  *   Andy

From: Cplusplus-sig 
 on behalf of 
Torsten Knüppel 
Reply-To: Development of Python/C++ integration 
Date: Wednesday, April 29, 2020 at 7:34 AM
To: "cplusplus-sig@python.org" 
Subject: [C++-sig] Compiling boost python

Dear all,

I'm trying to compile boost.python with a version of python, that I've 
downloaded and built myself.
Is the "No-install quickstart"-page 
(https://www.boost.org/doc/libs/1_73_0/libs/python/doc/html/building/no_install_quickstart.html)
 still updated, because some of the links are broken and
I honestly don't understand what is going on there.
Some questions that I have:
 - What is the bjam "build driver"? When I go to Section 5 of the boost Getting 
Started page - they mention something about an easy install option and another 
one for custom binaries.
  The entire page mentions neither bjam, nor "build driver".
 - I manage to build boost, by first running the bootstrap script and then 
calling b2 - if I select e.g. graph - it is built and copied into the correct 
directory, that I've specified. However,
   it doesn't work with my own Python folder.
  I wrote a small script to automate all steps:

#wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz
#tar -xvf boost_1_73_0.tar.gz
cd boost_1_73_0
./bootstrap.sh --prefix=../build_boost --with-libraries=python 
-with-python-root=../Python-3.6.10 --with-python-version=3.6
./b2 install -d+2
echo "using python : : ../Python-3.6.10/python ;" > user-config.jam

My folder structure is as follows:

buildBoost.sh (the script above)
 /Python-3.6.10 (contains the python source code and binaries that I've 
build myself)
 /boost_1_73_0 (boost source code as downloaded by the script)
 /build_boost (output folder as specified by prefix)

When do I need to write this user-config.jam file? What are the compilation 
scripts looking for - can this process be debugged?
I also have boost installed via apt - now I think that everytime I call b2 or 
bjam it uses
the global versions of these programs, instead of the ones contained in the 
boost-directory I'm compiling - is that an issue?

Thanks in advance.
torsten
___ Cplusplus-sig mailing list 
Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Compiling boost python

2020-04-29 Thread Andrew Voelkel
Have you considered using pybind11? It’s the same basic idea as boost.python, 
but it is cleaner, much better supported and documented, and has a large user 
community. I just discovered this lately, have been using it, and I’m thrilled 
with it. The only catch is that you need to be compiling with at least a C++11 
compiler, but that is a pretty low bar these days.


  *   Andy

From: Cplusplus-sig 
 on behalf of 
Torsten Knüppel 
Reply-To: Development of Python/C++ integration 
Date: Wednesday, April 29, 2020 at 7:34 AM
To: "cplusplus-sig@python.org" 
Subject: [C++-sig] Compiling boost python

Dear all,

I'm trying to compile boost.python with a version of python, that I've 
downloaded and built myself.
Is the "No-install quickstart"-page 
(https://www.boost.org/doc/libs/1_73_0/libs/python/doc/html/building/no_install_quickstart.html)
 still updated, because some of the links are broken and
I honestly don't understand what is going on there.
Some questions that I have:
 - What is the bjam "build driver"? When I go to Section 5 of the boost Getting 
Started page - they mention something about an easy install option and another 
one for custom binaries.
  The entire page mentions neither bjam, nor "build driver".
 - I manage to build boost, by first running the bootstrap script and then 
calling b2 - if I select e.g. graph - it is built and copied into the correct 
directory, that I've specified. However,
   it doesn't work with my own Python folder.
  I wrote a small script to automate all steps:

#wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz
#tar -xvf boost_1_73_0.tar.gz
cd boost_1_73_0
./bootstrap.sh --prefix=../build_boost --with-libraries=python 
-with-python-root=../Python-3.6.10 --with-python-version=3.6
./b2 install -d+2
echo "using python : : ../Python-3.6.10/python ;" > user-config.jam

My folder structure is as follows:

buildBoost.sh (the script above)
 /Python-3.6.10 (contains the python source code and binaries that I've 
build myself)
 /boost_1_73_0 (boost source code as downloaded by the script)
 /build_boost (output folder as specified by prefix)

When do I need to write this user-config.jam file? What are the compilation 
scripts looking for - can this process be debugged?
I also have boost installed via apt - now I think that everytime I call b2 or 
bjam it uses
the global versions of these programs, instead of the ones contained in the 
boost-directory I'm compiling - is that an issue?

Thanks in advance.
torsten
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Getting simple boost.python extension to work outside the test scripts - HELP!

2019-05-22 Thread Andrew Voelkel
Nope, doesn’t help.

However, based on your input, I found install_name_tool and used it to modify 
hello_ext.so to point to the actual location. That works well, so at least I 
have a path forward with boost.python.

I’m not sure the bjam approach is buying me much compared to Xcode or make, but 
at least I’ve got it to work.


  *   Andy

From: Cplusplus-sig 
 on behalf of 
stefan 
Reply-To: Development of Python/C++ integration 
Date: Wednesday, May 22, 2019 at 11:36 AM
To: "cplusplus-sig@python.org" 
Subject: Re: [C++-sig] Getting simple boost.python extension to work outside 
the test scripts - HELP!



On 2019-05-22 2:30 p.m., Jones, Torrin A (US) wrote:
You may need to set PYTHONPATH.  Search for PYTHONPATH on this page for a 
description.

https://docs.python.org/3/using/cmdline.html

No, PYTHONPATH is used by the Python runtime to locate (Python) modules. It is 
not used to resolve shared library dependencies.
[Stefan]

--



  ...ich hab' noch einen Koffer in Berlin...


___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Getting simple boost.python extension to work outside the test scripts - HELP!

2019-05-22 Thread Andrew Voelkel
That is helpful. It might indeed be an issue with System Integrity Protection, 
now that I do the right google search.

But that leads to the second question. It is possible to indicate within 
hello_ext.so where to look for the dylib. Then in theory this wouldn’t a 
problem, because I wouldn’t need to set DYLD_LIBRARY_PATH.

Is this insertion of the path of libboost_python37.dylib into hello_ext.so 
something I can do with bjam, or am I going to have to figure out how to use a 
separate build system?


  *   Andy

From: Cplusplus-sig 
 on behalf of 
stefan 
Reply-To: Development of Python/C++ integration 
Date: Wednesday, May 22, 2019 at 11:07 AM
To: "cplusplus-sig@python.org" 
Subject: Re: [C++-sig] Getting simple boost.python extension to work outside 
the test scripts - HELP!



On 2019-05-22 1:55 p.m., Andrew Voelkel wrote:
What magic is the boost environment performing to make this work? What can I do 
to make my python extensions look for libboost_python37.dylib in the location 
where it lives?

Boost.Build does inject a variety of paths into the system-specific path 
variable (I believe on MacOS that would be DYLD_LIBRARY_PATH) such that test 
executables can locate any shared libs they require.

But I also remember having seen cases where some OSX releases specifically 
would prevent that mechanism from working due to some security concerns. I'm 
not a Mac user, so all of this is second-hand information.

Best,
[Stefan]

--



  ...ich hab' noch einen Koffer in Berlin...


___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] Getting simple boost.python extension to work outside the test scripts - HELP!

2019-05-22 Thread Andrew Voelkel
Hi,

I spent most of yesterday trying to get the simple tutorials and example to 
build from within the Boost example folders, and finally succeeded. It was not 
super straightforward as the instructions seem incomplete and out of date. But 
after finding a tutorial on Boost.Build and understanding how it works, I was 
able to debug the build process and get the test scripts to run successfully.

Now I’d like to move to Spyder and run simple tests on the extension. However, 
when I try to execute a simple “import hello_ext” statement, I get an error 
trying to locate a dependent library. No amount of setting paths seem to help.

(I copied libboost_python37.dylib to /Users/andy before running this script. 
I’m on Mac OS Mojave

Commands:


import os
print(os.environ['PATH'])
os.environ['PATH'] += ':/Users/andy'
os.environ['DYLD_LIBRARY_PATH'] = '/Users/andy'
print(os.environ['PATH'])
print(os.environ['DYLD_LIBRARY_PATH'])
import hello_ext

Output:

/Users/andy/anaconda3/bin:/Users/andy/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
/Users/andy/anaconda3/bin:/Users/andy/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/andy
/Users/andy
Traceback (most recent call last):

File "", line 7, in
import hello_ext

ImportError: dlopen(/Users/andy/Dropbox 
(Personal)/Developer/boost_1_70_0/libs/python/example/tutorial/hello_ext.so, 
2): Library not loaded: libboost_python37.dylib
Referenced from: /Users/andy/Dropbox 
(Personal)/Developer/boost_1_70_0/libs/python/example/tutorial/hello_ext.so
Reason: image not found
What magic is the boost environment performing to make this work? What can I do 
to make my python extensions look for libboost_python37.dylib in the location 
where it lives?

Thanks in advance for any help!


  *   Andy


___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] Boost.Python simple example won't build

2019-05-21 Thread Andrew Voelkel
Hello,

I am new to Boost.Python and am trying to follow the Getting Started 
instructions here:

https://www.boost.org/doc/libs/1_70_0/libs/python/doc/html/building/no_install_quickstart.html

The first step is to “get the bjam build driver” and I’m referred to section 5 
of the generic Boost Getting Started Guide. But section 5 of the generic 
Getting Started guide doesn’t explain how to “get the bjam build driver”, or 
explain what the bjam driver is or how it works.

So I followed all the instructions to build and install Boost itself under 
section 5 “Easy Build and Install” of the generic Boost Getting Started guide 
(https://www.boost.org/doc/libs/1_70_0/more/getting_started/unix-variants.html).
 But this also fails at the step “./b2 install”, apparently because include 
paths are not set up correctly. But there is no explanation of how to set up 
include paths, and after all I am not supposed to need a complete install 
anyway. And since I’m apparently using a build engine, rather than an existing 
makefile or such, I don’t know to configure the include paths, and I don’t know 
what they should be anyway.

So I should back up. Is there a version of quickstart instructions that doesn’t 
refer you to another guide which doesn’t seem to explain what is needed anyway? 
How do I “Get the bjam build driver”. And what is it anyway? Won’t I need to 
know something about it to use Boost.Python? I don’t need any of Boost except 
for Boost.Python.

Sorry for newbie question. I’m new to Boost, but I’m NOT a newbie programmer, 
so I’m probably some justified in being confused by the instructions.


  *   Andy


___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig