Skip to content

Commit

Permalink
Merge pull request #96 from paulsengroup/fix/stubs
Browse files Browse the repository at this point in the history
Fix stubgen
  • Loading branch information
robomics authored Oct 18, 2024
2 parents 01a03ca + 21ca9f4 commit 636336c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ target_link_libraries(

install(TARGETS _hictkpy LIBRARY DESTINATION hictkpy)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/hictkpy")
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/hictkpy/__init__.pyi")

# This properly escapes Windows paths
string(REPLACE "\\" "/" HICTKPY_PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR})
Expand All @@ -69,7 +68,6 @@ install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/NanobindStubgen.cmake")

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hictkpy/py.typed" DESTINATION hictkpy)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hictkpy/__init__.pyi" DESTINATION hictkpy)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hictkpy/hictkpy.pyi" DESTINATION hictkpy)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hictkpy/cooler.pyi" DESTINATION hictkpy)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hictkpy/hic.pyi" DESTINATION hictkpy)

Expand Down
9 changes: 5 additions & 4 deletions utils/devel/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ def make_cli() -> argparse.ArgumentParser:

def process_module(mod_name: str, out_file: str, force: bool):
print(f'Processing module "{mod_name}"...', file=sys.stderr)
sg = StubGen(importlib.import_module(mod_name))

if not force and os.path.exists(out_file):
raise RuntimeError(f'Refusing to overwrite file "{out_file}". Pass --force to overwrite.')

mod = importlib.import_module(mod_name)
sg = StubGen(mod)
sg.put(mod)

print(f'Writing stub to file "{out_file}"...', file=sys.stderr)
with open(out_file, "w") as f:
print(sg.get(), file=f)
Expand All @@ -52,10 +54,9 @@ def main():
pyarrow = importlib.import_module("pyarrow")
pyarrow.create_library_symlinks()

touch_file(os.path.join(args["output-dir"], "__init__.pyi"), args["force"])
touch_file(os.path.join(args["output-dir"], "py.typed"), args["force"])

process_module("hictkpy._hictkpy", os.path.join(args["output-dir"], "hictkpy.pyi"), args["force"])
process_module("hictkpy._hictkpy", os.path.join(args["output-dir"], "__init__.pyi"), args["force"])
process_module("hictkpy._hictkpy.cooler", os.path.join(args["output-dir"], "cooler.pyi"), args["force"])
process_module("hictkpy._hictkpy.hic", os.path.join(args["output-dir"], "hic.pyi"), args["force"])

Expand Down

0 comments on commit 636336c

Please sign in to comment.