From 7f8ca065c0e7394d2f3c047d2e6f4f26292fcab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Tue, 9 Mar 2021 17:32:47 -0500 Subject: [PATCH 1/5] prepend 'comp_' in jl component file names so that the component file name does not conflict with the jl module filename in case-insensitive filesystems when --prefix=''. --- dash/development/_jl_components_generation.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dash/development/_jl_components_generation.py b/dash/development/_jl_components_generation.py index 750a0dcf89..16ec77d11a 100644 --- a/dash/development/_jl_components_generation.py +++ b/dash/development/_jl_components_generation.py @@ -91,7 +91,7 @@ "DashBase": "0.1", } -jl_component_include_string = 'include("{name}.jl")' +jl_component_include_string = 'include("{filename}.jl")' jl_resource_tuple_string = """DashBase.Resource( relative_package_path = {relative_package_path}, @@ -340,6 +340,10 @@ def format_fn_name(prefix, name): return name.lower() +def format_file_name(prefix, name): + return "comp_{}".format(format_fn_name(prefix, name)) + + def generate_metadata_strings(resources, metatype): def nothing_or_string(v): return '"{}"'.format(v) if v else "nothing" @@ -391,7 +395,7 @@ def generate_package_file(project_shortname, components, pkg_data, prefix): component_includes="\n".join( [ jl_component_include_string.format( - name=format_fn_name(prefix, comp_name) + filename=format_file_name(prefix, comp_name) ) for comp_name in components ] @@ -498,7 +502,7 @@ def generate_struct_file(name, props, description, project_shortname, prefix): name, props, description, project_shortname, prefix ) - file_name = format_fn_name(prefix, name) + ".jl" + file_name = format_file_name(prefix, name) + ".jl" file_path = os.path.join("src", file_name) with open(file_path, "w") as f: From 6e36c9adf53e1d1ab3a4159e4cd894e72018e85d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 1 Apr 2021 10:44:23 -0400 Subject: [PATCH 2/5] Revert "prepend 'comp_' in jl component file names" This reverts commit 7f8ca065c0e7394d2f3c047d2e6f4f26292fcab6. --- dash/development/_jl_components_generation.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dash/development/_jl_components_generation.py b/dash/development/_jl_components_generation.py index 16ec77d11a..750a0dcf89 100644 --- a/dash/development/_jl_components_generation.py +++ b/dash/development/_jl_components_generation.py @@ -91,7 +91,7 @@ "DashBase": "0.1", } -jl_component_include_string = 'include("{filename}.jl")' +jl_component_include_string = 'include("{name}.jl")' jl_resource_tuple_string = """DashBase.Resource( relative_package_path = {relative_package_path}, @@ -340,10 +340,6 @@ def format_fn_name(prefix, name): return name.lower() -def format_file_name(prefix, name): - return "comp_{}".format(format_fn_name(prefix, name)) - - def generate_metadata_strings(resources, metatype): def nothing_or_string(v): return '"{}"'.format(v) if v else "nothing" @@ -395,7 +391,7 @@ def generate_package_file(project_shortname, components, pkg_data, prefix): component_includes="\n".join( [ jl_component_include_string.format( - filename=format_file_name(prefix, comp_name) + name=format_fn_name(prefix, comp_name) ) for comp_name in components ] @@ -502,7 +498,7 @@ def generate_struct_file(name, props, description, project_shortname, prefix): name, props, description, project_shortname, prefix ) - file_name = format_file_name(prefix, name) + ".jl" + file_name = format_fn_name(prefix, name) + ".jl" file_path = os.path.join("src", file_name) with open(file_path, "w") as f: From 90dfd9f069aa8d9171b0aafda1dccc1e193cb3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 1 Apr 2021 12:35:53 -0400 Subject: [PATCH 3/5] put generated julia component files in `src/jl` - so that their paths never conflict with the julia module file in case-insensitive filesystems - this also makes the src directory less noisy (especially for devs that do not care about julia) --- dash/development/_jl_components_generation.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dash/development/_jl_components_generation.py b/dash/development/_jl_components_generation.py index 750a0dcf89..d224c75079 100644 --- a/dash/development/_jl_components_generation.py +++ b/dash/development/_jl_components_generation.py @@ -91,7 +91,7 @@ "DashBase": "0.1", } -jl_component_include_string = 'include("{name}.jl")' +jl_component_include_string = 'include("jl/{name}.jl")' jl_resource_tuple_string = """DashBase.Resource( relative_package_path = {relative_package_path}, @@ -500,7 +500,11 @@ def generate_struct_file(name, props, description, project_shortname, prefix): file_name = format_fn_name(prefix, name) + ".jl" - file_path = os.path.join("src", file_name) + # put component files in src/jl subdir + if not os.path.exists("src/jl"): + os.makedirs("src/jl") + + file_path = os.path.join("src", "jl", file_name) with open(file_path, "w") as f: f.write(import_string) f.write(class_string) From 169bc8426f782dcbe6222f8f8222504ead51fc3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 5 May 2021 15:18:05 -0400 Subject: [PATCH 4/5] rm redundant `os.makedirs("src")` block in `generate_module` ... and adapt comment in `generate_struct_file` accordingly. --- dash/development/_jl_components_generation.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/dash/development/_jl_components_generation.py b/dash/development/_jl_components_generation.py index d224c75079..212cfcbfd6 100644 --- a/dash/development/_jl_components_generation.py +++ b/dash/development/_jl_components_generation.py @@ -500,7 +500,9 @@ def generate_struct_file(name, props, description, project_shortname, prefix): file_name = format_fn_name(prefix, name) + ".jl" - # put component files in src/jl subdir + # put component files in src/jl subdir, + # this also creates the Julia source directory for the package + # if it is missing if not os.path.exists("src/jl"): os.makedirs("src/jl") @@ -516,12 +518,7 @@ def generate_struct_file(name, props, description, project_shortname, prefix): def generate_module( project_shortname, components, metadata, pkg_data, prefix, **kwargs ): - # the Julia source directory for the package won't exist on first call - # create the Julia directory if it is missing - if not os.path.exists("src"): - os.makedirs("src") - - # now copy over all JS dependencies from the (Python) components dir + # copy over all JS dependencies from the (Python) components dir # the inst/lib directory for the package won't exist on first call # create this directory if it is missing if os.path.exists("deps"): From 741df375f4f203f529f44942cda8285663b71e26 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Tue, 8 Jun 2021 10:44:14 -0400 Subject: [PATCH 5/5] Update changelog for src/jl build change --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd4becf68..d7bf82c57a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## Dash and Dash Renderer ### Changed - [#1611](https://github.com/plotly/dash/pull/1611) Package dash-renderer artifacts and dependencies with Dash, and source renderer resources from within Dash. +- [#1567](https://github.com/plotly/dash/pull/1567) Julia component generator puts components into `src/jl` - fixes an issue on case-insensitive filesystems when the component name and module name match (modulo case) and no prefix is used. Also reduces JS/Julia clutter in the overloaded `src` directory. ### Fixed - [#1664](https://github.com/plotly/dash/pull/1664) Fix [#1649](https://github.com/plotly/dash/issues/1649), makes the devtools readable with a dark theme.