Skip to content

Commit ae65843

Browse files
feat(flow-python): add version (#56)
Co-authored-by: MegEngine <[email protected]>
1 parent c8a46d3 commit ae65843

File tree

13 files changed

+39
-23
lines changed

13 files changed

+39
-23
lines changed

flow-debugger/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flow-debugger"
3-
version = "0.1.0"
3+
version = "0.3.5"
44
edition = "2018"
55
authors = ["megvii"]
66

flow-derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flow-derive"
3-
version = "0.3.2"
3+
version = "0.3.5"
44
authors = ["megvii"]
55
edition = "2018"
66

flow-message/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flow-message"
3-
version = "0.3.2"
3+
version = "0.3.5"
44
edition = "2018"
55

66
[features]

flow-plugins/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flow-plugins"
3-
version = "0.3.2"
3+
version = "0.3.5"
44
authors = ["megvii"]
55
edition = "2018"
66

flow-python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flow-python"
3-
version = "0.3.2"
3+
version = "0.3.5"
44
authors = ["megvii"]
55
edition = "2018"
66

flow-python/examples/basis_function/nest/nest.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ connections = [
2222

2323
[[graphs.nodes]]
2424
name = "n1"
25-
ty = "noop"
25+
ty = "Noop"
2626

2727
[[graphs.nodes]]
2828
name = "n2"
2929
ty = "noop"
3030

3131
[[graphs.nodes]]
3232
name = "n3"
33-
ty = "noop"
33+
ty = "Noop"
3434

3535
[[graphs.nodes]]
3636
name = "n4"
3737
ty = "noop"
3838

3939
[[graphs.nodes]]
4040
name = "n5"
41-
ty = "noop"
41+
ty = "Noop"
4242

4343
[[graphs]]
4444
name = "nest"

flow-python/examples/basis_function/nest/op.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
@map_def(exclusive=True)
66
def noop(x):
7-
print('send', x)
7+
# print('send', x)
88
return x
99

1010

1111
@source_def()
1212
def gen(context=None):
1313
for i in range(context.n):
14-
print('first', i)
14+
# print('first', i)
1515
yield i
1616

1717

1818
@sink_def()
1919
def printer(x):
20-
print('last', x)
20+
pass
21+
# print('last', x)

flow-python/megflow/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111

1212
from .registry import register, collect, res_register
1313
from .megflow import *
14+
15+
__version__ = version()

flow-python/megflow/command_line.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,19 @@ def megflow_run():
2323
sys.exit(1)
2424

2525
import argparse
26-
from megflow import Graph
26+
import megflow
2727

2828
parser = argparse.ArgumentParser(prog='megflow_run', description='run a pipeline with plugins.')
2929
parser.add_argument('--dump', help='the path to dump graph', action='store_true')
3030
parser.add_argument('-p', '--plugin', required=True, type=str, help='plugin path')
3131
parser.add_argument('-m', '--module', type=str, help='module path')
3232
parser.add_argument('-c', '--config', type=str, help='config path')
3333
parser.add_argument('--dynamic', type=str, help='dynamic config path')
34+
parser.add_argument('--version', action='version', version='%(prog)s {version}'.format(version=megflow.__version__))
3435

3536
args = parser.parse_args()
3637

37-
Graph(
38+
megflow.Graph(
3839
dump=args.dump,
3940
plugin_path=args.plugin,
4041
module_path=args.module,

flow-python/setup.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@
3030
elif system == 'windows':
3131
dyn_ext = 'dll'
3232

33-
devel_version = os.environ.get("DEVEL_VERSION")
3433
debug = os.environ.get("DEBUG")
3534
target_dir = os.environ.get("CARGO_TARGET_DIR")
3635

37-
if not devel_version:
38-
devel_version = "0.3.2" # fall back
3936
if not debug:
4037
debug = False
4138
if not target_dir:
@@ -120,14 +117,22 @@ def run(self):
120117
pattern = re.compile(f'.*?{dyn_ext}\.[0-9]*')
121118
ext_modules.append(CopyExtension(pattern, f"{ffmpeg_dir}/lib/*.{dyn_ext}.*", "lib/"))
122119

120+
current_dir = os.getcwd()
121+
with open(current_dir+'/Cargo.toml') as f:
122+
pattern = re.compile(r'\d+\.(?:\d+\.)*\d+')
123+
for line in f:
124+
if line.startswith('version'):
125+
version = re.search(pattern, line).group()
126+
break
127+
123128
setup(
124129
options={
125130
'bdist_wheel': {
126131
'py_limited_api': "cp36",
127132
}
128133
},
129134
name="megflow",
130-
version=devel_version,
135+
version=version,
131136
packages=["megflow"],
132137
author="Megvii IPU-SDK Team",
133138
author_email="[email protected]",

0 commit comments

Comments
 (0)