Repository: sebp/scikit-survival (language: python)

Issue:
Unable to install the library for Windows10 Python3.11.1
**Describe the bug**

I have been trying to install the library on Windows10 with Python3.11.1 and pip 22.3.1

However, the installation had errors and didn't complete. 



error: subprocess-exited-with-error

**Code Sample to Reproduce the Bug**
`pip install scikit-survival`

**Expected Results**
The installation should be successful and finish without any issue 

**Actual Results**


```python
$ pip install scikit-survival
Collecting scikit-survival
  Using cached scikit-survival-0.19.0.post1.tar.gz (2.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [109 lines of output]

      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  free(self.riskset_left)

          def __reduce__(self):
              return (type(self), (self.n_outputs, self.n_samples, self.event_ti
mes), self.__getstate__())

          cdef int init(self, const DOUBLE_t[:, ::1] y, DOUBLE_t* sample_weight,
              ^
      ------------------------------------------------------------

      sksurv\tree\_criterion.pyx:131:9: Signature not compatible with previous d
eclaration

      Error compiling Cython file:
      ------------------------------------------------------------
      ...

          # The criterion object is maintained such that left and right collecte
d
          # statistics correspond to samples[start:pos] and samples[pos:end].

          # Methods
          cdef int init(
                      ^
      ------------------------------------------------------------

      C:\Users\User\AppData\Local\Temp\pip-build-env-h0wsz9mp\overlay\Lib\site-p
ackages\sklearn\tree\_criterion.pxd:44:17: Previous declaration is here

      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cdef Riskset * riskset_total
          cdef Riskset * riskset_left

          def __cinit__(self, SIZE_t n_outputs, SIZE_t n_samples, const DOUBLE_t
[::1] event_times):
              # Default values
              self.sample_weight = NULL
                                  ^
      ------------------------------------------------------------

      sksurv\tree\_criterion.pyx:102:29: Cannot convert 'void *' to memoryviewsl
ice

      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                        SIZE_t end) nogil except -1:
              """Initialize the criterion at node samples[start:end] and
                 children samples[start:start] and samples[start:end]."""
              # Initialize fields
              self.y = y
              self.sample_weight = sample_weight
                                  ^
      ------------------------------------------------------------

      sksurv\tree\_criterion.pyx:138:29: Cannot convert 'DOUBLE_t *' to memoryvi
ewslice

      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              self.pos = self.end
              return 0

          cdef int update(self, SIZE_t new_pos) nogil except -1:
              """Updated statistics by moving samples[pos:new_pos] to the left."
""
              cdef const double* sample_weight = self.sample_weight
                                                    ^
      ------------------------------------------------------------

      sksurv\tree\_criterion.pyx:209:47: Cannot assign type 'const DOUBLE_t[:]'
to 'const double *'
      Compiling sksurv/bintrees/_binarytrees.pyx because it changed.
      Compiling sksurv/kernels/_clinical_kernel.pyx because it changed.
      Compiling sksurv/ensemble/_coxph_loss.pyx because it changed.
      Compiling sksurv/svm/_prsvm.pyx because it changed.
      Compiling sksurv/svm/_minlip.pyx because it changed.
      Compiling sksurv/tree/_criterion.pyx because it changed.
      Compiling sksurv/linear_model/_coxnet.pyx because it changed.
      [1/7] Cythonizing sksurv/bintrees/_binarytrees.pyx
      [2/7] Cythonizing sksurv/ensemble/_coxph_loss.pyx
      [3/7] Cythonizing sksurv/kernels/_clinical_kernel.pyx
      [4/7] Cythonizing sksurv/linear_model/_coxnet.pyx
      [5/7] Cythonizing sksurv/svm/_minlip.pyx
      [6/7] Cythonizing sksurv/svm/_prsvm.pyx
      [7/7] Cythonizing sksurv/tree/_criterion.pyx
      Traceback (most recent call last):
        File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-pac
kages\pip\_vendor\pep517\in_process\_in_process.py", line 351, in <module>
          main()
        File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-pac
kages\pip\_vendor\pep517\in_process\_in_process.py", line 333, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-pac
kages\pip\_vendor\pep517\in_process\_in_process.py", line 118, in get_requires_f
or_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\User\AppData\Local\Temp\pip-build-env-h0wsz9mp\overlay\Li
b\site-packages\setuptools\build_meta.py", line 338, in get_requires_for_build_w
heel
          return self._get_build_requires(config_settings, requirements=['wheel'
])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^
        File "C:\Users\User\AppData\Local\Temp\pip-build-env-h0wsz9mp\overlay\Li
b\site-packages\setuptools\build_meta.py", line 320, in _get_build_requires
          self.run_setup()
        File "C:\Users\User\AppData\Local\Temp\pip-build-env-h0wsz9mp\overlay\Li
b\site-packages\setuptools\build_meta.py", line 335, in run_setup
          exec(code, locals())
        File "<string>", line 222, in <module>
        File "<string>", line 195, in setup_package
        File "<string>", line 175, in get_extensions
        File "<string>", line 139, in cythonize_extensions
        File "C:\Users\User\AppData\Local\Temp\pip-build-env-h0wsz9mp\overlay\Li
b\site-packages\Cython\Build\Dependencies.py", line 1112, in cythonize
          cythonize_one(*args)
        File "C:\Users\User\AppData\Local\Temp\pip-build-env-h0wsz9mp\overlay\Li
b\site-packages\Cython\Build\Dependencies.py", line 1235, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: sksurv/tree/_criterion.pyx
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem wit
h pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with
pip.

```


