-
Notifications
You must be signed in to change notification settings - Fork 303
/
setup.py
39 lines (29 loc) · 936 Bytes
/
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
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", "training/labeled.xml", "usaddress"],
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
},
)