Skip to content
Open
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
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
default_language_version:
python: python3.11

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- id: check-merge-conflict
- id: debug-statements

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies: [typing-extensions>=4.7.0]
args: [--config-file=pyproject.toml]
# Mirror run_mypy.sh: type-check the library and the examples directory.
files: ^(bitcointx|examples)/
87 changes: 87 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[build-system]
requires = ["setuptools>=68.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "python-bitcointx"
description = "A library for handling Bitcoin transactions and associated data"
readme = "README.md"
requires-python = ">=3.11"
license = {text = "LGPL-3.0-or-later"}
keywords = ["bitcoin"]
classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
"Topic :: Security :: Cryptography",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dynamic = ["version"]
# Runtime dependencies: none. Native dependencies (loaded at runtime via ctypes):
# - libsecp256k1 >= 0.3.0 and < 1.0.0 (tested with 0.4.0; 0.7.0+ supported via
# compatibility shim that detects both the old `secp256k1_ec_privkey_*`
# and the new `secp256k1_ec_seckey_*` symbol names).
# - libbitcoinconsensus (optional).
dependencies = []

[project.urls]
Homepage = "https://github.com/Simplexum/python-bitcointx"
Issues = "https://github.com/Simplexum/python-bitcointx/issues"

[project.optional-dependencies]
dev = [
"pytest>=7.4.0",
"coverage>=7.0.0",
"ruff>=0.6.0",
"mypy>=1.10.0",
"typing-extensions>=4.7.0",
"pre-commit>=3.7.0",
]

[tool.setuptools.dynamic]
version = {attr = "bitcointx.__version__"}

[tool.setuptools.packages.find]
include = ["bitcointx*"]

[tool.setuptools.package-data]
bitcointx = ["py.typed"]

[tool.ruff]
line-length = 100
target-version = "py311"
extend-exclude = ["doc", "build", "dist"]

[tool.ruff.lint]
# Conservative starting set, keeping diffs small on legacy code.
select = ["E", "F", "I", "W", "UP", "B"]
ignore = [
"E501", # line too long (long lines exist in legacy code and crypto tables)
"E741", # ambiguous variable names (used in cryptographic spec translations)
"B008", # do not perform function call in argument defaults
"B904", # raise from ... (legacy code raises plain exceptions)
"UP006", # PEP 585 syntax (kept consistent with existing typing imports)
"UP007", # PEP 604 syntax (same reason)
"UP035", # deprecated import (typing aliases used intentionally)
]

[tool.ruff.lint.per-file-ignores]
"bitcointx/core/_ripemd160.py" = ["E226", "E741"]
"bitcointx/core/sha256.py" = ["E226", "E741"]
"bitcointx/tests/*" = ["B011"]

[tool.mypy]
python_version = "3.11"
strict = true
files = ["bitcointx", "examples"]
warn_unused_ignores = true
warn_redundant_casts = true
show_error_codes = true

[tool.pytest.ini_options]
testpaths = ["bitcointx/tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
3 changes: 0 additions & 3 deletions run_flake8.sh

This file was deleted.

10 changes: 0 additions & 10 deletions run_mypy.sh

This file was deleted.

41 changes: 7 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
#!/usr/bin/env python
"""Legacy setup shim.

import os
All project metadata lives in ``pyproject.toml``. This file remains only so
that ``python setup.py <command>`` invocations continue to work for tools that
have not yet switched to the PEP 517 build interface.
"""

from setuptools import setup, find_packages
from setuptools import setup

from bitcointx import __version__

here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md')) as f:
README = f.read()

requires = []

setup(
name='python-bitcointx',
version=__version__,
description='A library for handling Bitcoin transactions and associated data',
long_description=README,
long_description_content_type='text/markdown',
classifiers=[
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
],
python_requires='>=3.7',
url='https://github.com/Simplexum/python-bitcointx',
keywords='bitcoin',
packages=find_packages(),
zip_safe=False,
install_requires=requires,
test_suite="bitcointx.tests",
package_data={"bitcointx": ["py.typed"]}
)
setup()