**Versions**
Please execute the following snippet and paste the output below.

```python
import sklearn; sklearn.show_versions()
import sksurv; print("sksurv:", sksurv.__version__)
import cvxopt; print("cvxopt:", cvxopt.__version__)
import cvxpy; print("cvxpy:", cvxpy.__version__)
import numexpr; print("numexpr:", numexpr.__version__)
import osqp; print("osqp:", osqp.OSQP().version())
```


```
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn; sklearn.show_versions()

System:
    python: 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
executable: C:\Users\User\AppData\Local\Programs\Python\Python311\python.exe
   machine: Windows-10-10.0.19045-SP0

Python dependencies:
      sklearn: 1.2.0
          pip: 22.3.1
   setuptools: 65.5.0
        numpy: 1.24.1
        scipy: 1.10.0
       Cython: None
       pandas: 1.5.2
   matplotlib: 3.6.3
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: vcomp
       filepath: C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy\.libs\libopenblas64__v0.3.21-gcc_10_3_0.dll
        version: 0.3.21
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy.libs\libopenblas-802f9ed1179cb9c9b03d67ff79f48187.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8
>>> import sksurv; print("sksurv:", sksurv.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sksurv'
>>> import cvxopt; print("cvxopt:", cvxopt.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cvxopt'
>>> import cvxpy; print("cvxpy:", cvxpy.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cvxpy'
>>> import numexpr; print("numexpr:", numexpr.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numexpr'
>>> import osqp; print("osqp:", osqp.OSQP().version())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'osqp'
```


Discussion / hints:
Python 3.11 is not supported yet


Fix patch:
diff --git a/appveyor.yml b/appveyor.yml
index c0b678fc..51e79667 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -11,6 +11,8 @@ environment:
       CONDA_PY: "39"
     - TARGET_ARCH: "x64"
       CONDA_PY: "310"
+    - TARGET_ARCH: "x64"
+      CONDA_PY: "311"
 
 
 # We always use a 64-bit machine.
diff --git a/ci/appveyor/requirements_310.yaml b/ci/appveyor/requirements_310.yaml
index ddb02ac4..d1290af5 100644
--- a/ci/appveyor/requirements_310.yaml
+++ b/ci/appveyor/requirements_310.yaml
@@ -4,13 +4,13 @@ channels:
   - sebp
 dependencies:
   - python=3.10
+  - coverage
   - cython>=0.29
   - ecos
   - numexpr
   - numpy=1.21
   - osqp!=0.6.0,!=0.6.1
   - pytest
-  - pytest-cov
   - scipy!=1.3.0
   - scikit-learn=1.2
   - pandas=1.4
diff --git a/ci/appveyor/requirements_311.yaml b/ci/appveyor/requirements_311.yaml
new file mode 100644
index 00000000..dbffddbf
--- /dev/null
+++ b/ci/appveyor/requirements_311.yaml
@@ -0,0 +1,16 @@
+name: sksurv-test
+channels:
+  - defaults
+  - sebp
+dependencies:
+  - python=3.11
+  - coverage
+  - cython>=0.29
+  - ecos
+  - numexpr
+  - numpy=1.23
+  - osqp!=0.6.0,!=0.6.1
+  - pytest
+  - scipy!=1.3.0
+  - scikit-learn=1.2
+  - pandas=1.5
diff --git a/ci/appveyor/requirements_38.yaml b/ci/appveyor/requirements_38.yaml
index ed7518c4..d8c8cd5a 100644
--- a/ci/appveyor/requirements_38.yaml
+++ b/ci/appveyor/requirements_38.yaml
@@ -4,13 +4,13 @@ channels:
   - sebp
 dependencies:
   - python=3.8
