Skip to content

Commit e0904e6

Browse files
Merge pull request #204 from mloubout/install-tweaks
tweak deps
2 parents fbeb306 + 7f8e187 commit e0904e6

File tree

3 files changed

+119
-85
lines changed

3 files changed

+119
-85
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
- lts
1616
- 1 # automatically expands to the latest stable 1.x release of Julia
1717
devitoversion:
18-
- 'devito'
18+
- 'main'
1919
- 'devitopro'
20+
- ''
2021
os:
2122
- ubuntu-latest
2223
arch:
@@ -28,38 +29,48 @@ jobs:
2829
version: ${{ matrix.version }}
2930
arch: ${{ matrix.arch }}
3031
- uses: julia-actions/cache@v1
32+
3133
- name: install mpi
3234
run: sudo apt-get update
3335
- run: sudo apt-get install -y mpich libmpich-dev
36+
3437
- name: download miniconda manually
35-
run: wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
38+
run: wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.5.0-0-Linux-x86_64.sh
39+
3640
- name: run install
37-
run: bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda
41+
run: bash Miniconda3-py312_24.5.0-0-Linux-x86_64.sh -b -p $HOME/miniconda
42+
3843
- name: run path export
39-
run: export PATH=~/miniconda/bin:${PATH}
44+
run: |
45+
echo "$HOME/miniconda/bin:" >> $GITHUB_PATH
46+
echo "PYTHON=$HOME/miniconda/bin/python3" >> $GITHUB_ENV
47+
echo "PYCALL_JL_RUNTIME_PYTHON=$HOME/miniconda/bin/python3" >> $GITHUB_ENV
48+
echo "CONDA_EXE=$HOME/miniconda/bin/conda" >> $GITHUB_ENV
49+
4050
- name: use system MPI
4151
run: julia -e 'using Pkg; Pkg.add(["MPI", "MPIPreferences"]); using MPIPreferences; MPIPreferences.use_system_binary()'
52+
4253
- name: run build for devito/devitopro
4354
if: matrix.devitoversion == 'devitopro'
4455
run: julia --color=yes --project -e 'using Pkg; Pkg.build(verbose=true)'
45-
shell: bash
4656
env:
47-
PYTHON: '~/miniconda/bin/python3'
4857
DEVITO_PRO: ${{ secrets.DEVITOPRO }}
49-
DEVITO_PRO_CC: 'gcc'
50-
DEVITO_PRO_CFLAGS: '-O2'
58+
5159
- name: run build for devito
52-
if: matrix.devitoversion == 'devito'
60+
if: ! matrix.devitoversion != 'devitopro'
5361
run: julia --color=yes --project -e 'using Pkg; Pkg.build(verbose=true)'
54-
shell: bash
5562
env:
56-
PYTHON: '~/miniconda/bin/python3'
63+
DEVITO_BRANCH: ${{ matrix.devitoversion }}
64+
5765
# note Pkg.test docs indicate --inline=no can improve coverage
5866
- run: julia --color=yes --check-bounds=yes --inline=no --project -e 'using Pkg; Pkg.test(coverage=true)'
67+
5968
- uses: julia-actions/julia-processcoverage@v1
69+
6070
- uses: codecov/codecov-action@v1
6171
with:
6272
file: lcov.info
73+
6374
docs:
6475
name: Documentation
6576
runs-on: ubuntu-latest
@@ -68,26 +79,35 @@ jobs:
6879
- uses: julia-actions/setup-julia@v2
6980
with:
7081
version: '1'
82+
7183
- name: install mpi
7284
run: sudo apt-get update
7385
- run: sudo apt-get install -y mpich
86+
7487
- name: download miniconda manually
75-
run: wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
88+
run: wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.5.0-0-Linux-x86_64.sh
89+
7690
- name: run install
77-
run: bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda
91+
run: bash Miniconda3-py312_24.5.0-0-Linux-x86_64.sh -b -p ~/miniconda
92+
7893
- name: run path export
79-
run: export PATH=~/miniconda/bin:${PATH}
94+
run: |
95+
echo "$HOME/miniconda/bin:" >> $GITHUB_PATH
96+
echo "PYTHON=$HOME/miniconda/bin/python3" >> $GITHUB_ENV
97+
echo "PYCALL_JL_RUNTIME_PYTHON=$HOME/miniconda/bin/python3" >> $GITHUB_ENV
98+
echo "CONDA_EXE=$HOME/miniconda/bin/conda" >> $GITHUB_ENV
99+
80100
- run: julia --color=yes --project -e 'using Pkg; if VERSION >= v"1.1.0-rc1"; Pkg.build(verbose=true); else Pkg.build(); end'
81-
shell: bash
82-
env:
83-
PYTHON: '~/miniconda/bin/python3'
101+
84102
- name: Install dependencies
85103
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
104+
86105
- run: |
87106
julia --project=docs -e '
88107
using Pkg
89108
Pkg.develop(PackageSpec(path=pwd()))
90109
Pkg.instantiate()'
110+
91111
- run: julia --project=docs docs/make.jl
92112
env:
93113
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

