pyOCIO Windows compilation error against Python36

48 views
Skip to first unread message

renau...@fusefx.com

unread,
Jan 27, 2019, 1:05:26 AM1/27/19
to OpenColorIO Developers
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

unread,
Jan 27, 2019, 1:04:35 PM1/27/19
to ocio...@googlegroups.com
On Sun, Jan 27, 2019 at 12:05 AM <renau...@fusefx.com> 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

unread,
Feb 1, 2019, 3:50:19 PM2/1/19
to OpenColorIO Developers

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.

Richard Shaw

unread,
Feb 4, 2019, 11:45:20 AM2/4/19
to ocio...@googlegroups.com
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

unread,
Feb 9, 2019, 3:56:59 AM2/9/19
to ocio...@googlegroups.com

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...@googlegroups.com <ocio...@googlegroups.com> on behalf of Richard Shaw <hobbe...@gmail.com>
Sent: Monday, February 4, 2019 8:45:08 AM
To: ocio...@googlegroups.com
Subject: Re: [ocio-dev] pyOCIO Windows compilation error against Python36
 
--
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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages