Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v4

Expand Down
73 changes: 57 additions & 16 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ on:


jobs:
release:
name: Build and Release
build:
name: Build for Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
strategy:
matrix:
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v4

- name: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.13"
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
Expand All @@ -30,25 +31,65 @@ jobs:
- name: Install build dependencies only
run: poetry install --only main --no-interaction --no-ansi

- name: Build package
run: poetry build
- name: Build package with custom build script
run: |
poetry run python build.py
poetry build

- name: Rename artifacts with Python version
run: |
mkdir -p dist-py${{ matrix.python-version }}
cp dist/*.whl dist-py${{ matrix.python-version }}/
cp dist/*.tar.gz dist-py${{ matrix.python-version }}/
# Rename wheel to include Python version
cd dist-py${{ matrix.python-version }}
for file in *.whl; do
if [[ "$file" != *"py${{ matrix.python-version }}"* ]]; then
mv "$file" "${file%.whl}-py${{ matrix.python-version }}.whl"
fi
done

- name: Upload Python ${{ matrix.python-version }} artifacts
uses: actions/upload-artifact@v4
with:
name: python-packages-${{ matrix.python-version }}
path: dist-py${{ matrix.python-version }}/
retention-days: 7

release:
name: Create Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/

- name: Prepare release assets
run: |
mkdir -p release-assets
find artifacts/ -name "*.whl" -exec cp {} release-assets/ \;
find artifacts/ -name "*.tar.gz" -exec cp {} release-assets/ \;

- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
body: Automated release for version ${{ github.ref_name }}
body: |
Automated release for version ${{ github.ref_name }}
draft: false
prerelease: false
files: |
dist/*.whl
dist/*.tar.gz
files: release-assets/*

- name: Upload artifacts for PyPI
- name: Upload combined artifacts for PyPI
uses: actions/upload-artifact@v4
with:
name: python-packages
path: dist/
name: python-packages-combined
path: release-assets/
retention-days: 7

publish:
Expand All @@ -63,7 +104,7 @@ jobs:
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: python-packages
name: python-packages-combined
path: dist

- name: Publish to TestPyPI
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ High-performance Python logging library with file rotation and optimized caching
- [Memory Management](#memory-management)
- [Flexible Configuration Options](#flexible-configuration-options)
- [Migration Guide](#migration-guide)
- [Development](#source-code)
- [Run Tests and Get Coverage Report using Poe](#run-tests-and-get-coverage-report-using-poe)
- [Development](#development)
- [Development](#development)
- [Building from Source](#building-from-source)
- [Running Tests](#running-tests)
- [License](#license)
- [Buy me a cup of coffee](#buy-me-a-cup-of-coffee)
- [Support](#support)



Expand Down Expand Up @@ -520,25 +522,27 @@ timed_logger = timed_rotating_logger(level=LogLevel.WARNING, name="app", directo
- 📚 **Centralized configuration** through factory pattern


# Source Code
### Build
# Development

### Building from Source
```shell
poetry build -f wheel
```


# Run Tests and Get Coverage Report using Poe
### Running Tests
```shell
poetry update --with test
poe test
poe tests
```


# License

Released under the [MIT License](LICENSE)

# Support

If you find this project helpful, consider supporting development:

# Buy me a cup of coffee
+ [GitHub Sponsor](https://github.com/sponsors/ddc)
+ [ko-fi](https://ko-fi.com/ddcsta)
+ [Paypal](https://www.paypal.com/ncp/payment/6G9Z78QHUD4RJ)
- [GitHub Sponsor](https://github.com/sponsors/ddc)
- [ko-fi](https://ko-fi.com/ddcsta)
- [PayPal](https://www.paypal.com/ncp/payment/6G9Z78QHUD4RJ)
71 changes: 71 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python
import compileall
import sys
import tomllib
from pathlib import Path


def parse_python_version_requirement():
"""Parse Python version requirement from pyproject.toml"""
pyproject_path = Path(__file__).parent / "pyproject.toml"

with open(pyproject_path, "rb") as f:
data = tomllib.load(f)

python_req = data["tool"]["poetry"]["dependencies"]["python"]

# Parse version constraint like "^3.12"
if python_req.startswith("^"):
min_version = python_req[1:]
major, minor = map(int, min_version.split("."))
return major, minor
elif python_req.startswith(">="):
min_version = python_req[2:]
major, minor = map(int, min_version.split("."))
return major, minor
else:
# Default fallback
return 3, 12


def get_compatible_python_versions(min_major, min_minor):
"""Generate list of compatible Python versions"""
versions = []
current_major, current_minor = sys.version_info[:2]

# Start from the minimum required version
for major in range(min_major, min_major + 1): # Only Python 3.x for now
start_minor = min_minor if major == min_major else 0
# Go up to current Python version + 2 minor versions for future compatibility
end_minor = max(current_minor + 2, 12) if major == current_major else 12

for minor in range(start_minor, end_minor + 1):
if major == 3 and minor >= min_minor:
versions.append(f"{major}.{minor}")

return versions


def build():
"""Build bytecode for all compatible Python versions"""
try:
min_major, min_minor = parse_python_version_requirement()
compatible_versions = get_compatible_python_versions(min_major, min_minor)

print(f"Building for Python versions: {', '.join(compatible_versions)}")

# Compile for current Python version
print(f"Compiling for Python {sys.version_info.major}.{sys.version_info.minor}")
compileall.compile_dir('pythonDatabases', force=True)

# Note: For actual cross-version bytecode, you'd need multiple Python interpreters
# This compiles with current interpreter but documents compatibility
print("Build completed successfully")

except Exception as e:
print(f"Build failed: {e}")
sys.exit(1)


if __name__ == "__main__":
build()
72 changes: 3 additions & 69 deletions poetry.lock

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

14 changes: 9 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pythonLogs"
version = "4.0.6"
version = "4.0.7"
description = "High-performance Python logging library with file rotation and optimized caching for better performance"
license = "MIT"
readme = "README.md"
Expand All @@ -30,8 +30,15 @@ classifiers = [
"Natural Language :: English",
]

[tool.poetry.build]
script = "build.py"
generate-setup-file = false

[tool.poetry.group.test]
optional = true

[tool.poetry.dependencies]
python = "^3.10"
python = "^3.12"
pydantic-settings = "^2.10.1"
python-dotenv = "^1.1.1"

Expand All @@ -48,9 +55,6 @@ _coverage_xml = "coverage xml"
tests = ["_test", "_coverage_report", "_coverage_xml"]
test = ["tests"]

[tool.poetry.group.test]
optional = true

[tool.black]
line-length = 120
skip-string-normalization = true
Expand Down
Loading