Skip to content

Commit cb5dba4

Browse files
committed
Initialize development environment and testing configuration with Nix; add flake.lock and flake.nix for dependency management; update Makefile for pip installation options.
1 parent 1e3ab22 commit cb5dba4

4 files changed

Lines changed: 141 additions & 3 deletions

File tree

.cursorrules

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Development Environment
2+
3+
### Getting Started
4+
5+
**Important:** Run `nix develop` in every new terminal session to activate the development environment with all required dependencies and correct Python paths.
6+
7+
## Testing
8+
9+
### How to Run Tests
10+
11+
**For humans:**
12+
- Run tests using pytest: `pytest` or `make test`
13+
- The test configuration is in `pytest.ini`
14+
- Tests are located in the `tests/` directory
15+
16+
**For AI assistants:**
17+
- Use `nix develop -c pytest` to run tests in the Nix development environment
18+
- Use `nix develop -c make test` to run tests via Makefile
19+
- This ensures tests run in the correct environment with all dependencies
20+
21+
### Test Configuration
22+
- Test paths: `tests/`
23+
- Coverage reporting: enabled with `--cov=translate`
24+
- Verbose output: `-vv` flag enabled by default
25+

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ lint:
1818
pre-commit run -av
1919

2020
pip-install:
21-
pip install --user -r requirements-dev.txt
21+
pip install --user --break-system-packages -r requirements-dev.txt
2222
pip-install-build:
23-
pip install --user -r requirements-build.txt
23+
pip install --user --break-system-packages -r requirements-build.txt
2424

2525
pip-upgrade:
26-
pip install --user --upgrade -r requirements-dev.txt
26+
pip install --user --upgrade --break-system-packages -r requirements-dev.txt
2727

2828
cov:
2929
coverage report -m

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
description = "Python translate CLI development environment";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = import nixpkgs {
13+
inherit system;
14+
};
15+
python = pkgs.python3;
16+
pythonPackages = pkgs.python3Packages;
17+
in
18+
{
19+
devShells.default = pkgs.mkShell {
20+
name = "translate-python";
21+
22+
MYSQL_HOME = builtins.getEnv "MYSQL_HOME";
23+
MYSQL_DATADIR = builtins.getEnv "MYSQL_DATADIR";
24+
25+
buildInputs = with pkgs; [
26+
python
27+
pythonPackages.pip
28+
pythonPackages.setuptools
29+
pythonPackages.wheel
30+
vim
31+
git
32+
];
33+
34+
shellHook = ''
35+
export PYTHONUSERBASE=$PWD/.local
36+
export USER_SITE=$(python -c "import site; print(site.USER_SITE)")
37+
38+
# Fix Python version in USER_SITE path if needed
39+
export USER_SITE=${"\$\{USER_SITE//3.8/3.9}"}
40+
41+
export PYTHONPATH=$PYTHONPATH:$USER_SITE
42+
export PATH=$PATH:$PYTHONUSERBASE/bin
43+
44+
echo "Development environment ready!"
45+
echo "Install dependencies with: pip install --user -r requirements-dev.txt"
46+
echo "Run tests with: pytest"
47+
'';
48+
};
49+
}
50+
);
51+
}
52+

0 commit comments

Comments
 (0)