Skip to content
Merged
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
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "My Dev Container",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {},
"customizations": {
"vscode": {
"extensions": [
"github.copilot",
"github.copilot-chat",
"github.github-vscode-theme",
"github.vscode-pull-request-github",
"ms-ceintl.vscode-language-pack-it",
"ms-python.python",
"ms-vscode.vscode-typescript-next"
]
}
},
"postCreateCommand": "bash .devcontainer/setup.sh",
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind"
]
}
56 changes: 56 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -e # Exit on error

# Update and install dependencies
sudo apt update -y
sudo apt upgrade -y
sudo apt-get install -y python3-openssl
sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev git

# Install pyenv
curl https://pyenv.run | bash

# Add pyenv to shell profile
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init --path)"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.profile

# Apply changes
source ~/.profile

# Install Python 3.10 using pyenv
pyenv install 3.10.0
pyenv global 3.10.0
pyenv local 3.10

# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"

# Initialize Poetry environment
PROJECT_DIR="$(pwd)"
export VENV_PATH="$PROJECT_DIR/.venv"
poetry config virtualenvs.in-project true

poetry install --all-extras
source "$VENV_PATH/bin/activate" #poetry shell

# FFmpeg
FFMPEG_VERSION="6.0" # Ensure this is version 5 or higher
mkdir -p $HOME/.local/bin
echo "Downloading FFmpeg $FFMPEG_VERSION..."
cd $HOME/.local/bin
wget -O ffmpeg.tar.xz "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz"
tar -xf ffmpeg.tar.xz --strip-components=1
rm ffmpeg.tar.xz
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
export PATH="$HOME/.local/bin:$PATH"
cd -

#Run tests to verify all is good
pytest

echo "Setup complete!"
17 changes: 12 additions & 5 deletions docs/DEV.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# Development Environment
This doesn't represent the only way to develop on darwin-py, but does represent an easy and configurable way to manage things like underlying dependencies and python versions
## Shell environment
## Devcontainer - One click approach
Just use the devcontainer config, either in Github codespaces or in using the [VSCode extension](https://code.visualstudio.com/docs/devcontainers/tutorial).

NB the config is [here](../.devcontainer/devcontainer.json)

Remember to activate the _venv_ after the container boots `source .venv/bin/activate`
## Manual setup
### Shell environment
No requirement for any particular shell, [zsh](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH) + [oh my zsh](https://ohmyz.sh/) is a good setup commonly used, but whatever environment you use make sure to install the recommended alias's and path exports that the below systems require for your particular shell environment, particularly pertinent for poetry which has an added step that it prints to console but isn't included on the webpage.
## Pyenv
### Pyenv
Pyenv manages system python versions, install instructions can be found [here](https://github.com/pyenv/pyenv).
After installation of pyenv, install a python version that is compatible with darwin-py (3.9-3.12 as of writing)

`pyenv install 3.10`

If the command `pyenv` isn't recognized, it hasn't installed to your shell environemnt config file correctly .zshrc .bashrc etc.
## Poetry
### Poetry
Poetry manages project level dependencies and local python versions. Install instructions [here](https://python-poetry.org/docs/). Make sure to follow the printed instructions and add the path to your shell environment, if running the command `poetry --version` after installation doesn't work, it means your path hasn't been updated

## New Folder Setup
### New Folder Setup
To Start from scratch and get a development/QA environemnt setup. This process means you will have a fresh python version with only the dependencies required by darwin-py that is uncorrupted by other packages installed on the system python
- clone darwin py repo
- navigate to downloaded repo
Expand All @@ -22,7 +29,7 @@ To Start from scratch and get a development/QA environemnt setup. This process m

Pyenv + Poetry here get used in conjuction, with pyenv telling the system whenever `python` is called in a folder that has been set with `pyenv local <version>` that it should use that local version. Poetry is then set to prefer that local version of python, and to create a per project copy of python to use, it will clone `<version>` into a .venv folder locally, and install dependencies there. If new environment is required, run `rm -rf .venv` while inside the project folder, set a new pyenv version if needed and re-run poetry commands

## Subsequent Uses
### Subsequent Uses
Once a folder is setup, it can easily be reused
- navigate to folder
- run `poetry shell`
Expand Down