-
Notifications
You must be signed in to change notification settings - Fork 71
/
setup.py
65 lines (55 loc) · 1.72 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import subprocess
from distutils.cmd import Command
from setuptools import setup
from setuptools.command.build_py import build_py as _build_py
class TrainModel(Command):
description = "Training the model before building the package"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
PYTHONPATH = os.environ.get("PYTHONPATH", "")
subprocess.run(
[
"parserator",
"train",
"name_data/labeled/person_labeled.xml,name_data/labeled/company_labeled.xml",
"probablepeople",
"--modelfile=generic",
],
env=dict(os.environ, PYTHONPATH=f".{os.pathsep}{PYTHONPATH}"),
)
subprocess.run(
[
"parserator",
"train",
"name_data/labeled/person_labeled.xml",
"probablepeople",
"--modelfile=person",
],
env=dict(os.environ, PYTHONPATH=f".{os.pathsep}{PYTHONPATH}"),
)
subprocess.run(
[
"parserator",
"train",
"name_data/labeled/company_labeled.xml",
"probablepeople",
"--modelfile=company",
],
env=dict(os.environ, PYTHONPATH=f".{os.pathsep}{PYTHONPATH}"),
)
class build_py(_build_py):
def run(self):
self.run_command("train_model") # Run the custom command
super().run()
# Standard setup configuration
setup(
cmdclass={
"build_py": build_py, # Override build_py
"train_model": TrainModel, # Register custom command
},
)