From 3af0d286b32d3c1e978f8319bc0fe654f7464f74 Mon Sep 17 00:00:00 2001 From: ddc Date: Wed, 23 Jul 2025 14:03:12 -0300 Subject: [PATCH 1/6] V4.0.7 --- .github/workflows/tests.yml | 2 +- .github/workflows/workflow.yml | 75 ++++++++++++++++++++++++++-------- README.md | 30 ++++++++------ build.py | 71 ++++++++++++++++++++++++++++++++ poetry.lock | 72 ++------------------------------ pyproject.toml | 14 ++++--- 6 files changed, 160 insertions(+), 104 deletions(-) create mode 100644 build.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 28213bb..41765a6 100755 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 40ac9ad..974948b 100755 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -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 @@ -30,25 +31,67 @@ 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 }} + + This release includes builds for Python 3.10, 3.11, 3.12, and 3.13. 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: @@ -63,7 +106,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 diff --git a/README.md b/README.md index ab5cf90..172409d 100755 --- a/README.md +++ b/README.md @@ -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) @@ -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) diff --git a/build.py b/build.py new file mode 100644 index 0000000..95d1b07 --- /dev/null +++ b/build.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +import sys +import compileall +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.10" + 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, 11 + + +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: # Only include 3.10+ + 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() diff --git a/poetry.lock b/poetry.lock index ac7a1ec..0123c0f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -105,25 +105,6 @@ files = [ [package.extras] toml = ["tomli ; python_full_version <= \"3.11.0a6\""] -[[package]] -name = "exceptiongroup" -version = "1.3.0" -description = "Backport of PEP 654 (exception groups)" -optional = false -python-versions = ">=3.7" -groups = ["test"] -markers = "python_version == \"3.10\"" -files = [ - {file = "exceptiongroup-1.3.0-py3-none-any.whl", hash = "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10"}, - {file = "exceptiongroup-1.3.0.tar.gz", hash = "sha256:b241f5885f560bc56a59ee63ca4c6a8bfa46ae4ad651af316d4e81817bb9fd88"}, -] - -[package.dependencies] -typing-extensions = {version = ">=4.6.0", markers = "python_version < \"3.13\""} - -[package.extras] -test = ["pytest (>=6)"] - [[package]] name = "iniconfig" version = "2.1.0" @@ -191,7 +172,6 @@ files = [ [package.dependencies] pastel = ">=0.2.1,<0.3.0" pyyaml = ">=6.0.2,<7.0" -tomli = {version = ">=1.2.2", markers = "python_version < \"3.11\""} [package.extras] poetry-plugin = ["poetry (>=1.2.0,<3.0.0) ; python_version < \"4.0\""] @@ -407,12 +387,10 @@ files = [ [package.dependencies] colorama = {version = ">=0.4", markers = "sys_platform == \"win32\""} -exceptiongroup = {version = ">=1", markers = "python_version < \"3.11\""} iniconfig = ">=1" packaging = ">=20" pluggy = ">=1.5,<2" pygments = ">=2.7.2" -tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "requests", "setuptools", "xmlschema"] @@ -495,61 +473,17 @@ files = [ {file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"}, ] -[[package]] -name = "tomli" -version = "2.2.1" -description = "A lil' TOML parser" -optional = false -python-versions = ">=3.8" -groups = ["test"] -markers = "python_version == \"3.10\"" -files = [ - {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, - {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, - {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a"}, - {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee"}, - {file = "tomli-2.2.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e"}, - {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4"}, - {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106"}, - {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8"}, - {file = "tomli-2.2.1-cp311-cp311-win32.whl", hash = "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff"}, - {file = "tomli-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b"}, - {file = "tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea"}, - {file = "tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8"}, - {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192"}, - {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222"}, - {file = "tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77"}, - {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6"}, - {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd"}, - {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e"}, - {file = "tomli-2.2.1-cp312-cp312-win32.whl", hash = "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98"}, - {file = "tomli-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4"}, - {file = "tomli-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7"}, - {file = "tomli-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c"}, - {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13"}, - {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281"}, - {file = "tomli-2.2.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272"}, - {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140"}, - {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2"}, - {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744"}, - {file = "tomli-2.2.1-cp313-cp313-win32.whl", hash = "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec"}, - {file = "tomli-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69"}, - {file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"}, - {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, -] - [[package]] name = "typing-extensions" version = "4.14.1" description = "Backported and Experimental Type Hints for Python 3.9+" optional = false python-versions = ">=3.9" -groups = ["main", "test"] +groups = ["main"] files = [ {file = "typing_extensions-4.14.1-py3-none-any.whl", hash = "sha256:d1e1e3b58374dc93031d6eda2420a48ea44a36c2b4766a4fdeb3710755731d76"}, {file = "typing_extensions-4.14.1.tar.gz", hash = "sha256:38b39f4aeeab64884ce9f74c94263ef78f3c22467c8724005483154c26648d36"}, ] -markers = {test = "python_version == \"3.10\""} [[package]] name = "typing-inspection" @@ -568,5 +502,5 @@ typing-extensions = ">=4.12.0" [metadata] lock-version = "2.1" -python-versions = "^3.10" -content-hash = "1b58e2194b8ca5f7f291348a8dfbb2f7bf2b5eb0d781d0aee4955e482a159115" +python-versions = "^3.12" +content-hash = "f5274cb99a5307fb389b434e47d7bea063341abf33c538472dbff5a8dac6d37a" diff --git a/pyproject.toml b/pyproject.toml index 47d84d3..56f2c91 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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" @@ -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 From 91b5a332df4b28ed8904269a19c115b47950d1c6 Mon Sep 17 00:00:00 2001 From: ddc Date: Wed, 23 Jul 2025 14:07:26 -0300 Subject: [PATCH 2/6] V4.0.7 --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 95d1b07..fa251e0 100644 --- a/build.py +++ b/build.py @@ -25,7 +25,7 @@ def parse_python_version_requirement(): return major, minor else: # Default fallback - return 3, 11 + return 3, 12 def get_compatible_python_versions(min_major, min_minor): From 7f1ab416de3bf4ee49314425b914c37118226eb1 Mon Sep 17 00:00:00 2001 From: ddc Date: Wed, 23 Jul 2025 14:12:52 -0300 Subject: [PATCH 3/6] V4.0.7 --- build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.py b/build.py index fa251e0..a75ed14 100644 --- a/build.py +++ b/build.py @@ -14,7 +14,7 @@ def parse_python_version_requirement(): python_req = data["tool"]["poetry"]["dependencies"]["python"] - # Parse version constraint like "^3.10" + # Parse version constraint like "^3.12" if python_req.startswith("^"): min_version = python_req[1:] major, minor = map(int, min_version.split(".")) @@ -40,7 +40,7 @@ def get_compatible_python_versions(min_major, min_minor): 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: # Only include 3.10+ + if major == 3 and minor >= min_minor: versions.append(f"{major}.{minor}") return versions From 534255b8c9832be7f2fa036824fda40d464cec3d Mon Sep 17 00:00:00 2001 From: ddc Date: Wed, 23 Jul 2025 14:13:25 -0300 Subject: [PATCH 4/6] V4.0.7 --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index a75ed14..5e9c7fa 100644 --- a/build.py +++ b/build.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys import compileall +import sys import tomllib from pathlib import Path From d29725960380fba6a31f9ae71be907f827c43435 Mon Sep 17 00:00:00 2001 From: ddc Date: Wed, 23 Jul 2025 14:16:36 -0300 Subject: [PATCH 5/6] V4.0.7 --- pythonLogs/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonLogs/__init__.py b/pythonLogs/__init__.py index 9abc452..e9087eb 100755 --- a/pythonLogs/__init__.py +++ b/pythonLogs/__init__.py @@ -58,7 +58,7 @@ __email__ = "danieldcsta@gmail.com>" __license__ = "MIT" __copyright__ = "Copyright 2024-present ddc" -_req_python_version = (3, 10, 0) +_req_python_version = (3, 12, 0) try: From 648a1a5b2e4f8aadc860d74a45f6cf0d29663b4c Mon Sep 17 00:00:00 2001 From: ddc Date: Wed, 23 Jul 2025 14:35:55 -0300 Subject: [PATCH 6/6] V4.0.7 --- .github/workflows/workflow.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 974948b..91c8d96 100755 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -81,8 +81,6 @@ jobs: name: Release ${{ github.ref_name }} body: | Automated release for version ${{ github.ref_name }} - - This release includes builds for Python 3.10, 3.11, 3.12, and 3.13. draft: false prerelease: false files: release-assets/*