deps/Project.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

deps/build.jl

Lines changed: 82 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,99 @@
1-
using Conda
1+
using PyCall
22

33
dpro_repo = get(ENV, "DEVITO_PRO", "")
44
which_devito = get(ENV,"DEVITO_BRANCH", "")
5-
try
65

7-
Conda.pip_interop(true)
8-
# optional devito pro installation
9-
# note that the submodules do not install correctly from a URL, so we need install from local cloned repo
10-
# 2024-07-29 this is totally hacked for nvidia HPCX and Open MPI 4.1.7a1
11-
# using nvidia HPC SDK 24.7 and cuda 12.5
12-
if dpro_repo != ""
13-
@info "Building devitopro from latest release"
14-
Conda.pip("uninstall -y", "devitopro")
15-
Conda.pip("uninstall -y", "devito")
16-
Conda.pip("uninstall -y", "numpy")
17-
Conda.pip("uninstall -y", "mpi4py")
18-
19-
# clone the devitopro repository and init submodules
20-
dir = "$(tempname())-devitopro"
21-
_pwd = pwd()
22-
Sys.which("git") === nothing && error("git is not installed")
23-
run(`git clone $(dpro_repo) $(dir)`)
24-
cd(dir)
25-
run(`git submodule update --init`)
26-
cd(_pwd)
6+
# Check if packages altready installed
7+
# The assumption is that if the packages are already installed, the user
8+
# has already set up the environment and we don't need to do anything
279

28-
# get DEVITO_ARCH if it exists, default to gcc
29-
devito_arch = get(ENV, "DEVITO_ARCH", "gcc")
30-
31-
# devito requirements
32-
Conda.pip("install --no-cache-dir -r", "https://raw.githubusercontent.com/devitocodes/devito/master/requirements.txt")
10+
# First thing first, is devito already installed
11+
devito = try
12+
pyimport("devito")
13+
which_devito == ""
14+
catch e
15+
@info "Devito not installed or broken"
16+
false
17+
end
3318

34-
if lowercase(devito_arch) == "nvc"
35-
ENV["CC"] = "nvc"
36-
ENV["CFLAGS"] = "-noswitcherror -tp=px"
37-
elseif lowercase(devito_arch) == "gcc"
38-
ENV["CC"] = "gcc"
39-
ENV["CFLAGS"] = ""
40-
end
41-
@info "DEVITO_ARCH=$(devito_arch)"
42-
@info "CC=$(ENV["CC"])"
43-
@info "CFLAGS=$(ENV["CFLAGS"])"
19+
# Second, is devitopro installed
20+
devitopro = try
21+
pyimport("devitopro")
22+
true
23+
catch e
24+
@info "DevitoPRO not installed or broken"
25+
dpro_repo == ""
26+
end
4427

45-
# devitopro
46-
Conda.pip("install", "$(dir)")
47-
rm(dir, recursive=true, force=true)
28+
if (devito && devitopro)
29+
@info "Devito and DevitoPRO are already installed, no need to build"
30+
return
31+
end
4832

49-
# nvida requirements
50-
if lowercase(devito_arch) == "nvc"
51-
Conda.pip("install --no-cache-dir -r", "https://raw.githubusercontent.com/devitocodes/devito/master/requirements-nvidia.txt")
52-
end
33+
# Setup pip command. This will automatically pickup whichever pip PyCall is setup with.
34+
function pip(pkg::String)
35+
cmd_args = Vector{String}([PyCall.python, "-m", "pip", "install", "--no-cache-dir", split(pkg, " ")...])
36+
run(Cmd(cmd_args))
37+
end
5338

