Skip to content

Python 3.7.0 support #144

@Dushistov

Description

@Dushistov

Since python 3.7 threading is not optional,
for example from here

Changed in version 3.7: This module used to be optional, it is now always available.

So it tells that no WITH_THREAD, but actually threading is enabled:

Python 3.7.0 (default, Jul 15 2018, 10:44:58) 
[GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> config = sysconfig.get_config_vars()
>>> print(config['WITH_THREAD'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'WITH_THREAD'
>>> 

and compilation of 1bdca22 failed on arch linux/x86_64

$ cargo build
   Compiling python3-sys v0.2.0 (file:///home/buildbot/rust-cpython/python3-sys)
   Compiling cpython v0.2.0 (file:///home/buildbot/rust-cpython)
warning: unused import: `c_uchar`
 --> python3-sys/src/code.rs:1:20
  |
1 | use libc::{c_void, c_uchar, c_char, c_int};
  |                    ^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error[E0425]: cannot find function `PyEval_ThreadsInitialized` in module `ffi`
  --> src/pythonrun.rs:55:26
   |
55 |             assert!(ffi::PyEval_ThreadsInitialized() != 0);
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `ffi`

to fix build I have to disable WITH_THREAD check:

diff --git a/python3-sys/src/ceval.rs b/python3-sys/src/ceval.rs
index ab67b12..b85f6a2 100644
--- a/python3-sys/src/ceval.rs
+++ b/python3-sys/src/ceval.rs
@@ -51,7 +51,6 @@ pub unsafe fn PyEval_CallObject(callable: *mut PyObject, arg: *mut PyObject) ->
     pub fn PyEval_RestoreThread(arg1: *mut PyThreadState) -> ();
 }
 
-#[cfg(py_sys_config = "WITH_THREAD")]
 #[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
     pub fn PyEval_ThreadsInitialized() -> c_int;
     pub fn PyEval_InitThreads() -> ();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions