Skip to content

Commit

Permalink
update workflow for dev environment slightly
Browse files Browse the repository at this point in the history
This changes the recommended venv manager to be uv in addition to
configuring a nix development shell.
  • Loading branch information
lilioid committed Dec 26, 2024
1 parent 33ecd16 commit 9bae8ec
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use flake
layout uv
uv pip install --editable '.[django,djangorestframework]' -r requirements.dev.txt
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.direnv
venv
dist
docs/_build
Expand Down
26 changes: 20 additions & 6 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,29 @@ py_simple_openid_connect/
└ <others> (pytest based test suit)
```

## How to set up the project
## How to set up a dev environment

### With nix

If you use nix, this project provides a `flake.nix` file that defines a development shell with all dependencies installed.
It can be entered by typing `nix develop`.
Additionally, a [nix-direnv](https://github.com/nix-community/nix-direnv) configuration file is also present which also sets up a python environment suitable for development.

### Manually

Ensure you have the following system dependencies installed:
- `python~=3.9`
- a python virtual environment manager. This document assumes [uv](https://github.com/astral-sh/uv).

Afterwards, follow the below commands to set up your development environment:

```shell
# create a virtual python environment
virtualenv venv
# activate it
source ./venv/bin/activate
# install this project into the venv + dev dependencies
pip install -e .[django,djangorestframework] -r requirements.dev.txt
uv venv
# install this project + its dev dependencies into the virtual environment
uv pip install -e .[django,djangorestframework] -r requirements.dev.txt
# activate the venv python interpreter for use (use the correct activation script for your shell though)
source .venv/bin/activate
```

## How to run the Tests
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
description = "Simple and opinionated OpenID-Connect relying party and resource server python library";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [
python312
uv
];
};
}
);
}

0 comments on commit 9bae8ec

Please sign in to comment.