diff --git a/.flake8 b/.flake8 index 6deafc261..20a012392 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,3 @@ [flake8] max-line-length = 120 +exclude = ./lib/pybind11 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6063b8afa..55ed86618 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,15 +28,26 @@ jobs: - name: Install cibuildwheel run: | python -m pip install --upgrade pip + pip install wheel pip install cibuildwheel==1.3.0 + - name: Lint source with flake8 + run: | + pip install flake8 + flake8 setup.py tests + + - name: Lint source with mypy + run: | + pip install mypy + mypy --config-file mypi.ini setup.py tests + - name: Build source distribution with MacOS if: startsWith(matrix.os, 'mac') run: | pip install pep517 python -m pep517.build --source --out-dir dist . - - name: Build wheel + - name: Build wheel and test run: | python -m cibuildwheel --output-dir dist env: @@ -75,7 +86,7 @@ jobs: TWINE_NON_INTERACTIVE: 1 TWINE_PASSWORD: ${{ secrets.test_pypi_password }} run: twine upload --non-interactive --skip-existing --verbose 'dist/*' - + - name: Publish distribution to PyPI if: startsWith(github.event.ref, 'refs/tags') env: diff --git a/.gitignore b/.gitignore index 65f3afeea..017c2c7e6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ Makefile build .pytest_cache **/*.egg-info - +.mypy_cache +*.whl diff --git a/README.md b/README.md index d6b92de9f..cdf5b6f3d 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,13 @@ [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/Chia-Network/chiapos.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Chia-Network/chiapos/context:cpp) # Chia Proof of Space -A prototype of Chia's proof of space, written in C++. Includes a plotter, prover, and verifier. -Only runs on 64 bit architectures with AES-NI support. Read the [Proof of Space document](https://www.chia.net/assets/proof_of_space.pdf) to learn about what proof of space is and how it works. +Chia's proof of space, written in C++. Includes a plotter, prover, and verifier. +Only runs on 64 bit architectures with AES-NI support. Read the +[Proof of Space document](https://www.chia.net/assets/proof_of_space.pdf) to +learn about what proof of space is and how it works. + +Expect significant changes by June 30, 2020 that will break the plot file +format, move to chacha8, and otherwise improve plotting performance. ## C++ Usage Instructions @@ -33,7 +38,7 @@ cmake --build . -- -j 6 ```bash ./ProofOfSpace -k 25 -f "plot.dat" -m "0x1234" generate -./ProofOfSpace -k 25 -f "plot.dat" -m "0x4567" -t TEMPDIR -2 SECOND_TEMPDIR generate +./ProofOfSpace -k 25 -f "final-plot.dat" -m "0x4567" -t TMPDIR -2 SECOND_TMPDIR generate ./ProofOfSpace -f "plot.dat" prove <32 byte hex challenge> ./ProofOfSpace -k 25 verify <32 byte hex challenge> ./ProofOfSpace -f "plot.dat" check @@ -48,7 +53,8 @@ time ./ProofOfSpace -k 25 generate ### Hellman Attacks usage -There is an experimental implementation which implements some of the Hellman Attacks that can provide significant space savings for the final file. +There is an experimental implementation which implements some of the Hellman +Attacks that can provide significant space savings for the final file. ```bash @@ -72,8 +78,8 @@ pip3 install . ### Run python tests -Testings uses pytest. Type checking uses pyright, and linting uses flake8 and -mypy. +Testings uses pytest. Type checking uses pyright (currenlty disabled), and +linting uses flake8 and mypy. ```bash py.test ./tests -s -v diff --git a/mypi.ini b/mypi.ini new file mode 100644 index 000000000..976ba0294 --- /dev/null +++ b/mypi.ini @@ -0,0 +1,2 @@ +[mypy] +ignore_missing_imports = True diff --git a/setup.py b/setup.py index 377a0a30b..f13be2271 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,7 @@ from setuptools import setup, Extension from setuptools.command.build_ext import build_ext from distutils.version import LooseVersion +import setuptools class CMakeExtension(Extension): @@ -21,9 +22,9 @@ def run(self): try: out = subprocess.check_output(['cmake', '--version']) except OSError: - raise RuntimeError("CMake must be installed to build" + - " the following extensions: " + - ", ".join(e.name for e in self.extensions)) + raise RuntimeError("CMake must be installed to build" + + " the following extensions: " + + ", ".join(e.name for e in self.extensions)) if platform.system() == "Windows": cmake_version = LooseVersion( @@ -63,6 +64,7 @@ def build_extension(self, ext): subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp) + class get_pybind_include(object): """Helper class to determine the pybind11 include path @@ -126,7 +128,8 @@ def cpp_flag(compiler): flags = ['-std=c++17', '-std=c++14', '-std=c++11'] for flag in flags: - if has_flag(compiler, flag): return flag + if has_flag(compiler, flag): + return flag raise RuntimeError('Unsupported compiler -- at least C++11 support ' 'is needed!') @@ -135,12 +138,12 @@ def cpp_flag(compiler): class BuildExt(build_ext): """A custom build extension for adding compiler-specific options.""" c_opts = { - 'msvc': ['/EHsc','/std:c++17','/O2'], - 'unix': [], + 'msvc': ['/EHsc', '/std:c++17', '/O2'], + 'unix': [""], } l_opts = { - 'msvc': [], - 'unix': [], + 'msvc': [""], + 'unix': [""], } if sys.platform == 'darwin': @@ -164,9 +167,8 @@ def build_extensions(self): ext.extra_link_args = link_opts build_ext.build_extensions(self) -import platform -if platform.system()=="Windows": +if platform.system() == "Windows": setup( name='chiapos', author='Mariano Sorgente',