From a670542472ac03c7f06f4932ed7432be2cbd46a2 Mon Sep 17 00:00:00 2001 From: wangzhao0217 <74598734+wangzhao0217@users.noreply.github.com> Date: Tue, 10 Sep 2024 21:41:31 +0100 Subject: [PATCH 1/3] add devcontainer file and define path for utils.py --- .devcontainer/devcontainer.json | 36 ++++++++++++++++++ .devcontainer/postCreateCommand.sh | 59 ++++++++++++++++++++++++++++++ examples/edinburgh/setup.py | 6 ++- 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/postCreateCommand.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..20a1278 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,36 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "ghcr.io/geocompx/docker:suggests", + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": ["reditorsupport.r", + "GitHub.copilot-chat", + "GitHub.copilot-labs", + "GitHub.copilot", + "yzhang.markdown-all-in-one", + "quarto.quarto" + ] + } + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" + + // Run the script install-additional-dependencies.sh: + "postCreateCommand": "bash .devcontainer/postCreateCommand.sh" + +} diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh new file mode 100644 index 0000000..8ed4dfd --- /dev/null +++ b/.devcontainer/postCreateCommand.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# Ensure we are running under Bash +if [ -z "$BASH_VERSION" ]; then + echo "This script requires Bash, but it was executed with $SHELL. Exiting." + exit 1 +fi + +# Set debugging and exit on error +set -euxo pipefail + +# Check the Linux distro we're running: +cat /etc/os-release + +# Install Rust: +curl https://sh.rustup.rs -sSf | sh -s -- -y + +# Add cargo to the path both temporarily and permanently: +export PATH="$HOME/.cargo/bin:$PATH" +echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.profile + +# Ensure cargo command is available +command -v cargo + +# Install odjitter using cargo +cargo install --git https://github.com/dabreegster/odjitter --rev 32fb58bf7f0d68afd3b76b88cf6b1272c5c66828 + +# Ensure apt repository is up-to-date and install necessary packages +sudo apt-get update +sudo apt-get install -y software-properties-common python3 python3-pip + +# Install Python dependencies: +# Uncomment and modify if you have a requirements.txt +# pip3 install -r requirements.txt + +# Clone and install tippecanoe if not already installed +cd /tmp +if [ ! -d "tippecanoe" ]; then + git clone https://github.com/felt/tippecanoe.git +fi +cd tippecanoe +make -j$(nproc) +sudo make install +tippecanoe --version + +# Add local instance of odjitter to the /usr/local/bin directory: +if [ ! -L /usr/local/bin/odjitter ]; then + sudo ln -s ~/.cargo/bin/odjitter /usr/local/bin/odjitter +else + echo "Symbolic link /usr/local/bin/odjitter already exists." +fi + +# Verify odjitter installation +ls -hal ~/.cargo/bin/odjitter + +# Install GitHub CLI +sudo apt install -y gh + +# Make sure there's a newline at the end of the script +echo "Script execution completed successfully." diff --git a/examples/edinburgh/setup.py b/examples/edinburgh/setup.py index ee3a332..caeb11a 100644 --- a/examples/edinburgh/setup.py +++ b/examples/edinburgh/setup.py @@ -1,8 +1,12 @@ +import sys +import os import csv import json -from utils import * +# Add the parent directory to the system path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) +from utils import * def makeOSM(): download( From 77fe94fc08fd48490c7b15be2d1acaf1290af8c0 Mon Sep 17 00:00:00 2001 From: wangzhao0217 <74598734+wangzhao0217@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:31:11 +0100 Subject: [PATCH 2/3] removed odjitter from installation --- .devcontainer/postCreateCommand.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index 8ed4dfd..ed97c67 100644 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -21,9 +21,6 @@ echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.profile # Ensure cargo command is available command -v cargo -# Install odjitter using cargo -cargo install --git https://github.com/dabreegster/odjitter --rev 32fb58bf7f0d68afd3b76b88cf6b1272c5c66828 - # Ensure apt repository is up-to-date and install necessary packages sudo apt-get update sudo apt-get install -y software-properties-common python3 python3-pip @@ -49,9 +46,6 @@ else echo "Symbolic link /usr/local/bin/odjitter already exists." fi -# Verify odjitter installation -ls -hal ~/.cargo/bin/odjitter - # Install GitHub CLI sudo apt install -y gh From 029b5257f17715d47ccdeed1c14f4205aa3c278b Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Thu, 12 Sep 2024 14:08:42 +0100 Subject: [PATCH 3/3] Remove odjitter from devcontainer and explain path import problem --- .devcontainer/postCreateCommand.sh | 7 ------- examples/edinburgh/setup.py | 3 ++- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index ed97c67..d24d14f 100644 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -39,13 +39,6 @@ make -j$(nproc) sudo make install tippecanoe --version -# Add local instance of odjitter to the /usr/local/bin directory: -if [ ! -L /usr/local/bin/odjitter ]; then - sudo ln -s ~/.cargo/bin/odjitter /usr/local/bin/odjitter -else - echo "Symbolic link /usr/local/bin/odjitter already exists." -fi - # Install GitHub CLI sudo apt install -y gh diff --git a/examples/edinburgh/setup.py b/examples/edinburgh/setup.py index caeb11a..b855e79 100644 --- a/examples/edinburgh/setup.py +++ b/examples/edinburgh/setup.py @@ -3,7 +3,8 @@ import csv import json -# Add the parent directory to the system path +# utils.py is symlinked, but this appears broken in dev containers, so add the +# parent directory sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) from utils import *