Skip to content

Commit

Permalink
fix: build time import errors (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox authored Oct 14, 2023
1 parent 22a5be2 commit da164a6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

python3 starfyre --build --path="test_application"
python3 -m starfyre --build --path="test_application"
2 changes: 2 additions & 0 deletions starfyre/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def main(path, build):
absolute_path = Path(path).resolve()
print(f"Absolute path of the project = {absolute_path}")

sys.path.append(str(absolute_path))

if build:
# Compile and build project
init_file_path = absolute_path / "__init__.py"
Expand Down
4 changes: 3 additions & 1 deletion starfyre/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def remove_empty_lines_from_end(lines):
str(project_dir).split("/")[-1]

# Modify the line to use the resolved import path
line = f"from test_application.build.{file_to_import} import {imported_component}"
line = f"from build.{file_to_import} import {imported_component}"

if line.startswith("<style"):
current_line_type = "css"
Expand Down Expand Up @@ -264,6 +264,8 @@ def compile(entry_file_name):

build_dir = project_dir / "build"
build_dir.mkdir(exist_ok=True)
build_init_file = build_dir / "__init__.py"
build_init_file.touch(exist_ok=True)


fyre_files, directories = get_fyre_files(project_dir)
Expand Down
7 changes: 2 additions & 5 deletions starfyre/package_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ def generate_pages(generated_routes, path):
out_dir = Path(path + "/dist").resolve()
root = Path(out_dir / "..").resolve()
# get the user defined project name
app_name = (str(root).split('/'))[-1]
for route_name in generated_routes:
print(f'route name is = {{route_name}}')
Expand All @@ -55,9 +52,9 @@ def generate_pages(generated_routes, path):
component_key = route_name
if route_name == 'app':
module_name = f"{{Path(app_name)}}.build.pages"
module_name = f"build.pages"
else:
module_name= f"{{Path(app_name)}}.build.pages.{{route_name}}"
module_name= f"build.pages.{{route_name}}"
try:
module = importlib.import_module(module_name)
Expand Down

0 comments on commit da164a6

Please sign in to comment.