Skip to content

Commit b1de7ef

Browse files
authored
Move dependencies to pyproject.toml (ethereum#4093)
1 parent b73f3bd commit b1de7ef

6 files changed

Lines changed: 92 additions & 74 deletions

File tree

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ commands:
3636
steps:
3737
- restore_cached_venv:
3838
venv_name: v32-pyspec
39-
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}
39+
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "pyproject.toml" }}
4040
save_pyspec_cached_venv:
4141
description: Save a venv into a cache with pyspec keys"
4242
steps:
4343
- save_cached_venv:
4444
venv_name: v32-pyspec
45-
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}
45+
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "pyproject.toml" }}
4646
venv_path: ./venv
4747
jobs:
4848
checkout_specs:

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ PIP_VENV = $(VENV)/bin/pip3
6161
CODESPELL_VENV = $(VENV)/bin/codespell
6262

6363
# Make a virtual environment will all of the necessary dependencies.
64-
$(VENV): requirements_preinstallation.txt
64+
$(VENV): pyproject.toml
6565
@echo "Creating virtual environment"
6666
@python3 -m venv $(VENV)
67-
@$(PIP_VENV) install -r requirements_preinstallation.txt
6867

6968
###############################################################################
7069
# Specification

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[build-system]
2+
requires = [
3+
"marko==1.0.2",
4+
"ruamel.yaml==0.17.21",
5+
"setuptools==75.8.0",
6+
"wheel==0.45.1",
7+
]
8+
9+
[project]
10+
name = "eth2spec"
11+
dynamic = ["version"]
12+
authors = [{ name = "ethereum" }]
13+
description = "Ethereum consensus layer specifications package"
14+
readme = { file = "README.md", content-type = "text/markdown" }
15+
requires-python = ">=3.9,<4.0"
16+
dependencies = [
17+
"curdleproofs==0.1.2",
18+
"eth-typing==3.5.2",
19+
"eth-utils==2.3.2",
20+
"lru-dict==1.2.0",
21+
"marko==1.0.2",
22+
"milagro_bls_binding==1.9.0",
23+
"py_arkworks_bls12381==0.3.8",
24+
"py_ecc==6.0.0",
25+
"pycryptodome==3.21.0",
26+
"remerkleable==0.1.28",
27+
"ruamel.yaml==0.17.21",
28+
"setuptools==75.8.0",
29+
"trie==3.0.1",
30+
]
31+
32+
[project.optional-dependencies]
33+
test = [
34+
"pytest-cov==6.0.0",
35+
"pytest-xdist==3.6.1",
36+
"pytest==8.3.4",
37+
]
38+
lint = [
39+
"codespell==2.4.0",
40+
"flake8==5.0.4",
41+
"mypy==0.981",
42+
"pylint==3.3.1",
43+
]
44+
generator = [
45+
"filelock==3.17.0",
46+
"pathos==0.3.0",
47+
"pytest==8.3.4",
48+
"python-snappy==0.7.3",
49+
]
50+
docs = [
51+
"mdx-truly-sane-lists==1.3",
52+
"mkdocs-awesome-pages-plugin==2.8.0",
53+
"mkdocs-material==9.1.5",
54+
"mkdocs==1.4.2",
55+
]

setup.py

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,62 @@
1-
from setuptools import setup, find_packages, Command
2-
from setuptools.command.build_py import build_py
3-
from distutils import dir_util
4-
from distutils.util import convert_path
5-
from pathlib import Path
1+
import ast
2+
import copy
3+
import json
4+
import logging
65
import os
76
import string
8-
from typing import Dict, List, Sequence, Optional, Tuple
9-
import ast
10-
import subprocess
117
import sys
12-
import copy
8+
import warnings
9+
1310
from collections import OrderedDict
14-
import json
11+
from distutils import dir_util
12+
from distutils.util import convert_path
1513
from functools import lru_cache
14+
from marko.block import Heading, FencedCode, LinkRefDef, BlankLine
15+
from marko.ext.gfm import gfm
16+
from marko.ext.gfm.elements import Table
17+
from marko.inline import CodeSpan
18+
from pathlib import Path
19+
from ruamel.yaml import YAML
20+
from setuptools import setup, find_packages, Command
21+
from setuptools.command.build_py import build_py
22+
from typing import Dict, List, Sequence, Optional, Tuple
23+
24+
pysetup_path = os.path.abspath(os.path.dirname(__file__))
25+
sys.path.insert(0, pysetup_path)
1626

