Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup: Add venv for Ubuntu Noble (24.04 LTS) #6235

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions Sphinxsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ DISTRIBUTION_ID=$(lsb_release -i -s)
if [ ${DISTRIBUTION_ID} = 'Ubuntu' ]; then
DISTRIBUTION_CODENAME=$(lsb_release -c -s)
if [ ${DISTRIBUTION_CODENAME} = 'focal' ] || [ ${DISTRIBUTION_CODENAME} = 'bionic' ]; then
sudo add-apt-repository universe
sudo add-apt-repository universe -y
fi
fi

sudo apt-get -y update
sudo apt-get install -y unzip git imagemagick curl wget make python3

# create a Python venv on more recent releases:
if [ ${DISTRIBUTION_CODENAME} = 'noble' ]; then
sudo apt install python3-venv
python3 -m venv $HOME/venv-ardupilot-wiki --upgrade-deps

# activate it:
SOURCE_LINE="source $HOME/venv-ardupilot-wiki/bin/activate"
$SOURCE_LINE
fi

# Install packages release specific
if [ ${DISTRIBUTION_CODENAME} = 'bionic' ]; then
sudo apt-get install -y python3-distutils
Expand All @@ -38,12 +48,16 @@ if [ "$(python --version)" == "Python 3.6.9" ]; then
GET_PIP_URL="https://bootstrap.pypa.io/pip/3.6/get-pip.py"
fi

curl "$GET_PIP_URL" -o get-pip.py
python3 get-pip.py
rm -f get-pip.py
PIP_USER_ARGUMENT=""
if [ ${DISTRIBUTION_CODENAME} != 'noble' ]; then
curl "$GET_PIP_URL" -o get-pip.py
python3 get-pip.py
rm -f get-pip.py
PIP_USER_ARGUMENT="--user"
fi

# Install required python packages
python3 -m pip install --user --upgrade -r requirements.txt
python3 -m pip install $PIP_USER_ARGUMENT --upgrade -r requirements.txt

# Reset the value of DISPLAY
if grep -qi -E '(Microsoft|WSL)' /proc/version; then
Expand Down
25 changes: 15 additions & 10 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from __future__ import print_function, unicode_literals

import argparse
import distutils
import errno
import filecmp
import json
Expand All @@ -51,17 +50,19 @@
from concurrent.futures import ThreadPoolExecutor
from typing import Optional, Dict, List


from sphinx.application import Sphinx
from frontend.scripts import get_discourse_posts
import rst_table

from codecs import open
from datetime import datetime
# while flake8 says this is unused, distutils.dir_util.mkpath fails
# without the following import on old versions of Python:
from distutils import dir_util # noqa: F401

from frontend.scripts import get_discourse_posts
try:
from sphinx.application import Sphinx # noqa: F401
except ModuleNotFoundError as e:
print("Please make sure that you have run the SphinxSetup script for your system and that you have activated the",
"arudpilot-wiki-venv if it was created on your system")
print(e)
sys.exit(1)

if sys.version_info < (3, 8):
print("Minimum python version is 3.8")
Expand Down Expand Up @@ -365,14 +366,14 @@ def make_backup(site, destdir, backupdestdir):
debug('Backing up: %s' % wiki)

targetdir = os.path.join(destdir, wiki)
distutils.dir_util.mkpath(targetdir)
os.makedirs(targetdir, exist_ok=True)

if not os.path.exists(targetdir):
fatal("FAIL backup when looking for folder %s" % targetdir)

bkdir = os.path.join(backupdestdir, str(building_time + '-wiki-bkp'), str(wiki))
debug('Checking %s' % bkdir)
distutils.dir_util.mkpath(bkdir)
os.makedirs(bkdir, exist_ok=True)
debug('Copying %s into %s' % (targetdir, bkdir))
try:
subprocess.check_call(["rsync", "-a", "--delete", targetdir + "/", bkdir])
Expand Down Expand Up @@ -771,7 +772,11 @@ def copy_static_html_sites(site, destdir):

def check_imports():
'''check key imports work'''
import pkg_resources
try:
import pkg_resources
except ModuleNotFoundError:
debug("Unable to check imports using pkg_resources")
return
# package names to check the versions of. Note that these can be different than the string used to import the package
requires = ["sphinx_rtd_theme>=1.3.0", "sphinxcontrib.youtube>=1.2.0", "sphinx>=7.1.2", "docutils<0.19"]
for r in requires:
Expand Down
5 changes: 5 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ lock_file build.lck || {
echo "$(date +%s) already locked" >>build.lck.log
exit 1
}
# activate Python venv on more recent releases:
if [ ${DISTRIBUTION_CODENAME} == 'noble' ]; then
SOURCE_LINE="source $HOME/venv-ardupilot-wiki/bin/activate"
$SOURCE_LINE
fi

test -n "$FORCEBUILD" || {
(cd ardupilot_wiki && git fetch > /dev/null 2>&1)
Expand Down