memoryguard 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,114 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, develop ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os: [ubuntu-latest]
16
+ python-version: ['3.9', '3.10', '3.11', '3.12']
17
+ include:
18
+ - os: macos-latest
19
+ python-version: '3.11'
20
+ - os: windows-latest
21
+ python-version: '3.11'
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - name: Set up Python ${{ matrix.python-version }}
27
+ uses: actions/setup-python@v5
28
+ with:
29
+ python-version: ${{ matrix.python-version }}
30
+
31
+ - name: Install dependencies
32
+ run: |
33
+ python -m pip install --upgrade pip
34
+ pip install -e ".[dev]"
35
+ pip install pytest pytest-asyncio pytest-cov
36
+
37
+ - name: Run tests
38
+ run: pytest tests/ -v --tb=short
39
+ continue-on-error: false
40
+
41
+ - name: Run tests with coverage
42
+ if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
43
+ run: pytest tests/ --cov=memoryguard --cov-report=xml --cov-report=term-missing --cov-fail-under=80
44
+
45
+ - name: Upload coverage
46
+ if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
47
+ uses: codecov/codecov-action@v3
48
+ with:
49
+ file: ./coverage.xml
50
+ fail_ci_if_error: false
51
+ verbose: true
52
+
53
+ lint:
54
+ runs-on: ubuntu-latest
55
+
56
+ steps:
57
+ - uses: actions/checkout@v4
58
+
59
+ - name: Set up Python
60
+ uses: actions/setup-python@v5
61
+ with:
62
+ python-version: '3.11'
63
+
64
+ - name: Install dependencies
65
+ run: |
66
+ pip install black flake8 mypy
67
+ pip install -e ".[dev]"
68
+
69
+ - name: Check formatting with black
70
+ run: black --check memoryguard/ tests/ || true
71
+
72
+ - name: Lint with flake8
73
+ run: flake8 memoryguard/ tests/ --max-line-length=100 --extend-ignore=E203,W503 || true
74
+
75
+ - name: Type check with mypy
76
+ run: mypy memoryguard/ || true
77
+
78
+ memory-check:
79
+ runs-on: ubuntu-latest
80
+
81
+ steps:
82
+ - uses: actions/checkout@v4
83
+
84
+ - name: Set up Python
85
+ uses: actions/setup-python@v5
86
+ with:
87
+ python-version: '3.11'
88
+
89
+ - name: Install dependencies
90
+ run: |
91
+ pip install -e ".[all]"
92
+
93
+ - name: Run basic memory tests
94
+ run: |
95
+ python -c "
96
+ from memoryguard import MemoryGuard
97
+ guard = MemoryGuard()
98
+ print('✅ MemoryGuard imports successfully')
99
+
100
+ # Basic test
101
+ guard.check_memory('test')
102
+ print('✅ Basic memory check works')
103
+
104
+ # Generate report
105
+ report_path = guard.generate_report('memory-report.json')
106
+ print(f'✅ Report generated: {report_path}')
107
+ "
108
+
109
+ - name: Upload memory report
110
+ uses: actions/upload-artifact@v4
111
+ with:
112
+ name: memory-report
113
+ path: memory-report.json
114
+ if-no-files-found: ignore
@@ -0,0 +1,38 @@
1
+ name: Coverage Badge
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ coverage:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: '3.11'
18
+
19
+ - name: Install dependencies
20
+ run: |
21
+ pip install -e ".[dev]"
22
+ pip install pytest pytest-asyncio pytest-cov coverage-badge
23
+
24
+ - name: Run tests with coverage
25
+ run: |
26
+ pytest tests/ --cov=memoryguard --cov-report=xml --cov-report=term
27
+
28
+ - name: Generate coverage badge
29
+ run: |
30
+ coverage-badge -o coverage.svg -f
31
+
32
+ - name: Commit badge
33
+ run: |
34
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
35
+ git config --local user.name "github-actions[bot]"
36
+ git add coverage.svg
37
+ git diff --quiet && git diff --staged --quiet || git commit -m "Update coverage badge"
38
+ git push
@@ -0,0 +1,58 @@
1
+ name: Docker
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ tags:
7
+ - 'v*'
8
+ workflow_dispatch:
9
+
10
+ env:
11
+ REGISTRY: ghcr.io
12
+ IMAGE_NAME: ${{ github.repository }}
13
+
14
+ jobs:
15
+ build-and-push:
16
+ runs-on: ubuntu-latest
17
+ permissions:
18
+ contents: read
19
+ packages: write
20
+ id-token: write
21
+
22
+ steps:
23
+ - name: Checkout
24
+ uses: actions/checkout@v4
25
+
26
+ - name: Set up Docker Buildx
27
+ uses: docker/setup-buildx-action@v3
28
+
29
+ - name: Log in to GitHub Container Registry
30
+ uses: docker/login-action@v3
31
+ with:
32
+ registry: ${{ env.REGISTRY }}
33
+ username: ${{ github.actor }}
34
+ password: ${{ secrets.GITHUB_TOKEN }}
35
+
36
+ - name: Extract metadata
37
+ id: meta
38
+ uses: docker/metadata-action@v5
39
+ with:
40
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41
+ tags: |
42
+ type=ref,event=branch
43
+ type=ref,event=pr
44
+ type=semver,pattern={{version}}
45
+ type=semver,pattern={{major}}.{{minor}}
46
+ type=semver,pattern={{major}}
47
+ type=sha
48
+
49
+ - name: Build and push Docker image
50
+ uses: docker/build-push-action@v5
51
+ with:
52
+ context: .
53
+ push: true
54
+ tags: ${{ steps.meta.outputs.tags }}
55
+ labels: ${{ steps.meta.outputs.labels }}
56
+ cache-from: type=gha
57
+ cache-to: type=gha,mode=max
58
+ platforms: linux/amd64,linux/arm64
@@ -0,0 +1,105 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ python-version: '3.11'
19
+
20
+ - name: Install dependencies
21
+ run: |
22
+ pip install -e ".[dev]"
23
+ pip install pytest pytest-asyncio pytest-cov
24
+
25
+ - name: Run tests with coverage
26
+ run: pytest tests/ --cov=memoryguard --cov-report=xml --cov-fail-under=80
27
+
28
+ - name: Upload coverage
29
+ uses: codecov/codecov-action@v3
30
+ with:
31
+ file: ./coverage.xml
32
+
33
+ build:
34
+ needs: test
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+
39
+ - name: Set up Python
40
+ uses: actions/setup-python@v5
41
+ with:
42
+ python-version: '3.11'
43
+
44
+ - name: Install build dependencies
45
+ run: pip install build twine
46
+
47
+ - name: Build package
48
+ run: python -m build
49
+
50
+ - name: Check package
51
+ run: twine check dist/*
52
+
53
+ - name: Upload artifacts
54
+ uses: actions/upload-artifact@v4
55
+ with:
56
+ name: dist
57
+ path: dist/
58
+
59
+ publish-pypi:
60
+ needs: [test, build]
61
+ runs-on: ubuntu-latest
62
+ if: startsWith(github.ref, 'refs/tags/v')
63
+ environment:
64
+ name: pypi
65
+ url: https://pypi.org/p/memoryguard
66
+ permissions:
67
+ id-token: write
68
+
69
+ steps:
70
+ - name: Download artifacts
71
+ uses: actions/download-artifact@v4
72
+ with:
73
+ name: dist
74
+ path: dist/
75
+
76
+ - name: Publish to PyPI
77
+ uses: pypa/gh-action-pypi-publish@release/v1
78
+ with:
79
+ skip-existing: true
80
+
81
+ github-release:
82
+ needs: [test, build]
83
+ runs-on: ubuntu-latest
84
+ if: startsWith(github.ref, 'refs/tags/v')
85
+ permissions:
86
+ contents: write
87
+
88
+ steps:
89
+ - uses: actions/checkout@v4
90
+
91
+ - name: Download artifacts
92
+ uses: actions/download-artifact@v4
93
+ with:
94
+ name: dist
95
+ path: dist/
96
+
97
+ - name: Create Release
98
+ uses: softprops/action-gh-release@v1
99
+ with:
100
+ files: dist/*
101
+ generate_release_notes: true
102
+ draft: false
103
+ prerelease: false
104
+ env:
105
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,43 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ venv/
25
+ env/
26
+ ENV/
27
+
28
+ # IDE
29
+ .vscode/
30
+ .idea/
31
+ *.swp
32
+ *.swo
33
+ *~
34
+
35
+ # Testing
36
+ .pytest_cache/
37
+ .coverage
38
+ htmlcov/
39
+ .tox/
40
+
41
+ # MemoryGuard specific
42
+ memory-report.json
43
+ *.memory.log
@@ -0,0 +1,77 @@
1
+ # Contributing to MemoryGuard
2
+
3
+ Thank you for your interest in contributing to MemoryGuard! 🎉
4
+
5
+ ## Getting Started
6
+
7
+ 1. Fork the repository
8
+ 2. Clone your fork
9
+ 3. Install in development mode:
10
+ ```bash
11
+ pip install -e ".[dev]"
12
+ ```
13
+
14
+ ## Development Workflow
15
+
16
+ ### Running Tests
17
+
18
+ ```bash
19
+ # All tests
20
+ make test
21
+
22
+ # With coverage
23
+ make test-coverage
24
+
25
+ # Specific test
26
+ pytest tests/test_memoryguard.py::TestMemoryGuard::test_memory_check -v
27
+ ```
28
+
29
+ ### Code Style
30
+
31
+ We use:
32
+ - **black** for formatting
33
+ - **flake8** for linting
34
+ - **mypy** for type checking
35
+
36
+ ```bash
37
+ # Format code
38
+ make format
39
+
40
+ # Check style
41
+ make lint
42
+ ```
43
+
44
+ ### Before Submitting
45
+
46
+ 1. Run all tests
47
+ 2. Run linters
48
+ 3. Update documentation if needed
49
+ 4. Add tests for new features
50
+
51
+ ## Pull Request Process
52
+
53
+ 1. Create a feature branch
54
+ 2. Make your changes
55
+ 3. Add tests
56
+ 4. Update README if needed
57
+ 5. Submit PR with clear description
58
+
59
+ ## Code Guidelines
60
+
61
+ - Follow PEP 8
62
+ - Add type hints
63
+ - Write docstrings
64
+ - Keep functions focused
65
+ - Add tests for new features
66
+
67
+ ## Reporting Issues
68
+
69
+ When reporting bugs, please include:
70
+ - Python version
71
+ - Operating system
72
+ - Steps to reproduce
73
+ - Expected vs actual behavior
74
+
75
+ ## Questions?
76
+
77
+ Open an issue or discussion - we're happy to help!
@@ -0,0 +1,32 @@
1
+ # MemoryGuard Docker Image
2
+ # Usage: docker run -v $(pwd):/app ghcr.io/shadd0wtaka/memoryguard python -c "from memoryguard import MemoryGuard; ..."
3
+
4
+ FROM python:3.11-slim
5
+
6
+ LABEL maintainer="SHAdd0WTAka"
7
+ LABEL description="MemoryGuard - Modular Python Memory Monitoring"
8
+ LABEL org.opencontainers.image.source="https://github.com/SHAdd0WTAka/memoryguard"
9
+
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ git \
13
+ valgrind \
14
+ && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Set working directory
17
+ WORKDIR /app
18
+
19
+ # Copy requirements first for better caching
20
+ COPY pyproject.toml README.md ./
21
+ COPY memoryguard/ ./memoryguard/
22
+
23
+ # Install the package
24
+ RUN pip install --no-cache-dir -e ".[all]"
25
+
26
+ # Create non-root user
27
+ RUN useradd -m -u 1000 memoryguard && \
28
+ chown -R memoryguard:memoryguard /app
29
+ USER memoryguard
30
+
31
+ # Default command
32
+ CMD ["python", "-c", "from memoryguard import MemoryGuard, __version__; print(f'MemoryGuard v{__version__} ready!')"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MemoryGuard Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include README.md
2
+ include LICENSE
3
+ include MANIFEST.in
4
+ recursive-include examples *.py
5
+ recursive-include tests *.py
@@ -0,0 +1,55 @@
1
+ .PHONY: help install install-dev test test-coverage lint format clean build publish
2
+
3
+ help:
4
+ @echo "MemoryGuard - Available Commands:"
5
+ @echo ""
6
+ @echo " install Install package"
7
+ @echo " install-dev Install with dev dependencies"
8
+ @echo " test Run tests"
9
+ @echo " test-coverage Run tests with coverage"
10
+ @echo " lint Run linters"
11
+ @echo " format Format code with black"
12
+ @echo " clean Clean build artifacts"
13
+ @echo " build Build package"
14
+ @echo " publish Publish to PyPI"
15
+ @echo " demo Run demo"
16
+
17
+ install:
18
+ pip install -e .
19
+
20
+ install-dev:
21
+ pip install -e ".[dev]"
22
+ pip install -e ".[dashboard]"
23
+
24
+ test:
25
+ pytest tests/ -v
26
+
27
+ test-coverage:
28
+ pytest tests/ --cov=memoryguard --cov-report=term-missing
29
+
30
+ lint:
31
+ flake8 memoryguard/ tests/
32
+ mypy memoryguard/
33
+
34
+ format:
35
+ black memoryguard/ tests/ examples/
36
+ isort memoryguard/ tests/ examples/
37
+
38
+ clean:
39
+ rm -rf build/
40
+ rm -rf dist/
41
+ rm -rf *.egg-info/
42
+ rm -rf .pytest_cache/
43
+ rm -rf .mypy_cache/
44
+ find . -type d -name __pycache__ -exec rm -rf {} +
45
+ find . -type f -name "*.pyc" -delete
46
+
47
+ build: clean
48
+ python -m build
49
+
50
+ publish: build
51
+ twine check dist/*
52
+ twine upload dist/*
53
+
54
+ demo:
55
+ python examples/demo.py