contract_wrappers.py: fix ./setup.py clean

This commit is contained in:
F. Eugene Aumson 2019-08-08 16:20:24 -04:00
parent fc9c6c5434
commit 50f69f734f
No known key found for this signature in database
GPG Key ID: 23E6737B1374A24A

View File

@ -18,15 +18,7 @@ from setuptools.command.test import test as TestCommand
BLACK_COMMAND = "black --line-length 79 "
class PreInstallCommand(distutils.command.build_py.build_py):
"""Custom setuptools command class for pulling in generated code."""
description = "Pull in code generated by TypeScript"
def run(self):
"""Copy files from TS build area to local src, & `black` them."""
pkgdir = path.dirname(path.realpath(argv[0]))
contracts = [
CONTRACTS_TO_BE_WRAPPED = [
"asset_proxy_owner",
"coordinator",
"coordinator_registry",
@ -47,8 +39,18 @@ class PreInstallCommand(distutils.command.build_py.build_py):
"order_validator",
"weth9",
"zrx_token",
]
for contract in contracts:
]
class PreInstallCommand(distutils.command.build_py.build_py):
"""Custom setuptools command class for pulling in generated code."""
description = "Pull in code generated by TypeScript"
def run(self):
"""Copy files from TS build area to local src, & `black` them."""
pkgdir = path.dirname(path.realpath(argv[0]))
for contract in CONTRACTS_TO_BE_WRAPPED:
copy(
path.join(
pkgdir,
@ -84,7 +86,7 @@ class PreInstallCommand(distutils.command.build_py.build_py):
black_command = BLACK_COMMAND + " ".join(
[
f"src/zero_ex/contract_wrappers/{contract}/__init__.py"
for contract in contracts
for contract in CONTRACTS_TO_BE_WRAPPED
]
)
print(f"Running command `{black_command}`...")
@ -158,8 +160,11 @@ class CleanCommandExtension(clean):
rmtree(".pytest_cache", ignore_errors=True)
rmtree("src/0x_contract_wrappers.egg-info", ignore_errors=True)
# generated files:
remove("src/zero_ex/contract_wrappers/exchange/__init__.py")
remove("src/zero_ex/contract_wrappers/erc20_token/__init__.py")
for contract in CONTRACTS_TO_BE_WRAPPED:
try:
remove(f"src/zero_ex/contract_wrappers/{contract}/__init__.py")
except FileNotFoundError:
pass
class TestPublishCommand(distutils.command.build_py.build_py):