Skip to content

Commit

Permalink
Refactor install.py to be ready for v2.3.0 (#190)
Browse files Browse the repository at this point in the history
Refactor and modularization of install.py

- Wrap single steps in install() and uninstall() functions as unit functions that takes parameters as common argument
- Allow --use-pip on all platforms. No more manual spglib installation >= 2.0.0
- Create a bash entry point blender to wrap LD_LIBRARY_PATH for original blender binary (unit-only)
- Create bash alias blender under current conda environment (unix-only)
- Refactor message output and add --dry-run option
- Installation by git hastag now working
  • Loading branch information
alchem0x2A committed Mar 17, 2023
1 parent 9861831 commit ca2ecbc
Show file tree
Hide file tree
Showing 7 changed files with 1,571 additions and 692 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/batoms_plugin_test.yaml
Expand Up @@ -67,7 +67,9 @@ jobs:
- name: Run blender unittests
run: |
cd tests
pytest -svv --ignore=test_default_preference.py --ignore=test_batomspy_shebang.py
pytest -svv --ignore=test_default_preference.py \
--ignore=test_batomspy_shebang.py \
--ignore=test_install_script.py
shebang-test:
runs-on: ubuntu-latest
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/test_install_script.yaml
Expand Up @@ -16,6 +16,43 @@ env:
BLENDER_DOWN_URL: "https://mirror.clarkson.edu/blender/release"

jobs:
unittest-linux:
defaults:
run:
shell: bash -l {0}
runs-on: ubuntu-latest
strategy:
matrix:
# For future tests we will only over 3 of the latest versions
blender_ver: ["3.4.1"]
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: batoms
python-version: "3.10"
mamba-version: "*"
channels: conda-forge,defaults
- name: Update libstdc++ and
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test &&\
sudo apt-get update &&\
sudo apt-get install -y libxxf86vm1 libstdc++6
- name: Download portable blender
run: |
echo Currently install in $(pwd)
VER=${{ matrix.blender_ver }}
MAJ_VER=${VER%.*}
echo $VER $MAJ_VER
URL="${BLENDER_DOWN_URL}/Blender${MAJ_VER}/blender-${VER}-linux-x64.tar.xz"
mkdir -p ../blender && curl -O ${URL} && tar -xvf blender-*-linux-x64.tar.xz -C ../blender
echo "BLENDER_ROOT=../blender/blender-${VER}-linux-x64/${MAJ_VER}" >> $GITHUB_ENV
- name: Pytest and dependencies
run: |
pip install pytest pyfakefs
- name: Run pytest
run: |
pytest -svv tests/test_install_script.py
install-linux:
defaults:
run:
Expand Down Expand Up @@ -53,6 +90,10 @@ jobs:
echo Use blender root ${BLENDER_ROOT}
$CONDA_PYTHON_EXE install.py ${BLENDER_ROOT}
command -v batomspy >/dev/null 2>&1 || { echo >&2 "No batomspy installed"; exit 1; }
# Test symlink blender
rm -rf ./blender-sl && ln -s ${BLENDER_ROOT}/../blender ./blender-sl
./blender-sl -b >/dev/null 2>&1 || { echo >&2 "Symlinking blender doesn't work!"; exit 1; }
rm -rf /tmp/blender
$CONDA_PYTHON_EXE install.py --uninstall ${BLENDER_ROOT}
! ( command -v batomspy >/dev/null 2>&1 ) || { echo >&2 "batomspy not removed"; exit 1; }
- name: Run installation script with startup and preferences
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -161,3 +161,5 @@ Miniconda3-*.sh
archive/
blender-*.tar.xz
blender-*/
*~
**/beautiful-atoms/
32 changes: 16 additions & 16 deletions Dockerfiles/Dockerfile.env
Expand Up @@ -20,19 +20,19 @@ ARG DEBIAN_FRONTEND noninteractive

# Install dependencies (copief from nytimes/rd-blender-docker)
RUN apt-get update && apt-get install -y \
wget \
libopenexr-dev \
bzip2 \
build-essential \
zlib1g-dev \
libxmu-dev \
libxi-dev \
libxxf86vm-dev \
wget \
libopenexr-dev \
bzip2 \
build-essential \
zlib1g-dev \
libxmu-dev \
libxi-dev \
libxxf86vm-dev \
libxkbcommon-x11-0 \
libfontconfig1 \
libxrender1 \
libgl1-mesa-glx \
xz-utils \
libfontconfig1 \
libxrender1 \
libgl1-mesa-glx \
xz-utils \
python3 \
python3-pip &&\
apt-get clean autoclean &&\
Expand Down Expand Up @@ -84,7 +84,7 @@ RUN wget --quiet https://repo.continuum.io/miniconda/Miniconda3-py39_${MINICONDA
-c conda-forge \
conda=${CONDA_VERSION} \
python=$PYTHON_VERSION \
pip &&\
pip mamba git curl&&\
conda update --all --quiet --yes &&\
conda clean --all -f -y

Expand All @@ -102,8 +102,8 @@ RUN . ${CONDA_DIR}/bin/activate &&\
ln -s ${CONDA_DIR} ${BLENDER_PATH}/python


RUN conda env update -n base --file ./env.yml &&\
conda clean --all -f -y &&\
RUN mamba env update -n base --file ./env.yml &&\
mamba clean --all -f -y &&\
rm -rf /tmp/*


Expand All @@ -113,7 +113,7 @@ ENV B_UID="1000"
ENV B_GID="100"
ENV HOME=/home/${B_USER}
# Force blender packages to use the conda lib
ENV LD_LIBRARY_PATH=$CONDA_DIR/lib:$LD_LIBRARY_PATH
# ENV LD_LIBRARY_PATH=$CONDA_DIR/lib:$LD_LIBRARY_PATH


# Add user
Expand Down
18 changes: 10 additions & 8 deletions Dockerfiles/Dockerfile.main
Expand Up @@ -21,13 +21,13 @@ USER root
#COPY batoms ${BLENDER_PATH}/scripts/addons_contrib/batoms
ADD ./ /tmp/beautiful-atoms/
RUN cd /tmp/beautiful-atoms &&\
conda init bash &&\
export CONDA_DEFAULT_ENV=base &&\
export CONDA_DIR=/opt/conda &&\
export CONDA_PREFIX=/opt/conda &&\
export CONDA_EXE=/opt/conda/bin/conda &&\
yes | python install.py -p ./ ${BLENDER_PATH} &&\
rm -rf /tmp/*
conda init bash &&\
export CONDA_DEFAULT_ENV=base &&\
export CONDA_DIR=/opt/conda &&\
export CONDA_PREFIX=/opt/conda &&\
export CONDA_EXE=/opt/conda/bin/conda &&\
yes | python install.py -p ./ ${BLENDER_PATH} &&\
rm -rf /tmp/*

RUN chown ${B_UID}:${B_GID} -R ${BLENDER_PATH} &&\
chmod 755 -R ${BLENDER_PATH} &&\
Expand All @@ -39,7 +39,9 @@ WORKDIR /workdir

# Enable batoms addon and test (under the user)
# remember to delete the temp log files under /tmp
RUN blender -b \
RUN blender -b --python-exit-code 1 \
--python-expr "import scipy.stats" &&\
blender -b \
--python-exit-code 1 \
--python-expr \
"import bpy; import addon_utils; addon_utils.enable('batoms', default_set=True); bpy.ops.wm.save_userpref(); print('success')" &&\
Expand Down

0 comments on commit ca2ecbc

Please sign in to comment.