Skip to content

Commit

Permalink
pre-install command on readthedocs to fix sisl-test
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Aug 10, 2024
1 parent 6944862 commit 24ba52e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .readthedocs-pre_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# Pre-install commands for read-the-docs
#
set -euxo pipefail

if [[ "${READTHEDOCS:-no}" == "no" ]]; then
echo "This script is only intended to be run in the read-the-docs environment"
exit 1
fi

# Fix the code in src/sisl/_environ to make it always point to the correct path
sed -i -s -e "s:_THIS_DIRECTORY_DOES_NOT_EXIST_:$READTHEDOCS_REPOSITORY_PATH/files/tests:" src/sisl/_environ.py
3 changes: 3 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ build:
- gfortran
tools:
python: "latest"
jobs:
pre_install:
- ./.readthedocs-pre_install.sh

sphinx:
configuration: docs/conf.py
Expand Down
6 changes: 1 addition & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
os.environ["SISL_NUM_PROCS"] = "1"
os.environ["SISL_VIZ_NUM_PROCS"] = "1"

if "SISL_FILES_TESTS" not in os.environ:
os.environ["SISL_FILES_TESTS"] = str(_root / "files" / "tests")


# Print standard information about executable and path...
print("python exec:", sys.executable)
print("sys.path:", sys.path)
Expand All @@ -54,7 +50,7 @@
print(f"Located sisl here: {sisl.__path__}")

# Figure out if we can locate the tests:
sisl_files_tests = sisl.get_environ_variable("SISL_FILES_TESTS")
sisl_files_tests = os.environ.get("SISL_FILES_TESTS", "-unknown-directory-")
print(f"SISL_FILES_TESTS: {sisl_files_tests}")
print(" is directory: ", sisl_files_tests.is_dir())
if sisl_files_tests.is_dir():
Expand Down

0 comments on commit 24ba52e

Please sign in to comment.