@@ -23,12 +23,13 @@ def list2cmdline(cmd_list):
2323
2424
2525# the name of the project
26- name = "idom"
26+ NAME = "idom"
2727
2828# 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"
3233
3334
3435# -----------------------------------------------------------------------------
@@ -37,9 +38,9 @@ def list2cmdline(cmd_list):
3738
3839
3940package = {
40- "name" : name ,
41+ "name" : NAME ,
4142 "python_requires" : ">=3.7" ,
42- "packages" : find_packages (str (src_dir )),
43+ "packages" : find_packages (str (SRC_DIR )),
4344 "package_dir" : {"" : "src" },
4445 "description" : "It's React, but in Python" ,
4546 "author" : "Ryan Morshead" ,
@@ -70,7 +71,7 @@ def list2cmdline(cmd_list):
7071# Library Version
7172# -----------------------------------------------------------------------------
7273
73- pkg_root_init_file = package_dir / "__init__.py"
74+ pkg_root_init_file = PKG_DIR / "__init__.py"
7475for line in pkg_root_init_file .read_text ().split ("\n " ):
7576 if line .startswith ('__version__ = "' ) and line .endswith ('" # DO NOT MODIFY' ):
7677 package ["version" ] = (
@@ -96,15 +97,15 @@ def list2cmdline(cmd_list):
9697
9798
9899requirements = []
99- with (root_dir / "requirements" / "pkg-deps.txt" ).open () as f :
100+ with (ROOT_DIR / "requirements" / "pkg-deps.txt" ).open () as f :
100101 for line in map (str .strip , f ):
101102 if not line .startswith ("#" ):
102103 requirements .append (line )
103104package ["install_requires" ] = requirements
104105
105106_current_extras = []
106107extra_requirements = {"all" : []} # type: ignore
107- extra_requirements_path = root_dir / "requirements" / "pkg-extras.txt"
108+ extra_requirements_path = ROOT_DIR / "requirements" / "pkg-extras.txt"
108109with extra_requirements_path .open () as f :
109110 for line in map (str .strip , f ):
110111 if line .startswith ("#" ) and line [1 :].strip ().startswith ("extra=" ):
@@ -129,7 +130,7 @@ def list2cmdline(cmd_list):
129130# -----------------------------------------------------------------------------
130131
131132
132- with (root_dir / "README.md" ).open () as f :
133+ with (ROOT_DIR / "README.md" ).open () as f :
133134 long_description = f .read ()
134135
135136package ["long_description" ] = long_description
@@ -146,14 +147,13 @@ class Command(cls):
146147 def run (self ):
147148 log .info ("Installing Javascript..." )
148149 try :
149- js_dir = str (src_dir / "client" )
150150 npm = shutil .which ("npm" ) # this is required on windows
151151 if npm is None :
152152 raise RuntimeError ("NPM is not installed." )
153153 for args in (f"{ npm } install" , f"{ npm } run build" ):
154154 args_list = args .split ()
155155 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 )
157157 except Exception :
158158 log .error ("Failed to install Javascript" )
159159 log .error (traceback .format_exc ())
0 commit comments