Skip to content

Commit 2c4d7e9

Browse files
authored
Merge pull request #363 from MilesCranmer/pycall-install-help
Get incremental installs to automatically work
2 parents e74b8ad + 61ddc76 commit 2c4d7e9

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

.github/workflows/CI.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ jobs:
7878
COVERALLS_PARALLEL: true
7979
run: coveralls --service=github
8080

81+
incremental_install:
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v2
85+
- name: "Build incremental install"
86+
run: docker build -t pysr -f pysr/test/incremental_install_simulator.dockerfile .
87+
- name: "Test incremental install"
88+
run: docker run --rm pysr /bin/bash -l -c 'python3 -m pysr.test main && python3 -m pysr.test env'
89+
8190
conda_test:
8291
runs-on: ${{ matrix.os }}
8392
defaults:

pysr/julia_helpers.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,20 @@ def install(julia_project=None, quiet=False, precompile=None): # pragma: no cov
8181
if precompile == False:
8282
os.environ["JULIA_PKG_PRECOMPILE_AUTO"] = "0"
8383

84-
julia.install(quiet=quiet)
84+
try:
85+
julia.install(quiet=quiet)
86+
except julia.tools.PyCallInstallError:
87+
# Attempt to reset PyCall.jl's build:
88+
subprocess.run(
89+
[
90+
"julia",
91+
"-e",
92+
f'ENV["PYTHON"] = "{sys.executable}"; import Pkg; Pkg.build("PyCall")',
93+
],
94+
)
95+
# Try installing again:
96+
julia.install(quiet=quiet)
97+
8598
Main, init_log = init_julia(julia_project, quiet=quiet, return_aux=True)
8699
io_arg = _get_io_arg(quiet)
87100

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This dockerfile simulates a user installation that first
2+
# builds PySR for Python 3.9, and then upgrades to Python 3.10.
3+
# Normally this would cause an error when installing PyCall, so we want to
4+
# ensure that PySR can automatically patch things.
5+
FROM debian:bullseye-slim
6+
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
9+
# Install juliaup and pyenv:
10+
RUN apt-get update && apt-get install -y curl git build-essential \
11+
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
12+
libncurses5-dev libncursesw5-dev xz-utils libffi-dev liblzma-dev && \
13+
apt-get clean && \
14+
rm -rf /var/lib/apt/lists/*
15+
16+
# Install juliaup:
17+
RUN curl -fsSL https://install.julialang.org | sh -s -- -y
18+
19+
# Install pyenv:
20+
RUN curl -fsSL curl https://pyenv.run | sh && \
21+
echo 'export PATH="/root/.pyenv/bin:$PATH"' >> ~/.bashrc && \
22+
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc && \
23+
echo 'eval "$(pyenv init -)"' >> ~/.bashrc && \
24+
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
25+
26+
# Default to using bash -l:
27+
SHELL ["/bin/bash", "-l", "-c"]
28+
29+
RUN juliaup add 1.8 && juliaup default 1.8
30+
RUN pyenv install 3.9.2 && pyenv global 3.9.2
31+
RUN python3 -m pip install --upgrade pip
32+
33+
# Get PySR source:
34+
WORKDIR /pysr
35+
ADD ./requirements.txt /pysr/requirements.txt
36+
RUN python3 -m pip install -r /pysr/requirements.txt
37+
38+
ADD ./setup.py /pysr/setup.py
39+
ADD ./pysr/ /pysr/pysr/
40+
41+
# First install of PySR:
42+
RUN python3 -m pip install .
43+
RUN python3 -m pysr install
44+
45+
# Change Python version:
46+
RUN pyenv install 3.10 && pyenv global 3.10 && pyenv uninstall -f 3.9.2
47+
RUN python3 -m pip install --upgrade pip
48+
49+
# Second install of PySR:
50+
RUN python3 -m pip install .
51+
RUN rm -r ~/.julia/environments/pysr-*
52+
RUN python3 -m pysr install

pysr/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.14.2"
1+
__version__ = "0.14.3"
22
__symbolic_regression_jl_version__ = "0.19.1"

0 commit comments

Comments
 (0)