From 59cfa77fec0e864862e991bfcd71b609ac297673 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria <6909403+Uxio0@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:22:48 +0200 Subject: [PATCH 1/3] Migrate from setuptools to hatch - Fixes issues with editable builds, [broken by new versions of setuptools](https://github.com/pypa/setuptools/issues/3548) - Migrates project to `pyproject.toml`, [as recommended](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) --- gnosis/__init__.py | 1 + pyproject.toml | 71 ++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 63 ---------------------------------------- setup.py | 4 --- 4 files changed, 72 insertions(+), 67 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/gnosis/__init__.py b/gnosis/__init__.py index e69de29b..5870d77a 100644 --- a/gnosis/__init__.py +++ b/gnosis/__init__.py @@ -0,0 +1 @@ +VERSION = "6.0.0b30" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..1bdc83f9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "safe-eth-py" +dynamic = ["version"] +description = "Safe Ecosystem Foundation utilities for Ethereum projects" +readme = "README.rst" +license = "MIT" +requires-python = ">=3.9" +authors = [ + { name = "Uxío", email = "uxio@safe.global" }, +] +keywords = [ + "cowswap", + "django", + "ethereum", + "gnosis", + "safe", + "web3", +] +classifiers = [ + "Environment :: Web Environment", + "Framework :: Django", + "Framework :: Django :: 2.0", + "Framework :: Django :: 3.0", + "Framework :: Django :: 4.0", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: Dynamic Content", +] +dependencies = [ + "packaging", + "py-evm>=0.7.0a1", + "requests>=2", + "safe-pysha3>=1.0.0", + "web3>=6.2.0", +] + +[project.optional-dependencies] +django = [ + "django-filter>=2", + "django>=2", + "djangorestframework>=2", +] + +[project.urls] +Documentation = "https://safe-eth-py.readthedocs.io/en/latest/" +Homepage = "https://github.com/safe-global/safe-eth-py" +Source = "https://github.com/safe-global/safe-eth-py" +Tracker = "https://github.com/safe-global/safe-eth-py/issues" + +[tool.hatch.version] +path = "gnosis/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/gnosis", +] +[tool.hatch.build.targets.wheel] +packages = [ + "/gnosis", +] diff --git a/setup.cfg b/setup.cfg index 1100b99b..42f1aa1c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,66 +1,3 @@ -[metadata] -name = safe-eth-py -version = 6.0.0b30 -description = Safe Ecosystem Foundation utilities for Ethereum projects -long_description = file: README.rst -long_description_content_type = text/x-rst; charset=UTF-8 -keywords = - ethereum - web3 - django - safe - cowswap - gnosis -url = https://github.com/safe-global/safe-eth-py -author = Uxío -author_email = uxio@safe.global -license = MIT License -license_files = - LICENSE -classifiers = - Environment :: Web Environment - Framework :: Django - Framework :: Django :: 2.0 - Framework :: Django :: 3.0 - Framework :: Django :: 4.0 - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Topic :: Internet :: WWW/HTTP - Topic :: Internet :: WWW/HTTP :: Dynamic Content -project_urls = - Documentation = https://safe-eth-py.readthedocs.io/en/latest/ - Source = https://github.com/safe-global/safe-eth-py - Tracker = https://github.com/safe-global/safe-eth-py/issues - -[options] -packages = find: -platforms = any -include_package_data = True -install_requires = - packaging - py-evm>=0.7.0a1 - safe-pysha3>=1.0.0 - requests>=2 - web3>=6.2.0 -python_requires = >=3.9 - -[options.package_data] -gnosis = - py.typed - *.json - -[options.extras_require] -django = - django>=2 - django-filter>=2 - djangorestframework>=2 - [flake8] max-line-length = 88 select = C,E,F,W,B,B950 diff --git a/setup.py b/setup.py deleted file mode 100644 index 1abbd068..00000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -import setuptools - -if __name__ == "__main__": - setuptools.setup() From 4bba86e1909aa0f38904c7f7ef7dacd700e92be6 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Fri, 7 Jun 2024 12:36:23 +0200 Subject: [PATCH 2/3] Move some configuration from setup.cfg to pyproject.toml --- gnosis/eth/contracts/contract_base.py | 2 +- gnosis/eth/django/serializers.py | 2 +- pyproject.toml | 34 +++++++++++++++++++++++++++ requirements-dev.txt | 1 + setup.cfg | 24 +------------------ 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/gnosis/eth/contracts/contract_base.py b/gnosis/eth/contracts/contract_base.py index 084c21a3..c5ce5ccb 100644 --- a/gnosis/eth/contracts/contract_base.py +++ b/gnosis/eth/contracts/contract_base.py @@ -16,7 +16,7 @@ def __init__( address: ChecksumAddress, ethereum_client: "EthereumClient", # noqa F821 *args, - **kwargs + **kwargs, ): self.address = address self.ethereum_client = ethereum_client diff --git a/gnosis/eth/django/serializers.py b/gnosis/eth/django/serializers.py index d24ce250..b85256bd 100644 --- a/gnosis/eth/django/serializers.py +++ b/gnosis/eth/django/serializers.py @@ -32,7 +32,7 @@ def __init__( self, allow_zero_address: bool = False, allow_sentinel_address: bool = False, - **kwargs + **kwargs, ): self.allow_zero_address = allow_zero_address self.allow_sentinel_address = allow_sentinel_address diff --git a/pyproject.toml b/pyproject.toml index 1bdc83f9..3ecdc358 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", ] @@ -61,6 +62,39 @@ Tracker = "https://github.com/safe-global/safe-eth-py/issues" [tool.hatch.version] path = "gnosis/__init__.py" +[tool.hatch.envs.types] +extra-dependencies = [ + "mypy>=1.0.0", +] + +[tool.hatch.envs.types.scripts] +check = "mypy --install-types --non-interactive {args:gnosis tests}" + +[tool.coverage.run] +include = ["gnosis/*"] +# source_pkgs = ["prueba", "tests"] +branch = true +parallel = true +omit = [ + "*__init__.py*", + "*tests*", + "*/migrations/*", +] + +#[tool.coverage.paths] +#prueba = ["src/prueba", "*/prueba/src/prueba"] +#tests = ["tests", "*/prueba/tests"] + +[tool.coverage.report] +exclude_lines = [ + "no cov", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", + "if settings.DEBUG", + "raise NotImplementedError", + "pass", +] + [tool.hatch.build.targets.sdist] include = [ "/gnosis", diff --git a/requirements-dev.txt b/requirements-dev.txt index 1047b107..727660a0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,6 +2,7 @@ -r requirements-test.txt flake8 gitpython +hatch ipdb ipython isort diff --git a/setup.cfg b/setup.cfg index 42f1aa1c..81217412 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,31 +21,9 @@ env = DJANGO_SETTINGS_MODULE=config.settings.test [mypy] -python_version = 3.10 +python_version = 3.12 check_untyped_defs = True ignore_missing_imports = True warn_unused_ignores = True warn_redundant_casts = True warn_unused_configs = True - -[coverage:report] -exclude_lines = -# Have to re-enable the standard pragma - pragma: no cover - - # Don't complain if tests don't hit defensive assertion code: - raise NotImplementedError - - # Don't complain if non-runnable code isn't run: - if __name__ == .__main__.: - if settings.DEBUG - - # Ignore pass lines - pass - -[coverage:run] -include = safe_transaction_service/* -omit = - *__init__.py* - *tests* - */migrations/* From 1702b4d817bb2432ca8c342ecf18859257c7cb3c Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Fri, 7 Jun 2024 12:37:33 +0200 Subject: [PATCH 3/3] Don't install setuptools on CI - Not required anymore --- .github/workflows/python.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 8d8f58ea..23e200c5 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -61,8 +61,7 @@ jobs: cache: 'pip' cache-dependency-path: 'requirements*.txt' - name: Install dependencies - run: | - pip install wheel setuptools + run: pip install -r requirements-test.txt coveralls env: PIP_USE_MIRRORS: true