Closed noelmcloughlin closed 5 months ago
I'd agree with that in this PR, good suggestion. There is some open tooling which looks for a '.env' file, and auto loads environment vars if found. Chezmoi is one example, another called 'dotenv' I think. So it may be an official standard😊
There may also be value in using a standardized interface called '.config/' directory but I need to think about that. Its official standard for home directories, but I'm not 100% sure it's a standard for git repos.
According to google search, .env may be best. There is also a .dotenv competing standard maybe, but I'd vote for .env
@pkalita-lbl Looks like .env
may not be best choice, see https://configu.com/blog/dotenv-managing-environment-variables-in-node-python-php-and-more/#NoCommit
Maybe .env.public
is semantic alternative?
https://github.com/prisma/prisma/issues/15681#issuecomment-1617643202
@pkalita-lbl we can go ahead with .env.public
for now. PR is ready now.
Just a note, when using a .env
-style file in combination with GNU Make include
, it must follow GNU Make syntax. If that file is meant to be sourced by sh(1)
, then it must use only a common subset of that syntax (but that's not being done here).
Specifically, GNU Make retains any quotes as literal quotes whereas sh(1)
does its own quoting. So any further use of these variables with functions (such as $(dir ...)
) will be impacted such as with the SOURCE_SCHEMA_DIR
variable which will start with a "
character and end with a /
. I have a fix for this as follows:
diff --git a/Makefile b/Makefile
index 26adc0a..cf84f7e 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,10 @@ SHELL := bash
.SUFFIXES:
.SECONDARY:
+# define temporary variable for $(call ...)
+1 :=
+unquote = $(patsubst "%,%,$(patsubst %",%,$(1)))
+
# environment variables
.EXPORT_ALL_VARIABLES:
ifdef LINKML_ENVIRONMENT_FILENAME
@@ -16,8 +20,8 @@ endif
RUN = poetry run
SCHEMA_NAME = $(LINKML_SCHEMA_NAME)
-SOURCE_SCHEMA_PATH = $(LINKML_SCHEMA_SOURCE_PATH)
-SOURCE_SCHEMA_DIR = $(dir $(SOURCE_SCHEMA_PATH))
+SOURCE_SCHEMA_PATH = $(call unquote,$(LINKML_SCHEMA_SOURCE_PATH))
+SOURCE_SCHEMA_DIR = $(patsubst %/,%,$(dir $(SOURCE_SCHEMA_PATH)))
SRC = src
DEST = project
PYMODEL = $(SRC)/$(SCHEMA_NAME)/datamodel
I can make a PR for this.
The other solution is not use quotes on some of the variables (LINKML_SCHEMA_SOURCE_PATH
, LINKML_SCHEMA_GOOGLE_SHEET_TABS
), but that might confuse users as some variables don't follow the same pattern as others. Though this is already the case with the LINKML_GENERATORS_CONFIG_YAML
variable and I suppose the other *_ARGS
variables.
This PR refactors how schema definition is passed to makefile.
about.yaml
to.env.public
about.yaml
andutils/ directory
as not needed anymoreMakefile
to use environment variables from `.env.public.check-config
as part ofmake setup
to validateinclude .env.public
workedSee https://github.com/linkml/linkml-project-cookiecutter/issues/57#issuecomment-1919916264