Skip to content

Commit

Permalink
Modernize all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwatson committed May 8, 2024
1 parent 9caee5a commit b38e418
Show file tree
Hide file tree
Showing 19 changed files with 236 additions and 94 deletions.
2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
actions:
patterns:
- "*"
25 changes: 7 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,21 @@ jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Checkers
run: pip install flake8 black isort
- name: flake8
run: flake8
- name: black
run: black --check .
- name: isort
run: isort --check .
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Requirements
run: pip install cryptography
run: pip install -r requirements-dev.lock
- name: Run Tests
run: python tests.py
run: pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ __pycache__
/build
/pip-wheel-metadata
.vscode
.nova
.coverage
/htmlcov
/site
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.3
hooks:
# Run the linter.
- id: ruff
args: ["--fix"]
# Run the formatter.
- id: ruff-format
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.2
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## 1.1.0 (Unreleased)

* Increased default PBKDF2 iterations to 600,000
* Changed `DEFAULT_BLOCK_SIZE` from 256k to 128k
* Removed the `tqdm` optional requirement
* Switched to `pyproject.toml`, [hatchling](https://hatch.pypa.io/) for builds, and
[ruff](https://github.com/astral-sh/ruff) for formatting and linting


## 1.0.0 (2023-03-09)

* Initial release
58 changes: 58 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[project]
name = "pzip"
dynamic = ["version"]
description = "Crytographically secure file compression."
authors = [
{ name = "Dan Watson", email = "watsond@imsweb.com" }
]
dependencies = [
"cryptography>=42.0.7",
]
readme = "README.md"
requires-python = ">= 3.8"
license = { text = "MIT" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Security",
"Topic :: System :: Archiving :: Compression",
]

[project.optional-dependencies]
deflate = ["deflate"]

[project.urls]
Homepage = "https://github.com/imsweb/pzip"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.2.0",
"pytest-cov>=5.0.0",
"mkdocs>=1.6.0",
"mkdocs-material>=9.5.21",
"pre-commit>=3.7.0",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/pzip"]

[tool.hatch.version]
path = "src/pzip/__init__.py"

[tool.ruff.lint]
extend-select = ["I"]
isort.known-first-party = ["pzip"]

[tool.pytest.ini_options]
addopts = "--cov=pzip"
108 changes: 108 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

-e file:.
babel==2.15.0
# via mkdocs-material
certifi==2024.2.2
# via requests
cffi==1.16.0
# via cryptography
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via mkdocs
colorama==0.4.6
# via mkdocs-material
coverage==7.5.1
# via pytest-cov
cryptography==42.0.7
# via pzip
distlib==0.3.8
# via virtualenv
filelock==3.14.0
# via virtualenv
ghp-import==2.1.0
# via mkdocs
identify==2.5.36
# via pre-commit
idna==3.7
# via requests
iniconfig==2.0.0
# via pytest
jinja2==3.1.4
# via mkdocs
# via mkdocs-material
markdown==3.6
# via mkdocs
# via mkdocs-material
# via pymdown-extensions
markupsafe==2.1.5
# via jinja2
# via mkdocs
mergedeep==1.3.4
# via mkdocs
# via mkdocs-get-deps
mkdocs==1.6.0
# via mkdocs-material
mkdocs-get-deps==0.2.0
# via mkdocs
mkdocs-material==9.5.21
mkdocs-material-extensions==1.3.1
# via mkdocs-material
nodeenv==1.8.0
# via pre-commit
packaging==24.0
# via mkdocs
# via pytest
paginate==0.5.6
# via mkdocs-material
pathspec==0.12.1
# via mkdocs
platformdirs==4.2.1
# via mkdocs-get-deps
# via virtualenv
pluggy==1.5.0
# via pytest
pre-commit==3.7.0
pycparser==2.22
# via cffi
pygments==2.18.0
# via mkdocs-material
pymdown-extensions==10.8.1
# via mkdocs-material
pytest==8.2.0
# via pytest-cov
pytest-cov==5.0.0
python-dateutil==2.9.0.post0
# via ghp-import
pyyaml==6.0.1
# via mkdocs
# via mkdocs-get-deps
# via pre-commit
# via pymdown-extensions
# via pyyaml-env-tag
pyyaml-env-tag==0.1
# via mkdocs
regex==2024.4.28
# via mkdocs-material
requests==2.31.0
# via mkdocs-material
setuptools==69.5.1
# via nodeenv
six==1.16.0
# via python-dateutil
urllib3==2.2.1
# via requests
virtualenv==20.26.1
# via pre-commit
watchdog==4.0.0
# via mkdocs
16 changes: 16 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

-e file:.
cffi==1.16.0
# via cryptography
cryptography==42.0.7
# via pzip
pycparser==2.22
# via cffi
5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

39 changes: 0 additions & 39 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion pzip/__init__.py → src/pzip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .reader import PZipReader
from .writer import PZipWriter

__version__ = "1.0.0"
__version__ = "1.1.0"
__version_info__ = tuple(int(num) for num in __version__.split("."))


Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions pzip/base.py → src/pzip/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC

try:
import deflate
import deflate # pyright: ignore[reportMissingImports]

gzip_compress = deflate.gzip_compress
gzip_decompress = deflate.gzip_decompress
Expand Down Expand Up @@ -42,7 +42,7 @@ class InvalidFile(Exception):


# Number of PBKDF2 iterations to use by default. May increase over time.
DEFAULT_ITERATIONS = 200000
DEFAULT_ITERATIONS = 600_000


class Flag(enum.IntFlag):
Expand Down Expand Up @@ -235,7 +235,7 @@ class Password(KeyMaterial):

class PZip(io.RawIOBase):
# First two bytes of any PZIP file.
MAGIC = b"\xB6\x9E" # ¶ž
MAGIC = b"\xb6\x9e" # ¶ž

# PZip header format (for struct):
# magic, version, flags, algorithm, kdf, compression, #tags
Expand All @@ -245,8 +245,8 @@ class PZip(io.RawIOBase):
HEADER_SIZE = struct.calcsize(HEADER_FORMAT)

# Default plaintext block size when encrypting.
# Benchmarking suggests that block sizes in the 256k-1MB range perform best.
DEFAULT_BLOCK_SIZE = 2**18 # 256k
# Benchmarking suggests that block sizes in the 128k-1MB range perform best.
DEFAULT_BLOCK_SIZE = 2**17 # 128k

def __init__(
self,
Expand Down
Loading

0 comments on commit b38e418

Please sign in to comment.