Re: [C++-sig] With boost python tuple, how to loop over tuple items?

2020-01-30 Thread Jones, Torrin A (US)
If I remember correctly there is a len() function on the boost::python::object 
class.

len() is documented at the bottom of this page . . .

https://www.boost.org/doc/libs/1_66_0/libs/python/doc/html/reference/object_wrappers/boost_python_object_hpp.html

I can’t help with the ambiguity.


From: Cplusplus-sig 
 On Behalf Of 
HOUSSEN Franck
Sent: Wednesday, January 29, 2020 1:02 PM
To: cplusplus-sig@python.org
Subject: [C++-sig] With boost python tuple, how to loop over tuple items?

*** WARNING ***
EXTERNAL EMAIL -- This message originates from outside our organization.

With boost python tuple, how to loop over tuple items? In dummy.cpp attached, 
I'd like to get line 8 to work. Afterwards, I noticed line 7 does not even 
compile. How to get the length of a tuple (line 8), and, why there could be 
some ambiguity (line 7). Any help / clue is appreciated.
Franck
___
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 Jones, Torrin A (US)
You may need to set PYTHONPATH.  Search for PYTHONPATH on this page for a 
description.

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


From: Cplusplus-sig 
[mailto:cplusplus-sig-bounces+torrin.jones=baesystems@python.org] On Behalf 
Of Andrew Voelkel
Sent: Wednesday, May 22, 2019 10:56 AM
To: Development of Python/C++ integration 
Subject: [C++-sig] Getting simple boost.python extension to work outside the 
test scripts - HELP!

*** WARNING ***
EXTERNAL EMAIL -- This message originates from outside our organization.

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


Re: [C++-sig] Python support in boost::python (what version)

2019-05-22 Thread Jones, Torrin A (US)
What did you expect ? It's obvious that a given release of Boost.Python can not 
make any compatibility guarantees about future Python releases

. . .

What's your point, exactly ? What are you trying to do ?
You're right.  All I'm trying to do is gather information that I can submit and 
hopefully get approved.

I would *hope* that Boost.Python 1.66.0 was compatible with Python 3.6.4

Agreed.  That was just an example for illustration.  Not a criticism.  And 
since you made the point about the major and minor version of python and 
backward-compatibility that's something else for me to think about before I 
present something.

Thanks for your help on this.


From: Cplusplus-sig 
[mailto:cplusplus-sig-bounces+torrin.jones=baesystems@python.org] On Behalf 
Of Stefan Seefeld
Sent: Monday, May 20, 2019 9:16 AM
To: cplusplus-sig@python.org
Subject: Re: [C++-sig] Python support in boost::python (what version)

*** WARNING ***
EXTERNAL EMAIL -- This message originates from outside our organization.



On 2019-05-20 11:20 a.m., Jones, Torrin A (US) wrote:
For clarity, my boss is asking, "what version of python does boost python 
support?"  I was hoping there was some kind of table or something, but I guess 
the answer is something like, "It supports whatever version of python was out 
at the time that boost python was released?"  And then we can go back and look 
at release dates.  LOL.

What did you expect ? It's obvious that a given release of Boost.Python can not 
make any compatibility guarantees about future Python releases, unless, of 
course, Python itself promises to be fully backward compatible. That's 
precisely why the versioning scheme used by Python supports the distinction 
between "major" and "minor" version, to be able to make statements as to what 
degree of backward-compatibility to expect.
Ex: boost python 1.66.0 was released/tagged on Nov 17, 2017.  Python 3.6.3 was 
released on Oct 3, 2017.  Python 3.6.4 was released on Dec 19. 2017.  So in 
theory boost python 1.66.0 has support for Python 3.6.3, but does not have 
support for Python 3.6.4.  I know that's ludicrous but, I work in the corporate 
world so here we are.

What's your point, exactly ? What are you trying to do ?