1727
from pysetup.constants import (
18-
# code names
1928
PHASE0,
20-
# misc
2129
ETH2_SPEC_COMMENT_PREFIX,
2230
)
23-
from pysetup.spec_builders import spec_builders
24-
from pysetup.typing import (
25-
BuildTarget,
26-
ProtocolDefinition,
27-
SpecObject,
28-
VariableDefinition,
29-
)
3031
from pysetup.helpers import (
3132
combine_spec_objects,
3233
dependency_order_class_objects,
3334
objects_to_spec,
3435
parse_config_vars,
3536
)
36-
from pysetup.md_doc_paths import get_md_doc_paths
37+
from pysetup.md_doc_paths import (
38+
get_md_doc_paths
39+
)
40+
from pysetup.spec_builders import (
41+
spec_builders
42+
)
43+
from pysetup.typing import (
44+
BuildTarget,
45+
ProtocolDefinition,
46+
SpecObject,
47+
VariableDefinition,
48+
)
49+
3750

3851
# Ignore '1.5.0-alpha.*' to '1.5.0a*' messages.
39-
import warnings
4052
warnings.filterwarnings('ignore', message='Normalizing .* to .*')
4153

4254
# Ignore 'running' and 'creating' messages
43-
import logging
4455
class PyspecFilter(logging.Filter):
4556
def filter(self, record):
4657
return not record.getMessage().startswith(('running ', 'creating '))
4758
logging.getLogger().addFilter(PyspecFilter())
4859

49-
# NOTE: have to programmatically include third-party dependencies in `setup.py`.
50-
def installPackage(package: str):
51-
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
52-
53-
RUAMEL_YAML_VERSION = "ruamel.yaml==0.17.21"
54-
try:
55-
import ruamel.yaml
56-
except ImportError:
57-
installPackage(RUAMEL_YAML_VERSION)
58-
59-
from ruamel.yaml import YAML
60-
61-
MARKO_VERSION = "marko==1.0.2"
62-
try:
63-
import marko
64-
except ImportError:
65-
installPackage(MARKO_VERSION)
66-
67-
from marko.block import Heading, FencedCode, LinkRefDef, BlankLine
68-
from marko.inline import CodeSpan
69-
from marko.ext.gfm import gfm
70-
from marko.ext.gfm.elements import Table
71-
7260

7361
@lru_cache(maxsize=None)
7462
def _get_name_from_heading(heading: Heading) -> Optional[str]:
@@ -550,12 +538,9 @@ def run(self):
550538
spec_version = f.read().strip()
551539

552540
setup(
553-
name='eth2spec',
554541
version=spec_version,
555-
description="Eth2 spec, provided as Python package for tooling and testing",
556542
long_description=readme,
557543
long_description_content_type="text/markdown",
558-
author="ethereum",
559544
url="https://github.com/ethereum/consensus-specs",
560545
include_package_data=False,
561546
package_data={
@@ -575,25 +560,4 @@ def run(self):
575560
packages=find_packages(where='tests/core/pyspec') + ['configs', 'presets', 'specs', 'presets', 'sync'],
576561
py_modules=["eth2spec"],
577562
cmdclass=commands,
578-
python_requires=">=3.9, <4",
579-
extras_require={
580-
"test": ["pytest>=4.4", "pytest-cov", "pytest-xdist"],
581-
"lint": ["flake8==5.0.4", "mypy==0.981", "pylint==3.3.1", "codespell==2.4.0"],
582-
"generator": ["setuptools>=72.0.0", "pytest>4.4", "python-snappy==0.7.3", "filelock", "pathos==0.3.0"],
583-
"docs": ["mkdocs==1.4.2", "mkdocs-material==9.1.5", "mdx-truly-sane-lists==1.3", "mkdocs-awesome-pages-plugin==2.8.0"]
584-
},
585-
install_requires=[
586-
"eth-utils>=2.0.0,<3",
587-
"eth-typing>=3.2.0,<4.0.0",
588-
"pycryptodome>=3.19.1",
589-
"py_ecc==6.0.0",
590-
"milagro_bls_binding==1.9.0",
591-
"remerkleable==0.1.28",
592-
"trie>=3,<4",
593-
RUAMEL_YAML_VERSION,
594-
"lru-dict==1.2.0",
595-
MARKO_VERSION,
596-
"py_arkworks_bls12381==0.3.8",
597-
"curdleproofs==0.1.2",
598-
]
599563
)

solidity_deposit_contract/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ install_deposit_contract_web3_tester:
3030
@cd $(DEPOSIT_CONTRACT_TESTER_DIR); \
3131
python3 -m venv venv; \
3232
source venv/bin/activate; \
33-
python3 -m pip install -r ../../requirements_preinstallation.txt; \
33+
python3 -m pip install -r requirements_preinstallation.txt; \
3434
python3 -m pip install -r requirements.txt
3535

3636
test_deposit_contract_web3_tests:

requirements_preinstallation.txt renamed to solidity_deposit_contract/web3_tester/requirements_preinstallation.txt

File renamed without changes.

0 commit comments

Comments
 (0)