@@ -23,12 +23,13 @@ def list2cmdline(cmd_list):
23
23
24
24
25
25
# the name of the project
26
- name = "idom"
26
+ NAME = "idom"
27
27
28
28
# basic paths used to gather files
29
- root_dir = Path (__file__ ).parent
30
- src_dir = root_dir / "src"
31
- package_dir = src_dir / name
29
+ ROOT_DIR = Path (__file__ ).parent
30
+ SRC_DIR = ROOT_DIR / "src"
31
+ PKG_DIR = SRC_DIR / NAME
32
+ JS_DIR = SRC_DIR / "client"
32
33
33
34
34
35
# -----------------------------------------------------------------------------
@@ -37,9 +38,9 @@ def list2cmdline(cmd_list):
37
38
38
39
39
40
package = {
40
- "name" : name ,
41
+ "name" : NAME ,
41
42
"python_requires" : ">=3.7" ,
42
- "packages" : find_packages (str (src_dir )),
43
+ "packages" : find_packages (str (SRC_DIR )),
43
44
"package_dir" : {"" : "src" },
44
45
"description" : "It's React, but in Python" ,
45
46
"author" : "Ryan Morshead" ,
@@ -70,7 +71,7 @@ def list2cmdline(cmd_list):
70
71
# Library Version
71
72
# -----------------------------------------------------------------------------
72
73
73
- pkg_root_init_file = package_dir / "__init__.py"
74
+ pkg_root_init_file = PKG_DIR / "__init__.py"
74
75
for line in pkg_root_init_file .read_text ().split ("\n " ):
75
76
if line .startswith ('__version__ = "' ) and line .endswith ('" # DO NOT MODIFY' ):
76
77
package ["version" ] = (
@@ -96,15 +97,15 @@ def list2cmdline(cmd_list):
96
97
97
98
98
99
requirements = []
99
- with (root_dir / "requirements" / "pkg-deps.txt" ).open () as f :
100
+ with (ROOT_DIR / "requirements" / "pkg-deps.txt" ).open () as f :
100
101
for line in map (str .strip , f ):
101
102
if not line .startswith ("#" ):
102
103
requirements .append (line )
103
104
package ["install_requires" ] = requirements
104
105
105
106
_current_extras = []
106
107
extra_requirements = {"all" : []} # type: ignore
107
- extra_requirements_path = root_dir / "requirements" / "pkg-extras.txt"
108
+ extra_requirements_path = ROOT_DIR / "requirements" / "pkg-extras.txt"
108
109
with extra_requirements_path .open () as f :
109
110
for line in map (str .strip , f ):
110
111
if line .startswith ("#" ) and line [1 :].strip ().startswith ("extra=" ):
@@ -129,7 +130,7 @@ def list2cmdline(cmd_list):
129
130
# -----------------------------------------------------------------------------
130
131
131
132
132
- with (root_dir / "README.md" ).open () as f :
133
+ with (ROOT_DIR / "README.md" ).open () as f :
133
134
long_description = f .read ()
134
135
135
136
package ["long_description" ] = long_description
@@ -146,14 +147,13 @@ class Command(cls):
146
147
def run (self ):
147
148
log .info ("Installing Javascript..." )
148
149
try :
149
- js_dir = str (src_dir / "client" )
150
150
npm = shutil .which ("npm" ) # this is required on windows
151
151
if npm is None :
152
152
raise RuntimeError ("NPM is not installed." )
153
153
for args in (f"{ npm } install" , f"{ npm } run build" ):
154
154
args_list = args .split ()
155
155
log .info (f"> { list2cmdline (args_list )} " )
156
- subprocess .run (args_list , cwd = js_dir , check = True )
156
+ subprocess .run (args_list , cwd = str ( JS_DIR ) , check = True )
157
157
except Exception :
158
158
log .error ("Failed to install Javascript" )
159
159
log .error (traceback .format_exc ())
0 commit comments