From 05970c93831ca3b0db08e265355335ec4791ae25 Mon Sep 17 00:00:00 2001 From: protolambda Date: Thu, 28 Mar 2019 23:10:16 +0800 Subject: [PATCH] fix pyspec setup, and update usages: py_tests and in docs --- py_tests/README.md | 3 ++- py_tests/conftest.py | 0 .../block_processing/test_process_attestation.py | 2 +- .../block_processing/test_process_block_header.py | 2 +- .../phase0/block_processing/test_process_deposit.py | 2 +- .../test_process_proposer_slashing.py | 2 +- .../phase0/block_processing/test_voluntary_exit.py | 2 +- py_tests/requirements.txt | 2 +- test_generators/README.md | 11 ++++++++--- {py_tests => test_libs/pyspec/eth2}/__init__.py | 0 test_libs/pyspec/setup.py | 5 ++--- 11 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 py_tests/conftest.py rename {py_tests => test_libs/pyspec/eth2}/__init__.py (100%) diff --git a/py_tests/README.md b/py_tests/README.md index 659e737f1..86e2b541d 100644 --- a/py_tests/README.md +++ b/py_tests/README.md @@ -13,9 +13,10 @@ From within the py_tests folder: Install dependencies: ```bash python3 -m venv venv -. py_tests/venv/bin/activate +. venv/bin/activate pip3 install -r requirements.txt ``` +Note: make sure to run `make pyspec` from the root of the specs repository, to build the pyspec requirement. Run the tests: ``` diff --git a/py_tests/conftest.py b/py_tests/conftest.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/py_tests/phase0/block_processing/test_process_attestation.py b/py_tests/phase0/block_processing/test_process_attestation.py index f76ca77d8..ba2754092 100644 --- a/py_tests/phase0/block_processing/test_process_attestation.py +++ b/py_tests/phase0/block_processing/test_process_attestation.py @@ -11,7 +11,7 @@ from eth2.phase0.spec import ( process_attestation, slot_to_epoch, ) -from ..helpers import ( +from phase0.helpers import ( build_empty_block_for_next_slot, get_valid_attestation, ) diff --git a/py_tests/phase0/block_processing/test_process_block_header.py b/py_tests/phase0/block_processing/test_process_block_header.py index ef902bb72..0c4a930c2 100644 --- a/py_tests/phase0/block_processing/test_process_block_header.py +++ b/py_tests/phase0/block_processing/test_process_block_header.py @@ -8,7 +8,7 @@ from eth2.phase0.spec import ( advance_slot, process_block_header, ) -from ..helpers import ( +from phase0.helpers import ( build_empty_block_for_next_slot, ) diff --git a/py_tests/phase0/block_processing/test_process_deposit.py b/py_tests/phase0/block_processing/test_process_deposit.py index 19467984e..bda014665 100644 --- a/py_tests/phase0/block_processing/test_process_deposit.py +++ b/py_tests/phase0/block_processing/test_process_deposit.py @@ -8,7 +8,7 @@ from eth2.phase0.spec import ( ZERO_HASH, process_deposit, ) -from ..helpers import ( +from phase0.helpers import ( build_deposit, privkeys, pubkeys, diff --git a/py_tests/phase0/block_processing/test_process_proposer_slashing.py b/py_tests/phase0/block_processing/test_process_proposer_slashing.py index 761624c25..b172cd988 100644 --- a/py_tests/phase0/block_processing/test_process_proposer_slashing.py +++ b/py_tests/phase0/block_processing/test_process_proposer_slashing.py @@ -7,7 +7,7 @@ from eth2.phase0.spec import ( get_current_epoch, process_proposer_slashing, ) -from ..helpers import ( +from phase0.helpers import ( get_valid_proposer_slashing, ) diff --git a/py_tests/phase0/block_processing/test_voluntary_exit.py b/py_tests/phase0/block_processing/test_voluntary_exit.py index 45a8af1bb..32c747024 100644 --- a/py_tests/phase0/block_processing/test_voluntary_exit.py +++ b/py_tests/phase0/block_processing/test_voluntary_exit.py @@ -8,7 +8,7 @@ from eth2.phase0.spec import ( get_current_epoch, process_voluntary_exit, ) -from ..helpers import ( +from phase0.helpers import ( build_voluntary_exit, pubkey_to_privkey, ) diff --git a/py_tests/requirements.txt b/py_tests/requirements.txt index d18b29127..27b3f22d8 100644 --- a/py_tests/requirements.txt +++ b/py_tests/requirements.txt @@ -4,4 +4,4 @@ oyaml==0.7 pycryptodome==3.7.3 py_ecc>=1.6.0 pytest>=3.6,<3.7 -../pyspec +../test_libs/pyspec diff --git a/test_generators/README.md b/test_generators/README.md index 61dc96063..155059fe0 100644 --- a/test_generators/README.md +++ b/test_generators/README.md @@ -46,9 +46,9 @@ Simply open up the generator (not all at once) of choice in your favorite IDE/ed ```bash # Create a virtual environment (any venv/.venv/.venvs is git-ignored) -python3 -m venv .venv +python3 -m venv venv # Activate the venv, this is where dependencies are installed for the generator -. .venv/bin/activate +. venv/bin/activate ``` Now that you have a virtual environment, write your generator. @@ -57,8 +57,13 @@ It's recommended to extend the base-generator. Create a `requirements.txt` in the root of your generator directory: ``` eth-utils==1.4.1 -../test_libs/gen_helpers +../../test_libs/gen_helpers ``` +And optionally, to include pyspec, add: +``` +../../test_libs/pyspec +``` +Note: make sure to run `make pyspec` from the root of the specs repository, to build the pyspec requirement. Install all the necessary requirements (re-run when you add more): ```bash diff --git a/py_tests/__init__.py b/test_libs/pyspec/eth2/__init__.py similarity index 100% rename from py_tests/__init__.py rename to test_libs/pyspec/eth2/__init__.py diff --git a/test_libs/pyspec/setup.py b/test_libs/pyspec/setup.py index 6d57e5916..b04847d37 100644 --- a/test_libs/pyspec/setup.py +++ b/test_libs/pyspec/setup.py @@ -1,9 +1,8 @@ -from distutils.core import setup +from setuptools import setup, find_packages setup( name='pyspec', - version='1.0', - packages=['eth2.debug', 'eth2.phase0', 'eth2.utils'], + packages=find_packages(), install_requires=[ "eth-utils>=1.3.0,<2", "eth-typing>=2.1.0,<3.0.0",