Skip to content

Commit

Permalink
Fix docs (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Jul 1, 2022
1 parent 60c9aeb commit 2e21ecc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
from abc import ABC
from datetime import datetime
from pathlib import Path
from unittest.mock import MagicMock, patch


try:
Expand All @@ -9,8 +11,33 @@
from importlib_metadata import metadata


def mock_rpy2():
# Can’t use autodoc_mock_imports as we import anndata2ri
patch('rpy2.situation.get_r_home', lambda: None).start()
sys.modules['rpy2.rinterface_lib'] = MagicMock()
submods = ['embedded', 'conversion', 'memorymanagement', 'sexp', 'bufferprotocol', 'callbacks', '_rinterface_capi']
sys.modules.update({f'rpy2.rinterface_lib.{sub}': MagicMock() for sub in submods})
sexp = sys.modules['rpy2.rinterface_lib'].sexp = sys.modules['rpy2.rinterface_lib.sexp']
sexp.Sexp = type('Sexp', (MagicMock, ABC), dict(__module__='rpy2.rinterface_lib.sexp'))
sexp.SexpEnvironment = type('SexpEnvironment', (sexp.Sexp,), dict(__module__='rpy2.rinterface_lib.sexp'))
sexp.SexpVector = sexp.StrSexpVector = MagicMock
sexp.SexpVector.from_iterable = MagicMock()

import rpy2.rinterface
import rpy2.rinterface_lib.sexp

rpy2.rinterface_lib = sys.modules['rpy2.rinterface_lib']
rpy2.rinterface._MissingArgType = object
rpy2.rinterface.initr_simple = lambda *_, **__: None

assert rpy2.rinterface_lib.sexp is sexp


HERE = Path(__file__).parent

mock_rpy2()

# now we can anndata2ri and our extensions
sys.path[:0] = [str(HERE.parent), str(HERE / 'ext')]


Expand Down

0 comments on commit 2e21ecc

Please sign in to comment.