diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3124d4b8d..cd56769bb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -78,6 +78,15 @@ jobs: COVERALLS_PARALLEL: true run: coveralls --service=github + incremental_install: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: "Build incremental install" + run: docker build -t pysr -f pysr/test/incremental_install_simulator.dockerfile . + - name: "Test incremental install" + run: docker run --rm pysr /bin/bash -l -c 'python3 -m pysr.test main && python3 -m pysr.test env' + conda_test: runs-on: ${{ matrix.os }} defaults: diff --git a/pysr/julia_helpers.py b/pysr/julia_helpers.py index 5a61a1af9..9b57fff76 100644 --- a/pysr/julia_helpers.py +++ b/pysr/julia_helpers.py @@ -81,7 +81,20 @@ def install(julia_project=None, quiet=False, precompile=None): # pragma: no cov if precompile == False: os.environ["JULIA_PKG_PRECOMPILE_AUTO"] = "0" - julia.install(quiet=quiet) + try: + julia.install(quiet=quiet) + except julia.tools.PyCallInstallError: + # Attempt to reset PyCall.jl's build: + subprocess.run( + [ + "julia", + "-e", + f'ENV["PYTHON"] = "{sys.executable}"; import Pkg; Pkg.build("PyCall")', + ], + ) + # Try installing again: + julia.install(quiet=quiet) + Main, init_log = init_julia(julia_project, quiet=quiet, return_aux=True) io_arg = _get_io_arg(quiet) diff --git a/pysr/test/incremental_install_simulator.dockerfile b/pysr/test/incremental_install_simulator.dockerfile new file mode 100644 index 000000000..62811e8c3 --- /dev/null +++ b/pysr/test/incremental_install_simulator.dockerfile @@ -0,0 +1,52 @@ +# This dockerfile simulates a user installation that first +# builds PySR for Python 3.9, and then upgrades to Python 3.10. +# Normally this would cause an error when installing PyCall, so we want to +# ensure that PySR can automatically patch things. +FROM debian:bullseye-slim + +ENV DEBIAN_FRONTEND=noninteractive + +# Install juliaup and pyenv: +RUN apt-get update && apt-get install -y curl git build-essential \ + libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \ + libncurses5-dev libncursesw5-dev xz-utils libffi-dev liblzma-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Install juliaup: +RUN curl -fsSL https://install.julialang.org | sh -s -- -y + +# Install pyenv: +RUN curl -fsSL curl https://pyenv.run | sh && \ + echo 'export PATH="/root/.pyenv/bin:$PATH"' >> ~/.bashrc && \ + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc && \ + echo 'eval "$(pyenv init -)"' >> ~/.bashrc && \ + echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc + +# Default to using bash -l: +SHELL ["/bin/bash", "-l", "-c"] + +RUN juliaup add 1.8 && juliaup default 1.8 +RUN pyenv install 3.9.2 && pyenv global 3.9.2 +RUN python3 -m pip install --upgrade pip + +# Get PySR source: +WORKDIR /pysr +ADD ./requirements.txt /pysr/requirements.txt +RUN python3 -m pip install -r /pysr/requirements.txt + +ADD ./setup.py /pysr/setup.py +ADD ./pysr/ /pysr/pysr/ + +# First install of PySR: +RUN python3 -m pip install . +RUN python3 -m pysr install + +# Change Python version: +RUN pyenv install 3.10 && pyenv global 3.10 && pyenv uninstall -f 3.9.2 +RUN python3 -m pip install --upgrade pip + +# Second install of PySR: +RUN python3 -m pip install . +RUN rm -r ~/.julia/environments/pysr-* +RUN python3 -m pysr install diff --git a/pysr/version.py b/pysr/version.py index 5be325be2..33a210037 100644 --- a/pysr/version.py +++ b/pysr/version.py @@ -1,2 +1,2 @@ -__version__ = "0.14.2" +__version__ = "0.14.3" __symbolic_regression_jl_version__ = "0.19.1"