From 7b00a616ce1cdb1a6604d7c85acfc3d10c56fb49 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/7] 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 e69de29bb..5870d77af 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 000000000..1bdc83f9f --- /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 1100b99b5..42f1aa1ce 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 1abbd068c..000000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -import setuptools - -if __name__ == "__main__": - setuptools.setup() From 26309679e0fb11f0ac1e73eed1bbb9947a473840 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Fri, 7 Jun 2024 12:36:23 +0200 Subject: [PATCH 2/7] 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 084c21a36..c5ce5ccb3 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 d24ce250c..b85256bd3 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 1bdc83f9f..3ecdc3584 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 1047b1070..727660a00 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 42f1aa1ce..81217412c 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 9220ee4a21f3545d6bce015c7ce9abca0636fe38 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Fri, 7 Jun 2024 12:37:33 +0200 Subject: [PATCH 3/7] 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 8d8f58ea3..23e200c51 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 From 3df92dc0a35f3aeeaebda3190b2535321ebc7315 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Fri, 7 Jun 2024 16:07:01 +0200 Subject: [PATCH 4/7] Move configuration to pyproject.toml --- pyproject.toml | 25 +++++++++++++++++++++++++ setup.cfg | 16 ---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3ecdc3584..b1090814c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,7 +99,32 @@ exclude_lines = [ include = [ "/gnosis", ] + [tool.hatch.build.targets.wheel] packages = [ "/gnosis", ] + +[tool.isort] +profile = "black" +default_section = "THIRDPARTY" +known_first_party = "gnosis" +known_safe_foundation = "py_eth_sig_utils" +known_django = "django" +sections = [ + "FUTURE", + "STDLIB", + "DJANGO", + "THIRDPARTY", + "SAFE_FOUNDATION", + "FIRSTPARTY", + "LOCALFOLDER", +] + +[tool.mypy] +python_version = "3.12" +check_untyped_defs = true +ignore_missing_imports = true +warn_unused_ignores = true +warn_redundant_casts = true +warn_unused_configs = true diff --git a/setup.cfg b/setup.cfg index 81217412c..11c658e49 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,22 +8,6 @@ exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv max-line-length = 120 exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv -[isort] -profile = black -default_section = THIRDPARTY -known_first_party = gnosis -known_gnosis = py_eth_sig_utils -known_django = django -sections = FUTURE,STDLIB,DJANGO,THIRDPARTY,GNOSIS,FIRSTPARTY,LOCALFOLDER - [tool:pytest] env = DJANGO_SETTINGS_MODULE=config.settings.test - -[mypy] -python_version = 3.12 -check_untyped_defs = True -ignore_missing_imports = True -warn_unused_ignores = True -warn_redundant_casts = True -warn_unused_configs = True From ea09e5029ba3adefe5e3d7d79178f7d307c766e7 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Fri, 7 Jun 2024 16:10:33 +0200 Subject: [PATCH 5/7] Move more configuration to pyproject.toml --- pyproject.toml | 3 +++ setup.cfg | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b1090814c..2453b0f76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,3 +128,6 @@ ignore_missing_imports = true warn_unused_ignores = true warn_redundant_casts = true warn_unused_configs = true + +[tool.pytest_env] +DJANGO_SETTINGS_MODULE = "config.settings.test" diff --git a/setup.cfg b/setup.cfg index 11c658e49..a391c7063 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,3 @@ exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv [pycodestyle] max-line-length = 120 exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv - -[tool:pytest] -env = - DJANGO_SETTINGS_MODULE=config.settings.test From d2c301125eec372d599381878aa7bdf5a029ea18 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Fri, 7 Jun 2024 16:25:54 +0200 Subject: [PATCH 6/7] Rename some minor fields --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2453b0f76..886e13b5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,11 +68,11 @@ extra-dependencies = [ ] [tool.hatch.envs.types.scripts] -check = "mypy --install-types --non-interactive {args:gnosis tests}" +check = "mypy --install-types --non-interactive {args:gnosis}" [tool.coverage.run] include = ["gnosis/*"] -# source_pkgs = ["prueba", "tests"] +# source_pkgs = ["gnosis", "tests"] branch = true parallel = true omit = [ @@ -82,8 +82,8 @@ omit = [ ] #[tool.coverage.paths] -#prueba = ["src/prueba", "*/prueba/src/prueba"] -#tests = ["tests", "*/prueba/tests"] +#prueba = ["src/gnosis", "*/gnosis/src/gnosis"] +#tests = ["tests", "*/gnosis/tests"] [tool.coverage.report] exclude_lines = [ From 30a17d3b19ac1b7c3478ccfc344efc08958b1a12 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Fri, 7 Jun 2024 16:46:48 +0200 Subject: [PATCH 7/7] Use Python 3.12 to publish the package --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 23e200c51..eb438e1f8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -93,7 +93,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.12 - name: Deploy Package run: | python -m pip install --upgrade build twine