+  - coverage
   - cython>=0.29
   - ecos
   - numexpr
   - numpy=1.19
   - osqp!=0.6.0,!=0.6.1
   - pytest
-  - pytest-cov
   - scipy!=1.3.0
   - scikit-learn=1.2
   - pandas=1.1
diff --git a/ci/appveyor/requirements_39.yaml b/ci/appveyor/requirements_39.yaml
index 55979eba..e48765c8 100644
--- a/ci/appveyor/requirements_39.yaml
+++ b/ci/appveyor/requirements_39.yaml
@@ -4,13 +4,13 @@ channels:
   - sebp
 dependencies:
   - python=3.9
+  - coverage
   - cython>=0.29
   - ecos
   - numexpr
   - numpy=1.21
   - osqp!=0.6.0,!=0.6.1
   - pytest
-  - pytest-cov
   - scipy!=1.3.0
   - scikit-learn=1.2
   - pandas=1.3
diff --git a/ci/deps/py310_pandas14_numpy121_sklearn12.sh b/ci/deps/py310_pandas14_numpy121_sklearn12.sh
index 130fe741..b72aa690 100644
--- a/ci/deps/py310_pandas14_numpy121_sklearn12.sh
+++ b/ci/deps/py310_pandas14_numpy121_sklearn12.sh
@@ -3,4 +3,4 @@ export CONDA_PYTHON_VERSION='3.10.*'
 export PANDAS_VERSION='1.4.*'
 export NUMPY_VERSION='1.21.*'
 export SKLEARN_VERSION='1.2.*'
-export NO_SLOW=false
+export NO_SLOW=true
diff --git a/ci/deps/py311_pandas15_numpy123_sklearn12.sh b/ci/deps/py311_pandas15_numpy123_sklearn12.sh
new file mode 100644
index 00000000..fd8d74fb
--- /dev/null
+++ b/ci/deps/py311_pandas15_numpy123_sklearn12.sh
@@ -0,0 +1,6 @@
+# shellcheck shell=sh
+export CONDA_PYTHON_VERSION='3.11.*'
+export PANDAS_VERSION='1.5.*    '
+export NUMPY_VERSION='1.23.*'
+export SKLEARN_VERSION='1.2.*'
+export NO_SLOW=false
diff --git a/ci/deps/py38_pandas11_numpy120_sklearn12.sh b/ci/deps/py38_pandas11_numpy120_sklearn12.sh
deleted file mode 100644
index 16ff7de8..00000000
--- a/ci/deps/py38_pandas11_numpy120_sklearn12.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-# shellcheck shell=sh
-export CONDA_PYTHON_VERSION='3.8.*'
-export PANDAS_VERSION='1.1.*'
-export NUMPY_VERSION='1.20.*'
-export SKLEARN_VERSION='1.2.*'
-export NO_SLOW=true
diff --git a/pyproject.toml b/pyproject.toml
index 36832ccc..24e49c46 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -20,7 +20,8 @@ requires = [
     # scikit-learn requirements
     "scikit-learn~=1.2.0; python_version<='3.9'",
     "scikit-learn~=1.2.0; python_version=='3.10'",
-    "scikit-learn; python_version>'3.10'",
+    "scikit-learn~=1.2.0; python_version=='3.11'",
+    "scikit-learn; python_version>'3.11'",
 ]
 build-backend = "setuptools.build_meta"
 


Test patch:
diff --git a/.github/workflows/tests-workflow.yaml b/.github/workflows/tests-workflow.yaml
index 23ac9827..d5cded7d 100644
--- a/.github/workflows/tests-workflow.yaml
+++ b/.github/workflows/tests-workflow.yaml
@@ -13,9 +13,9 @@ jobs:
       matrix:
         config:
           - py38_pandas10_numpy119_sklearn12
-          - py38_pandas11_numpy120_sklearn12
           - py39_pandas13_numpy121_sklearn12
           - py310_pandas14_numpy121_sklearn12
+          - py311_pandas15_numpy123_sklearn12
         runner:
           - ubuntu-latest
           - macos-latest