Skip to content

Conversation

envolution
Copy link
Contributor

… to setup.py

Allows glog detection as shared resource via cmake and includes it via setup.py as a macro. This was needed when directly calling cmake with '-DPYTHON_EXTENSIONS=ON'

@@ -112,6 +124,7 @@ if (PYTHON_EXTENSIONS)
add_dependencies(folly_python_cpp folly_python_bindings create_post_binding_symlink)
set_property(TARGET folly_python_cpp PROPERTY VERSION ${PACKAGE_VERSION})
target_compile_definitions(folly_python_cpp PRIVATE BOOST_NO_AUTO_PTR)
target_compile_definitions(folly_python_cpp PRIVATE GLOG_USE_GLOG_EXPORT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment I made down below in setup.py.

),
Extension(
"folly.iobuf",
sources=["folly/iobuf.pyx", "folly/iobuf_ext.cpp"],
libraries=["folly", "glog"],
define_macros=[("GLOG_USE_GLOG_EXPORT", "1")],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The export should only be needed when using glog as a .dll, right? There should already be something in the cmake config to detect and propagate that IIRC. (though I'm actually not sure if this python code path can actually make use of that detection in cmake)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've only been using glog as a shared library yes - without the macro export the python module compilation doesn't know how to locate the library.

Without the setup.py modifications:

[ 33%] Linking CXX shared library singleton_thread_local_overload.so
[ 33%] Built target singleton_thread_local_overload
/usr/lib/python3.13/site-packages/setuptools/__init__.py:92: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.

        By 2025-Oct-31, you need to update your project and remove deprecated calls
        or your builds will no longer be supported.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
running build_ext
building 'folly.executor' extension
/usr/bin/c++ -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -fPIC -I/Downloads/20250715174717_folly/folly/src/folly -I/Downloads/20250715174717_folly/folly/src/folly/build -I/usr/include -I/usr/include/libiberty -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include/python3.13 -c folly/ProactorExecutor.cpp -o build/temp.linux-x86_64-cpython-313/folly/ProactorExecutor.o
In file included from /Downloads/20250715174717_folly/folly/src/folly/folly/synchronization/HazptrObj.h:22,
                 from /Downloads/20250715174717_folly/folly/src/folly/folly/synchronization/HazptrDomain.h:27,
                 from /Downloads/20250715174717_folly/folly/src/folly/folly/synchronization/Hazptr.h:20,
                 from /Downloads/20250715174717_folly/folly/src/folly/folly/concurrency/detail/ConcurrentHashMap-detail.h:28,
                 from /Downloads/20250715174717_folly/folly/src/folly/folly/concurrency/ConcurrentHashMap.h:23,
                 from /Downloads/20250715174717_folly/folly/src/folly/folly/python/ProactorExecutor.h:19,
                 from folly/ProactorExecutor.cpp:17:
/usr/include/glog/logging.h:60:4: error: #error <glog/logging.h> was not included correctly. See the documentation for how to consume the library.
   60 | #  error <glog/logging.h> was not included correctly. See the documentation for how to consume the library.
      |    ^~~~~
In file included from /usr/include/glog/logging.h:63:
/usr/include/glog/flags.h:45:4: error: #error <glog/flags.h> was not included correctly. See the documentation for how to consume the library.
   45 | #  error <glog/flags.h> was not included correctly. See the documentation for how to consume the library.
      |    ^~~~~
In file included from /usr/include/glog/logging.h:77:
/usr/include/glog/log_severity.h:38:4: error: #error <glog/log_severity.h> was not included correctly. See the documentation for how to consume the library.
   38 | #  error <glog/log_severity.h> was not included correctly. See the documentation for how to consume the library.
      |    ^~~~~
In file included from /usr/include/glog/logging.h:78:
/usr/include/glog/vlog_is_on.h:71:4: error: #error <glog/vlog_is_on.h> was not included correctly. See the documentation for how to consume the library.
   71 | #  error <glog/vlog_is_on.h> was not included correctly. See the documentation for how to consume the library.
      |    ^~~~~
      ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants