Skip to content

Commit cd43356

Browse files
Andrey Golovanovclaude
andcommitted
Rewrite DES core from scratch
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2dd844f commit cd43356

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+5285
-6307
lines changed

.github/workflows/python-test.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
# Run unit tests and check test coverage
2-
name: Python-test
1+
name: CI
32

43
on: [push, pull_request]
54

65
jobs:
7-
build:
6+
test:
87
runs-on: ubuntu-latest
98
strategy:
9+
fail-fast: false
1010
matrix:
11-
python-version: ["3.11", "3.12", "3.13"]
11+
python-version: ["3.11", "3.12", "3.13", "3.14"]
1212

1313
steps:
14-
- uses: actions/checkout@v4 # latest stable
14+
- uses: actions/checkout@v4
1515
- name: Set up Python ${{ matrix.python-version }}
1616
uses: actions/setup-python@v5
1717
with:
1818
python-version: ${{ matrix.python-version }}
19-
20-
- name: Install project (dev extras)
19+
- name: Install dependencies
2120
run: |
22-
python -m pip install --upgrade pip
23-
pip install -e ".[dev]"
24-
25-
- name: Run tests with coverage
21+
python -m pip install -U pip
22+
python -m pip install -e '.[dev]'
23+
- name: CI checks (lint + tests)
2624
run: |
27-
pytest --cov=netsim --cov-fail-under=85
25+
make check-ci

.gitignore

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,30 @@
1-
# MacOS stuff
1+
# OS
22
.DS_Store
33

4-
# VSCode stuff
4+
# Editors
55
**/.vscode
6+
.idea/
67

7-
# Byte-compiled / optimized / DLL files
8+
# Python
89
__pycache__/
910
*.py[cod]
1011
*$py.class
12+
*.egg-info/
13+
*.egg
14+
dist/
15+
build/
1116

12-
# Distribution / packaging / testing
13-
.Python
14-
bin/
17+
# Virtual environments
1518
env/
1619
venv/
17-
build/
18-
develop-eggs/
19-
dist/
20-
downloads/
21-
eggs/
22-
.eggs/
23-
lib/
24-
lib64/
25-
parts/
26-
sdist/
27-
var/
28-
*.egg-info/
29-
.installed.cfg
30-
*.egg
31-
pyvenv.cfg
32-
.pytest_cache
20+
21+
# Testing / coverage
22+
.pytest_cache/
3323
.coverage
24+
.benchmarks/
25+
htmlcov/
3426

35-
# NetSim artifacts
27+
# Artifacts
3628
*.jsonl
3729
*.png
3830
*.csv
39-
.ipynb_checkpoints

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.11.13
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format
8+
9+
- repo: https://github.com/RobertCraigie/pyright-python
10+
rev: v1.1.401
11+
hooks:
12+
- id: pyright
13+
args: [--project, pyproject.toml]
14+
15+
- repo: https://github.com/pre-commit/pre-commit-hooks
16+
rev: v5.0.0
17+
hooks:
18+
- id: trailing-whitespace
19+
- id: end-of-file-fixer
20+
- id: check-yaml
21+
- id: check-toml
22+
- id: check-merge-conflict
23+
- id: check-added-large-files

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021-2025 Andrey Golovanov
3+
Copyright (c) 2021-2026 Andrey Golovanov
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# NetSim Development Makefile
2+
3+
.PHONY: help venv clean-venv dev install check check-ci lint format test qt build clean check-dist publish-test publish info hooks check-python
4+
5+
.DEFAULT_GOAL := help
6+
7+
# --------------------------------------------------------------------------
8+
# Python interpreter detection
9+
# --------------------------------------------------------------------------
10+
VENV_BIN := $(PWD)/venv/bin
11+
12+
PY_BEST := $(shell for v in 3.14 3.13 3.12 3.11; do command -v python$$v >/dev/null 2>&1 && { echo python$$v; exit 0; }; done; command -v python3 2>/dev/null || command -v python 2>/dev/null)
13+
14+
PY_PATH := $(shell command -v python3 2>/dev/null || command -v python 2>/dev/null)
15+
16+
PYTHON ?= $(if $(wildcard $(VENV_BIN)/python),$(VENV_BIN)/python,$(if $(PY_PATH),$(PY_PATH),$(if $(PY_BEST),$(PY_BEST),python3)))
17+
18+
PIP := $(PYTHON) -m pip
19+
PYTEST := $(PYTHON) -m pytest
20+
RUFF := $(PYTHON) -m ruff
21+
PRECOMMIT := $(PYTHON) -m pre_commit
22+
23+
# --------------------------------------------------------------------------
24+
# Help
25+
# --------------------------------------------------------------------------
26+
help:
27+
@echo "NetSim Development Commands"
28+
@echo ""
29+
@echo "Setup:"
30+
@echo " make venv - Create virtual environment (./venv)"
31+
@echo " make dev - Full dev setup (venv + deps + pre-commit hooks)"
32+
@echo " make install - Install package only (no dev deps)"
33+
@echo " make clean-venv - Remove virtual environment"
34+
@echo ""
35+
@echo "Code Quality & Testing:"
36+
@echo " make check - Pre-commit (auto-fix) + tests + lint"
37+
@echo " make check-ci - Lint + tests (non-mutating, CI entrypoint)"
38+
@echo " make lint - Linting only (ruff + pyright)"
39+
@echo " make format - Auto-format with ruff"
40+
@echo " make test - Run tests with coverage"
41+
@echo " make qt - Quick tests (no coverage, no benchmarks)"
42+
@echo ""
43+
@echo "Build & Publish:"
44+
@echo " make build - Build distribution packages"
45+
@echo " make clean - Clean build artifacts"
46+
@echo " make check-dist - Check packages with twine"
47+
@echo " make publish-test - Publish to Test PyPI"
48+
@echo " make publish - Publish to PyPI"
49+
@echo ""
50+
@echo "Utilities:"
51+
@echo " make info - Show project info"
52+
@echo " make hooks - Run pre-commit on all files"
53+
@echo " make check-python - Verify venv Python version"
54+
55+
# --------------------------------------------------------------------------
56+
# Setup
57+
# --------------------------------------------------------------------------
58+
dev:
59+
@echo "Setting up development environment..."
60+
@if [ ! -x "$(VENV_BIN)/python" ]; then \
61+
if [ -z "$(PY_BEST)" ]; then \
62+
echo "Error: No Python interpreter found"; \
63+
exit 1; \
64+
fi; \
65+
echo "Creating virtual environment with $(PY_BEST) ..."; \
66+
$(PY_BEST) -m venv venv || { echo "Failed to create venv"; exit 1; }; \
67+
$(VENV_BIN)/python -m pip install -U pip setuptools wheel; \
68+
fi
69+
@echo "Installing dev dependencies..."
70+
@$(VENV_BIN)/python -m pip install -e '.[dev]'
71+
@echo "Installing pre-commit hooks..."
72+
@$(VENV_BIN)/python -m pre_commit install --install-hooks
73+
@echo "Dev environment ready. Activate with: source venv/bin/activate"
74+
@$(MAKE) check-python
75+
76+
venv:
77+
@if [ -z "$(PY_BEST)" ]; then \
78+
echo "Error: No Python interpreter found"; \
79+
exit 1; \
80+
fi
81+
@echo "Creating virtual environment with $(PY_BEST) ..."
82+
@$(PY_BEST) -m venv venv
83+
@$(VENV_BIN)/python -m pip install -U pip setuptools wheel
84+
@echo "venv ready. Activate with: source venv/bin/activate"
85+
86+
clean-venv:
87+
@rm -rf venv/
88+
89+
install:
90+
@$(PIP) install -e .
91+
92+
# --------------------------------------------------------------------------
93+
# Code Quality & Testing
94+
# --------------------------------------------------------------------------
95+
check:
96+
@echo "Running complete checks..."
97+
@$(PRECOMMIT) run --all-files || true
98+
@$(PRECOMMIT) run --all-files
99+
@$(MAKE) test
100+
@$(MAKE) lint
101+
102+
check-ci:
103+
@echo "Running CI checks (lint + tests)..."
104+
@$(MAKE) lint
105+
@$(MAKE) test
106+
107+
lint:
108+
@$(RUFF) format --check .
109+
@$(RUFF) check .
110+
@$(PYTHON) -m pyright
111+
112+
format:
113+
@$(RUFF) format .
114+
115+
test:
116+
@$(PYTEST)
117+
118+
qt:
119+
@$(PYTEST) --no-cov -m "not slow and not benchmark"
120+
121+
hooks:
122+
@$(PRECOMMIT) run --all-files
123+
124+
# --------------------------------------------------------------------------
125+
# Build & Publish
126+
# --------------------------------------------------------------------------
127+
build:
128+
@$(PYTHON) -m build
129+
130+
clean:
131+
@rm -rf build/ dist/ *.egg-info/ netsim.egg-info/
132+
133+
check-dist:
134+
@$(PYTHON) -m twine check dist/*
135+
136+
publish-test:
137+
@$(PYTHON) -m twine upload --repository testpypi dist/*
138+
139+
publish:
140+
@$(PYTHON) -m twine upload dist/*
141+
142+
# --------------------------------------------------------------------------
143+
# Utilities
144+
# --------------------------------------------------------------------------
145+
info:
146+
@echo "Python: $$($(PYTHON) --version 2>&1)"
147+
@echo "pip: $$($(PIP) --version 2>&1 | head -1)"
148+
@echo "ruff: $$($(RUFF) --version 2>&1 || echo 'not installed')"
149+
@echo "pyright: $$($(PYTHON) -m pyright --version 2>&1 || echo 'not installed')"
150+
@echo "Git: $$(git describe --tags --always 2>/dev/null || echo 'no tags')"
151+
152+
check-python:
153+
@VENV_PY=$$($(VENV_BIN)/python --version 2>&1 | awk '{print $$2}' | cut -d. -f1,2); \
154+
BEST_PY=$$($(PY_BEST) --version 2>&1 | awk '{print $$2}' | cut -d. -f1,2); \
155+
if [ "$$VENV_PY" != "$$BEST_PY" ]; then \
156+
echo "Warning: venv uses Python $$VENV_PY but $$BEST_PY is available"; \
157+
echo "Run: make clean-venv && make dev"; \
158+
fi

0 commit comments

Comments
 (0)