54-
# mpi requirements
55-
Conda.pip("install --no-cache-dir -r", "https://raw.githubusercontent.com/devitocodes/devito/master/requirements-mpi.txt")
39+
# MPI4PY and optional nvidia requirements
40+
function mpi4py(mpireqs)
41+
try
42+
ENV["CC"] = "nvc"
43+
ENV["CFLAGS"] = "-noswitcherror -tp=px"
44+
pip("-r $(mpireqs)requirements-mpi.txt")
45+
# If this succeeded, the we might need the extra nvidia python requirements
46+
pip("-r $(mpireqs)requirements-nvidia.txt")
47+
catch e
48+
# Default. Don't set any flag an use the default compiler
5649
delete!(ENV,"CFLAGS")
50+
ENV["CC"] = "gcc"
51+
pip("-r $(mpireqs)requirements-mpi.txt")
52+
end
53+
delete!(ENV,"CFLAGS")
54+
delete!(ENV,"CC")
55+
end
5756

58-
elseif which_devito != ""
59-
@info "Building devito from branch $(which_devito)"
60-
Conda.pip("install", "devito[tests,extras,mpi]@git+https://github.com/devitocodes/devito@$(which_devito)")
61-
62-
else
63-
@info "Building devito from latest release"
64-
Conda.pip("uninstall -y", "devitopro")
65-
Conda.pip("uninstall -y", "devito")
66-
67-
dir = "$(tempname())-devito"
57+
# Install devito and devitopro
58+
try
59+
# Some python version don't like without --user so bypass it
60+
ENV["PIP_BREAK_SYSTEM_PACKAGES"] = "1"
61+
if dpro_repo != ""
62+
# Devitopro is available (Licensed). Install devitopro that comes with devito
63+
# as a submodule. THis way we install the devito version that is compatible with devitopro
64+
# and we don't need to install devito separately
65+
# Because devito is a submodule, pip fails to install it properly (pip does not clone with --recursive)
66+
# So we need to clone then install it. And since julia somehow doesn't think submodules exists LibGit2 cannot clone
67+
# the submodules. So we need to clone it with git by hand
68+
dir = "$(tempname())-devitopro"
6869
Sys.which("git") === nothing && error("git is not installed")
69-
run(`git clone https://github.com/devitocodes/devito $(dir)`)
70-
71-
Conda.pip("install", "$(dir)[tests,extras]")
70+
run(`git clone --recurse-submodules --depth 1 $(dpro_repo) $(dir)`)
71+
72+
# Install devitopro
73+
pip(dir)
74+
75+
# Now all we need is mpi4py. It is straightforward to install except with the nvidia compiler that requires
76+
# extra flags to ignore some flags set by mpi4py
77+
mpi4py("$(dir)/submodules/devito/")
7278
rm(dir, recursive=true, force=true)
73-
74-
# Conda.pip("install", "$(dir)[tests,extras,mpi]")
75-
# ENV["CC"] = "gcc"
76-
# ENV["CFLAGS"] = ""
77-
# ENV["MPICC"] = "mpicc"
78-
# Conda.pip("uninstall -y", "mpi4py")
79-
# Conda.pip("install", "mpi4py")
79+
80+
# Make sure it imports
81+
pyimport("devitopro")
82+
pyimport("devito")
83+
else
84+
if which_devito != ""
85+
@info "Building devito from branch $(which_devito)"
86+
pip("devito[extras,tests]@git+https://github.com/devitocodes/devito@$(which_devito)")
87+
mpi4py("https://raw.githubusercontent.com/devitocodes/devito/$(which_devito)/")
88+
else
89+
@info "Building devito from latest release"
90+
pip("devito[extras,tests]")
91+
mpi4py("https://raw.githubusercontent.com/devitocodes/devito/main/")
92+
end
93+
# Make sure it imports
94+
pyimport("devito")
8095
end
96+
delete!(ENV, "PIP_BREAK_SYSTEM_PACKAGES")
8197
catch e
8298
if get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") == "true"
8399
@warn "unable to build"

0 commit comments

Comments
 (0)