Skip to content

Commit 68e028b

Browse files
committed
refactor: update install scripts to use uv
1 parent 6555cd3 commit 68e028b

File tree

3 files changed

+40
-55
lines changed

3 files changed

+40
-55
lines changed

configure.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import shutil
1515
import zipfile
1616

17-
from venv import EnvBuilder
18-
1917
parser = argparse.ArgumentParser(description='ODM Windows Configure Script')
2018
parser.add_argument('action',
2119
type=str,
@@ -62,15 +60,8 @@ def vcpkg_requirements():
6260
return pckgs
6361

6462
def build():
65-
# Create python virtual env
66-
if not os.path.isdir("venv"):
67-
print("Creating virtual env --> venv/")
68-
ebuilder = EnvBuilder(with_pip=True)
69-
ebuilder.create("venv")
70-
71-
run("pip install setuptools")
72-
run("venv\\Scripts\\pip install --ignore-installed -r requirements.txt")
73-
63+
run("uv sync")
64+
7465
# Download / build VCPKG environment
7566
if not os.path.isdir("vcpkg"):
7667
if args.build_vcpkg:
@@ -129,7 +120,7 @@ def safe_remove(path):
129120
def clean():
130121
safe_remove("vcpkg-download.zip")
131122
safe_remove("vcpkg")
132-
safe_remove("venv")
123+
safe_remove(".venv")
133124
safe_remove(os.path.join("SuperBuild", "build"))
134125
safe_remove(os.path.join("SuperBuild", "download"))
135126
safe_remove(os.path.join("SuperBuild", "src"))

configure.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ ensure_prereqs() {
5151
sudo $APT_GET install -y -qq --no-install-recommends pkg-config
5252
fi
5353

54+
if ! command -v curl &> /dev/null; then
55+
echo "Installing curl"
56+
sudo $APT_GET install -y -qq --no-install-recommends curl
57+
fi
58+
5459
echo "Installing tzdata"
5560
sudo $APT_GET install -y -qq tzdata
5661

@@ -62,14 +67,11 @@ ensure_prereqs() {
6267
sudo $APT_GET update
6368
fi
6469

65-
echo "Installing Python PIP"
66-
sudo $APT_GET install -y -qq --no-install-recommends \
67-
python3-pip \
68-
python3-setuptools \
69-
python3-venv
70-
python3 -m venv venv --system-site-packages
71-
venv/bin/pip3 install -U pip
72-
venv/bin/pip3 install -U shyaml
70+
echo "Installing Python UV"
71+
curl -LsSf https://astral.sh/uv/0.9.5/install.sh | sh
72+
73+
echo "Syncing Python dependencies"
74+
uv sync
7375
}
7476

7577
# Save all dependencies in snapcraft.yaml to maintain a single source of truth.
@@ -82,17 +84,18 @@ installdepsfromsnapcraft() {
8284
*) key=build-packages; ;; # shouldn't be needed, but it's here just in case
8385
esac
8486

85-
UBUNTU_VERSION=$(lsb_release -r)
86-
SNAPCRAFT_FILE="snapcraft.yaml"
87-
if [[ "$UBUNTU_VERSION" == *"21.04"* ]]; then
88-
SNAPCRAFT_FILE="snapcraft21.yaml"
89-
elif [[ "$UBUNTU_VERSION" == *"24.04"* ]]; then
90-
SNAPCRAFT_FILE="snapcraft24.yaml"
91-
fi
87+
echo "Installing dependencies from snap/$SNAPCRAFT_FILE ($section.$key)"
88+
89+
uv run python - "$section" "$key" "snap/$SNAPCRAFT_FILE" <<'PYCODE' | \
90+
xargs sudo $APT_GET install -y -qq --no-install-recommends
91+
import sys, yaml
9292
93-
cat snap/$SNAPCRAFT_FILE | \
94-
venv/bin/shyaml get-values-0 parts.$section.$key | \
95-
xargs -0 sudo $APT_GET install -y -qq --no-install-recommends
93+
section, key, snapfile = sys.argv[1:]
94+
with open(snapfile, 'r') as f:
95+
data = yaml.safe_load(f)
96+
for pkg in data.get('parts', {}).get(section, {}).get(key, []):
97+
print(pkg)
98+
PYCODE
9699
}
97100

98101
installruntimedepsonly() {
@@ -133,10 +136,7 @@ installreqs() {
133136
set -e
134137

135138
# edt requires numpy to build
136-
venv/bin/pip install numpy==2.3.2
137-
venv/bin/pip install -r requirements.txt --ignore-installed
138-
#if [ ! -z "$GPU_INSTALL" ]; then
139-
#fi
139+
uv pip install numpy==2.3.2
140140
set +e
141141
}
142142

configure_macos.sh

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,10 @@ ensure_prereqs() {
3434
installreqs() {
3535
ensure_prereqs
3636

37-
brew install cmake gcc@12 [email protected] tbb@2020 eigen gdal boost cgal libomp
37+
brew install cmake gcc@12 [email protected] tbb@2020 eigen gdal boost cgal libomp uv
3838
brew link tbb@2020
3939

40-
python3.12 -m pip install virtualenv
41-
42-
if [ ! -e ${RUNPATH}/venv ]; then
43-
python3.12 -m virtualenv venv
44-
fi
45-
46-
source venv/bin/activate
47-
pip install --ignore-installed -r requirements.txt
40+
uv sync
4841
}
4942

5043
install() {
@@ -55,18 +48,19 @@ install() {
5548
mkdir -p build && cd build
5649
cmake .. && make -j$processes
5750

58-
cd /tmp
59-
pip download GDAL==3.11.1
60-
tar -xpzf GDAL-3.11.1.tar.gz
61-
cd GDAL-3.11.1
62-
if [ -e /opt/homebrew/bin/gdal-config ]; then
63-
python setup.py build_ext --gdal-config /opt/homebrew/bin/gdal-config
64-
else
65-
python setup.py build_ext --gdal-config /usr/local/bin/gdal-config
66-
fi
67-
python setup.py build
68-
python setup.py install
69-
rm -fr /tmp/GDAL-3.11.1 /tmp/GDAL-3.11.1.tar.gz
51+
# TODO check if we actually need this, when using uv / Mac?
52+
# cd /tmp
53+
# pip download GDAL==3.11.1
54+
# tar -xpzf GDAL-3.11.1.tar.gz
55+
# cd GDAL-3.11.1
56+
# if [ -e /opt/homebrew/bin/gdal-config ]; then
57+
# python setup.py build_ext --gdal-config /opt/homebrew/bin/gdal-config
58+
# else
59+
# python setup.py build_ext --gdal-config /usr/local/bin/gdal-config
60+
# fi
61+
# python setup.py build
62+
# python setup.py install
63+
# rm -fr /tmp/GDAL-3.11.1 /tmp/GDAL-3.11.1.tar.gz
7064

7165
cd ${RUNPATH}
7266

0 commit comments

Comments
 (0)