Skip to content

Commit

Permalink
feat: publish cfbc 0.1.6 to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
doitian committed Mar 27, 2019
1 parent a5424e1 commit 0cdab15
Show file tree
Hide file tree
Showing 45 changed files with 118 additions and 15 deletions.
3 changes: 3 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,3 @@
include LICENSE README.md
global-exclude *.py[co]
graft cfb/templates
7 changes: 7 additions & 0 deletions Makefile
Expand Up @@ -24,6 +24,12 @@ gen-clean:
rm -f ${BFBS} ${JSON} ${FLATC_RS} ${BUILDER}
gen-force: gen-clean gen

publish-python:
rm -rf dist
${PIPENV_RUN} python setup.py sdist bdist_wheel
twine --version || ${PIPENV_RUN} pip install twine
twine upload dist/*

doc:
cargo doc

Expand Down Expand Up @@ -73,3 +79,4 @@ ci-python: test-python ci-gen-clean ci-gen
.PHONY: doc doc-clean doc-publish
.PHONY: fmt clippy
.PHONY: ci ci-rust ci-python ci-gen ci-gen-clean
.PHONY: publish-python
3 changes: 1 addition & 2 deletions Pipfile
Expand Up @@ -4,8 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
cfbc = {editable = true,path = "."}
cfbc = { editable = true, path = "." }

[dev-packages]
flatbuffers = "*"
mock = "==1.0.1"
32 changes: 30 additions & 2 deletions README.md
@@ -1,6 +1,34 @@
# CFB Encoding

[![Build Status](https://travis-ci.com/nervosnetwork/cfb.svg?branch=master)](https://travis-ci.com/nervosnetwork/cfb)
---
## [![Build Status](https://travis-ci.com/nervosnetwork/cfb.svg?branch=master)](https://travis-ci.com/nervosnetwork/cfb)

CFB (Canonical FlatBuffers) is a restricted variant of FlatBuffers for producing unequivocal transfer syntax.

## Usage

Install the code geneartor as commane line utility:

```
pip install cfbc
```

First generate bfbs file from fbs:

```
flatc -b --schema example.fbs
```

Then generate rust files from bfbs:

```
cfbc example.bfbs
```

### Use Verifier with flatbuffers rust

Add the generated `<name>_generated_verifier.rs` to the project. This file
depends on the crate `flatbuffers`.

The file defines a function `get_root`, which is intended to replace the
function with the same name in `flatbuffers`. This function will verify the
buffer, and returns a `Result` to indicate whether the buffer is valid.
22 changes: 17 additions & 5 deletions cfb/cli.py
Expand Up @@ -2,21 +2,33 @@
Usage:
cfbc [-o <dir>] <bfbs>
cfbc -h | --help
cfbc --version
Options:
-o <dir> output directory (default: the same directory of <bfbs>)
<bfbs> bfbs file which is generated using `flatc -b --schema <fbs>`.
-o <dir> Save all generated files in <dir>, instead of the directory containing <bfbs>.
<bfbs> Load schema from <bfbs> which is generated by `flatc -b --schema <fbs>`.
-h --help Show this screen.
--version Show version.
"""
import os
from docopt import docopt
from cfb.generator import Generator
from cfb.version import VERSION


def parse_arguments(argv=None):
return docopt(__doc__, argv)


def main():
arguments = parse_arguments()
def generate(arguments):
g = Generator(arguments['<bfbs>'])
g.generate(arguments['-o'])


def main():
arguments = parse_arguments()
if arguments['--version']:
print(VERSION)
else:
generate(arguments)
3 changes: 3 additions & 0 deletions cfb/struct.py
@@ -1,3 +1,6 @@
# foo


class StructPadding(object):
def __init__(self, index, ty):
self.index = index
Expand Down
1 change: 1 addition & 0 deletions cfb/templates/builder.rs.jinja
@@ -1 +1,2 @@
//! This file is auto-generated by cfbc.
{% set mod = cfb.root %}{% include "_builder_mod.rs.jinja" %}
1 change: 1 addition & 0 deletions cfb/templates/legacy_verifier.rs.jinja
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::{{ cfb.basename }}_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions cfb/version.py
@@ -0,0 +1 @@
VERSION = '0.1.6'
25 changes: 19 additions & 6 deletions setup.py
@@ -1,22 +1,35 @@
import os
import io
from setuptools import setup
from setuptools import setup, find_packages

HERE = os.path.dirname(os.path.realpath(__file__))
README = os.path.join(HERE, "README.md")

README = os.path.join(HERE, 'README.md')
with io.open(README, encoding='utf-8') as f:
long_description = f.read()

VERSION = os.path.join(HERE, 'cfb', 'version.py')
with io.open(VERSION, encoding='utf-8') as f:
package = {}
exec(f.read(), package)
version = package['VERSION']

setup(name='cfbc',
version='0.1',
version=version,
description='CFB code generator',
long_description=long_description,
long_description_content_type='text/markdown',
url='http://github.com/nervosnetwork/cfb',
author='Nervos Core Dev',
author_email='dev@nervos.org',
license='MIT',
packages=['cfb'],
install_requires=['docopt', 'Jinja2'],
packages=find_packages(),
install_requires=['docopt', 'Jinja2', 'flatbuffers'],
scripts=['bin/cfbc'],
zip_safe=False)
zip_safe=False,
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Environment :: Console',
],
include_package_data=True,
)
1 change: 1 addition & 0 deletions src/lib.rs
@@ -1,3 +1,4 @@
//! asdfo
pub mod alignment;
pub mod builder;
pub mod scalar;
Expand Down
1 change: 1 addition & 0 deletions tests/common/ckb_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod ckb {
pub mod protocol {
#![allow(unused_imports, clippy::large_enum_variant)]
Expand Down
1 change: 1 addition & 0 deletions tests/common/ckb_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::ckb_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/data_alignment_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
#![allow(unused_imports, clippy::large_enum_variant)]

use cfb::builder::{
Expand Down
1 change: 1 addition & 0 deletions tests/common/data_alignment_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::data_alignment_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/data_order_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
#![allow(unused_imports, clippy::large_enum_variant)]

use cfb::builder::{
Expand Down
1 change: 1 addition & 0 deletions tests/common/data_order_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::data_order_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/enum_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/enum_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::enum_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/enum_vector_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/enum_vector_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::enum_vector_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/nested_buffer_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
#![allow(unused_imports, clippy::large_enum_variant)]

use cfb::builder::{
Expand Down
1 change: 1 addition & 0 deletions tests/common/nested_buffer_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::nested_buffer_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/scalar_vector_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/scalar_vector_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::scalar_vector_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/scalars_with_different_size_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::scalars_with_different_size_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/scalars_with_same_size_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/scalars_with_same_size_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::scalars_with_same_size_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/string_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/string_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::string_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/string_vector_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/string_vector_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::string_vector_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/struct_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/struct_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::struct_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/struct_vector_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/struct_vector_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::struct_vector_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/table_field_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/table_field_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::table_field_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/table_fields_order_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
#![allow(unused_imports, clippy::large_enum_variant)]

use cfb::builder::{
Expand Down
1 change: 1 addition & 0 deletions tests/common/table_fields_order_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::table_fields_order_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/table_vector_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/table_vector_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::table_vector_generated as reader;
use flatbuffers;
use std::error;
Expand Down
1 change: 1 addition & 0 deletions tests/common/union_builder.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
pub mod example {
#![allow(unused_imports, clippy::large_enum_variant)]

Expand Down
1 change: 1 addition & 0 deletions tests/common/union_generated_verifier.rs
@@ -1,3 +1,4 @@
//! This file is auto-generated by cfbc.
use super::union_generated as reader;
use flatbuffers;
use std::error;
Expand Down

0 comments on commit 0cdab15

Please sign in to comment.