pyOCIO Windows compilation error against Python36


renau...@...
 

I downloaded the latest OCIO code from GitHub (1.1.0) and I was able to compile OCIO using "Visual Studio 2015" as-well as pyOpenColorIO against Python27.

However when I tried to compile it against Python36 I get the following error:

...

9>  PyLogTransform.cpp
9>  PyLook.cpp
9>  PyLookTransform.cpp
9>  PyMain.cpp
9>D:\Development\Libraries\src\ocio\src\bindings\python\PyMain.cpp(153): error C2059: syntax error: '__declspec(dllexport)'
9>D:\Development\Libraries\src\ocio\src\bindings\python\PyMain.cpp(154): error C2143: syntax error: missing ';' before '{'
9>D:\Development\Libraries\src\ocio\src\bindings\python\PyMain.cpp(154): error C2447: '{': missing function header (old-style formal list?)

9>  PyMatrixTransform.cpp
9>  PyProcessor.cpp
9>  PyProcessorMetadata.cpp
9>  Generating Code...
9>  Compiling...
9>  PyRangeTransform.cpp
9>  PyTransform.cpp
9>  PyUtil.cpp
9>  Generating Code...
========== Build: 8 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Line 153 points to this :

OCIO_NAMESPACE_EXIT

MOD_INIT(PyOpenColorIO)
{
   
PyObject * m;
    MOD_DEF
(m, OCIO_STRINGIFY(PYOCIO_NAME), OCIO::OPENCOLORIO__DOC__, PyOCIO_methods);


MOD_INIT definition looks like this:

pyMain.cpp

...
#if PY_MAJOR_VERSION >= 3
 
#define MOD_ERROR_VAL NULL
 
#define MOD_SUCCESS_VAL(val) val
  #define MOD_INIT(name) PyMODINIT_FUNC EXPORT_SYMBOL PyInit_##name(void)
 
#define MOD_DEF(ob, name, doc, methods) \
         
static struct PyModuleDef moduledef = { \
           
PyModuleDef_HEAD_INIT, name, doc, -1, methods, NULL, NULL, NULL, NULL}; \
          ob
= PyModule_Create(&moduledef);

pyMODINIT_FUNC is defined here:

PyUtil.h

...
       
/* module init functions outside the core must be exported */
#                       if defined(__cplusplus)
#                               define PyMODINIT_FUNC extern "C" __declspec(dllexport) PyObject*
#                       else /* __cplusplus */
#                               define PyMODINIT_FUNC __declspec(dllexport) PyObject*
#                       endif /* __cplusplus */

and EXPORT_SYMBOL here:

PyUtil.h

#ifdef WIN32
    #define EXPORT_SYMBOL _declspec(dllexport)
#else
   
#define EXPORT_SYMBOL
#endif


I checked online to see if I could figure out what's causing the issue but I couldn't figure it out. Anybody would know why this is happening ?
Was anyone able to compile OCIO 1.1.0 | Win64 | Visual Studio 2015 | Python36 (official 64 bit build) ?

Thanks.


Richard Shaw <hobbe...@...>
 

On Sun, Jan 27, 2019 at 12:05 AM <renau...@...> wrote:
I downloaded the latest OCIO code from GitHub (1.1.0) and I was able to compile OCIO using "Visual Studio 2015" as-well as pyOpenColorIO against Python27.

I checked online to see if I could figure out what's causing the issue but I couldn't figure it out. Anybody would know why this is happening ?
Was anyone able to compile OCIO 1.1.0 | Win64 | Visual Studio 2015 | Python36 (official 64 bit build) ?

My guess is that it hasn't been updated for Python3 yet... There are some incompatible changes.

You can try a converter and see if it takes care of the errors but beware any unintended side effects...


Thanks,
Richard 


Patrick Hodoul <patric...@...>
 

Hi Guys,

 

Thanks for your investigations around Python 3. 

 

OCIO does not currently support Python 3. But it would be appreciated to have a pull request fixing the Python 3 support   :-)

 

Patrick.

 


On Sunday, January 27, 2019 at 1:04:35 PM UTC-5, Richard wrote:
On Sun, Jan 27, 2019 at 12:05 AM <rena...@...> wrote:
I downloaded the latest OCIO code from GitHub (1.1.0) and I was able to compile OCIO using "Visual Studio 2015" as-well as pyOpenColorIO against Python27.

I checked online to see if I could figure out what's causing the issue but I couldn't figure it out. Anybody would know why this is happening ?
Was anyone able to compile OCIO 1.1.0 | Win64 | Visual Studio 2015 | Python36 (official 64 bit build) ?

My guess is that it hasn't been updated for Python3 yet... There are some incompatible changes.

You can try a converter and see if it takes care of the errors but beware any unintended side effects...


Thanks,
Richard 


Richard Shaw <hobbe...@...>
 

I had completely forgotten that I moved the Fedora package over to Python 3.7 and haven't had any build issues... Now that being said I don't know if there's any consumers of the python library in Fedora...


Feel free to poke around the build logs...

Here's the spec file for building... Some of it won't make sense to you but you can review the settings / cmake options I use.


Thanks,
Richard


Renaud Talon <renau...@...>
 

Hi Richard,

 

Thank you for your suggestions, I did look into your diff files but I couldn’t find anything that’s not already added to the current versions of the files.

I got it to compile with Windows 10 / Python 3.6 – Visual Studio 2015, by changing the following line in “pyUtil.h” (line 65):

from :

  #define MOD_INIT(name) PyMODINIT_FUNC EXPORT_SYMBOL PyInit_##name(void)

 

to:

  #define MOD_INIT(name) EXPORT_SYMBOL PyMODINIT_FUNC PyInit_##name(void)

 

I did get a warning message though but the compilation process went through and the “.pyd” file was generated.

I’m honestly no C++ expert so I’m not sure if this makes sense but it seems to work. I need to run further testing next week to confirm but so far so good.

 

Thanks again,

Renaud

 

 


From: ocio...@... <oc...@...> on behalf of Richard Shaw <hob...@...>
Sent: Monday, February 4, 2019 8:45:08 AM
To: ocio...@...
Subject: Re: [ocio-dev] pyOCIO Windows compilation error against Python36
 
I had completely forgotten that I moved the Fedora package over to Python 3.7 and haven't had any build issues... Now that being said I don't know if there's any consumers of the python library in Fedora...


Feel free to poke around the build logs...

Here's the spec file for building... Some of it won't make sense to you but you can review the settings / cmake options I use.


Thanks,
Richard

--
You received this message because you are subscribed to the Google Groups "OpenColorIO Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ocio-dev+unsu...@....
For more options, visit https://groups.google.com/d/optout.


renaudtalon@...
 

Sorry for re-opening this so late. I did test the fix I thought work among other few things but I can't get OCIO to work with Python 3+ on Windows.
I tested with both OCIO 1.1 and OCIO 2.0 (master branch) and I can't compile against Python3. Any news on when this will be supported ?
Thank you.


Michael Dolan
 

I'm currently writing new Python bindings for OCIO (with pybind11, targeting the 2.0 release), which will support Python 3 (and 2). Stills a ways to go, but it's in the works.


On Wed, Oct 23, 2019 at 1:01 PM <renaudtalon@...> wrote:
Sorry for re-opening this so late. I did test the fix I thought work among other few things but I can't get OCIO to work with Python 3+ on Windows.
I tested with both OCIO 1.1 and OCIO 2.0 (master branch) and I can't compile against Python3. Any news on when this will be supported ?
Thank you.


renaudtalon@...
 

That's great news, thank you !