(For the specific case, I would *hope* that Boost.Python 1.66.0 was compatible 
with Python 3.6.4, for the reason I cite above. But of course, there is no 
guarantee. Boost is Free Software, and its license 
(https://www.boost.org/users/license.html) clearly states that it is provided 
"...without warranty of any kind...". So make of it what you want.)

[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] Python support in boost::python (what version)

2019-05-20 Thread Jones, Torrin A (US)
Anything above version 2.2
OK, I understand what you are saying below, but there seems to be a little bit 
more to this . . .

Example: This was fixed in boost-1.67.0.  So in theory, nothing below boost 
python 1.67.0 supports Python 3.7.  I guess I didn't ask about older versions 
of boost python though.

https://github.com/boostorg/python/commit/660487c43fde76f3e64f1cb2e644500da92fe582

For clarity, my boss is asking, "what version of python does boost python 
support?"  I was hoping there was some kind of table or something, but I guess 
the answer is something like, "It supports whatever version of python was out 
at the time that boost python was released?"  And then we can go back and look 
at release dates.  LOL.

Ex: boost python 1.66.0 was released/tagged on Nov 17, 2017.  Python 3.6.3 was 
released on Oct 3, 2017.  Python 3.6.4 was released on Dec 19. 2017.  So in 
theory boost python 1.66.0 has support for Python 3.6.3, but does not have 
support for Python 3.6.4.  I know that's ludicrous but, I work in the corporate 
world so here we are.

There isn't another question here, but if you have any other thoughts on this 
please reply.


From: Cplusplus-sig 
[mailto:cplusplus-sig-bounces+torrin.jones=baesystems@python.org] On Behalf 
Of stefan
Sent: Thursday, May 16, 2019 12:57 PM
To: cplusplus-sig@python.org
Subject: Re: [C++-sig] Python support in boost::python (what version)

*** WARNING ***
EXTERNAL EMAIL -- This message originates from outside our organization.


On 2019-05-16 3:43 p.m., Jones, Torrin A (US) wrote:
What version of python does boost::python officially support?

Anything above version 2.2
I noticed in the python build file (see link below), it will only find from 
version 1.5 to 3.4.  Does this mean that boost python really only supports up 
to 3.4?  Folks do appear to be using other versions, but the fact that this 
only goes to 3.4 leads me to believe that is as far as it's been tested.  Is 
that right?

Definitely not. You are right, though: this file needs to be fixed. (I'm not 
maintaining this file myself, so I'll follow up with the relevant people 
(Boost.Build).)

Boost internally regularly builds and tests Boost.Python with versions > 3.4. 
and I know various distributions containing Boost.Python packages built against 
more recent Python versions.

See for example https://anaconda.org/anaconda/boost/files
What are the official versions?  Is there any documentation that says that?

Not really, as Boost only "officially" releases source packages. Users are free 
to compile against a large range of tools and prerequisites (compilers, Python 
versions, etc.).

If you find any issues building and running against a particular Python 
version, please file a bug report, and I'll try to help as quickly as possible.

[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] Python support in boost::python (what version)

2019-05-16 Thread Jones, Torrin A (US)
What version of python does boost::python officially support?  I noticed in the 
python build file (see link below), it will only find from version 1.5 to 3.4.  
Does this mean that boost python really only supports up to 3.4?  Folks do 
appear to be using other versions, but the fact that this only goes to 3.4 
leads me to believe that is as far as it's been tested.  Is that right?

What are the official versions?  Is there any documentation that says that?

https://github.com/boostorg/build/blob/develop/src/tools/python.jam#L401
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Calling python function repr from C++ using boost.python (possible?)

2019-03-10 Thread Jones, Torrin A (US)
This worked very well thanks.

-Original Message-
From: Stefan Ring [mailto:stefan...@gmail.com] 
Sent: Tuesday, March 05, 2019 12:04 PM
To: Development of Python/C++ integration 
Cc: Jones, Torrin A (US) 
Subject: Re: [C++-sig] Calling python function repr from C++ using boost.python 
(possible?)

*** WARNING ***
EXTERNAL EMAIL -- This message originates from outside our organization.


On Sat, Mar 2, 2019 at 6:12 PM Jones, Torrin A (US) 
 wrote:
>
> Is it possible to call repr from C++ on a C++ object that can be converted to 
> python?  Let me explain.
>
>
>
> I have an enum that I converted to python using boost::python::enum_().  That 
> class already provides a good repr() to python (thanks to the boost::python 
> developers for that).  However that enum is used as a type on a member in 
> another C++ class that I have where boost::python does not provide a good 
> repr().  So I’m trying to provide one and thought, it sure would be nice if I 
> could just call repr() on the member.  I assume I have to convert the value 
> on that member to python first, some kind of way then call repr?  Is that 
> possible?  Or is there a better way?
>
>
>
> Example:
>
>
>
> Typedef enum
>
> {
>
>V1 = 0,
>
>V2 = 5,
>
>V3 = 6
>
> } values;
>
>
>
> Class ValueExample
>
> {
>
>Public:
>
>   ValueExample(const values& v) {m_value = v};
>
>   Values getValue() const { return m_value };
>
>Private:
>
>   Values m_value;
>
> }
>
>
>
> Std::string
>
> ValueExampleRepr(const ValueExample& object)
>
> {
>
>Std::stringstream ss;
>
>
>
>// What do I put here?
>
>// Ss << repr(object.getValue());
>
>
>
>Return ss::str();
>
> }
>
>
>
> Boost::python::enum_ values(“values”);
>
> Values.value(“V1”, V1);
>
> Values.value(“V2”, V2);
>
> Values.value(“V3”, V3);
>
>
>
> Boost::python::class_ ValueExample(“ValueExample”);
>
>
>
> ValueExample(“__repr__”, ValueExampleRepr);

I can only come up with this:

Ss << 
extract(boost::python::object(object.getValue()).attr("__repr__")())();
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] Calling python function repr from C++ using boost.python (possible?)

2019-03-02 Thread Jones, Torrin A (US)
Is it possible to call repr from C++ on a C++ object that can be converted to 
python?  Let me explain.

I have an enum that I converted to python using boost::python::enum_().  That 
class already provides a good repr() to python (thanks to the boost::python 
developers for that).  However that enum is used as a type on a member in 
another C++ class that I have where boost::python does not provide a good 
repr().  So I'm trying to provide one and thought, it sure would be nice if I 
could just call repr() on the member.  I assume I have to convert the value on 
that member to python first, some kind of way then call repr?  Is that 
possible?  Or is there a better way?

Example:

Typedef enum
{
   V1 = 0,
   V2 = 5,
   V3 = 6
} values;

Class ValueExample
{
   Public:
  ValueExample(const values& v) {m_value = v};
  Values getValue() const { return m_value };
   Private:
  Values m_value;
}

Std::string
ValueExampleRepr(const ValueExample& object)
{
   Std::stringstream ss;

   // What do I put here?
   // Ss << repr(object.getValue());

   Return ss::str();
}

Boost::python::enum_ values("values");
Values.value("V1", V1);
Values.value("V2", V2);
Values.value("V3", V3);

Boost::python::class_ ValueExample("ValueExample");

ValueExample("__repr__", ValueExampleRepr);
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig