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

Devcontainer for Local Development, Mailgun as an alternative Mailclient and 2025 Notebooks #38

Merged
merged 14 commits into from
Dec 30, 2024
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
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "pytanis",
"image": "mcr.microsoft.com/devcontainers/python:3.12",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"eamodio.gitlens"
]
},
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"jupyter.jupyterServerType": "local"
}
},
"postCreateCommand": "bash .devcontainer/init.sh",
"mounts": [
"type=bind,source=${localEnv:HOME}/.ssh,target=/root/.ssh"
],
"remoteUser": "root"
}
50 changes: 50 additions & 0 deletions .devcontainer/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

set -e # Terminates the script in case of errors
set -u # Terminates the script if an unset variable is used
set -o pipefail # Terminates the script if a command in a pipe fails

# Update and installation of pipx
apt update && apt install -y pipx

# Installations with pipx
pipx install hatch
pipx install pre-commit
pipx install hatch-pip-compile

# Configure Hatch
hatch config set dirs.env.virtual .direnv

# .pytanis directory and config.toml file (see README)
DIR="$HOME/.pytanis"
FILE="$DIR/config.toml"

# Check if the file exists
if [ ! -f "$FILE" ]; then
# Create the directory if it doesn't exist
mkdir -p "$DIR"

# Write the content to the file
cat > "$FILE" <<EOF
[Pretalx]
api_token = ""

[Google]
client_secret_json = "client_secret.json"
token_json = "token.json"
service_user_authentication = false

[HelpDesk]
account = ""
entity_id = ""
token = ""

[Mailgun]
token = ""
from_address = ""
reply_to = ""
EOF
echo "File created at $FILE"
else
echo "File already exists at $FILE"
fi
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ MANIFEST

# Version file
/src/pytanis/_version.py

# Devcontainer
devcontainer.env
config.toml
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ service_user_authentication = false
account = "934jcjkdf-39df-9df-93kf-934jfhuuij39fd"
entity_id = "[email protected]"
token = "dal:Sx4id934C3Y-X934jldjdfjk"

[Mailgun]
token = "gguzdgshbdhjsb87239njsa"
from_address = "PyCon DE & PyData Program Committee <[email protected]>"
reply_to = "[email protected]"
```

where you need to replace the dummy values in the sections `[Pretalx]` and `[HelpDesk]` accordingly. Note that `service_user_authentication` is not required to be set if authentication via a service user is not necessary (see [GSpread using Service Account] for more details).
Expand Down Expand Up @@ -85,16 +90,33 @@ Move it to the `~/.pytanis` folder as `client_secret.json`. Also make sure to se

## Development

This section is only relevant if you want to contribute to Pytanis itself. Your help is highly appreciated!
This section is only relevant if you want to contribute to Pytanis itself. Your help is highly appreciated! There are two options for local development.

Whilst both option are valid, the Devcontainer setup is the most convenient, as all dependencies are preconfigured.

### Devcontainer Setup

After having cloned this repository:

1. Make sure to have a local installation of [Docker] and [VS Code] running.
2. Open [VS Code] and make sure to have the [Dev Containers Extension] from Microsoft installed.
3. Open the cloned project in [VS Code] and from the bottom right corner confirm to open the project to be opened within the Devcontainer.

If you miss any dependencies check out the `devcontainer.json` within the `.devcontainer` folder. Otherwise, the right python environment with [pipx], [hatch], [pre-commit] and [hatch-pip-compile] as well as the initialization step for the Hatch environments are already included.

For the use of the `pytanis` libary some credentials and tokens are necessary (see the "Getting Started" section). With the Devcontainer setup the `config.yaml` is already created. Just navigate to `~/.pytanis/config.toml` and update the file with the corresponding tokens.

### Conventional Setup

After having cloned this repository:

1. install [hatch] globally, e.g. `pipx install hatch`,
2. install [pre-commit] globally, e.g. `pipx install pre-commit`,
3. \[only once\] run `hatch config set dirs.env.virtual .direnv` to let [VS Code] find your virtual environments.

and then you are already set up to start hacking. Use `hatch run` to do everything you would normally do in a virtual
environment, e.g. `hatch run juptyer lab` to start [JupyterLab] in the default environment, `hatch run cov` for unit tests

And then you are already set up to start hacking. Use `hatch run` to do everything you would normally do in a virtual
environment, e.g. `hatch run jupyter lab` to start [JupyterLab] in the default environment, `hatch run cov` for unit tests
and coverage (like [tox]) or `hatch run docs:serve` to build & serve the documentation. For code hygiene, execute `hatch run lint:all`
in order to run [ruff] and [mypy] or `hatch run lint:fix` to automatically fix formatting issues.
Check out the `[tool.hatch.envs]` sections in [pyproject.toml](pyproject.toml) to learn about other commands.
Expand Down Expand Up @@ -139,3 +161,5 @@ To start this project off a lot of inspiration and code was taken from [Alexande
[ruff]: https://github.com/astral-sh/ruff
[VS Code]: https://code.visualstudio.com/
[LiveChat]: https://www.livechat.com/
[Docker]: https://www.docker.com/
[Dev Containers Extension]: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
Loading
Loading