Skip to content

Commit

Permalink
add flake8, mypy - fix revealed issues - note pyright disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmang9 committed May 13, 2020
1 parent 51c068c commit 87a4f71
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 19 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[flake8]
max-line-length = 120
exclude = ./lib/pybind11
15 changes: 13 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Makefile
build
.pytest_cache
**/*.egg-info

.mypy_cache
*.whl
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <hex proof> <32 byte hex challenge>
./ProofOfSpace -f "plot.dat" check <iterations>
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mypi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True
22 changes: 12 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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!')
Expand All @@ -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':
Expand All @@ -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',
Expand Down

0 comments on commit 87a4f71

Please sign in to comment.