When starting a project in Python, I want to save some environment variables in a file called environment_variables
and source this file in the bashrc.
The file looks something like this:
username=$(whoami)
# project root path
export PROJECT_DIR='/home/'$username'/nuclei_segmentation/'
# project data path
export DATA_DIR=$PROJECT_DIR"data/"
# location of models
export MODEL_DIR=$PROJECT_DIR"models/"
# project output data
export OUTPUT_DIR=$PROJECT_DIR"output/"
I would like to change the PROJECT_DIR
path so it is platform/name independent. So this environment_variables
file will always be in the root directory of the project and I want to set PROJECT_DIR
to always be the location of the environment_variables
file.
I thought I could do this with PWD
but when called from bashrc this creates an error, I also thought of a solution using find to search for the file from the root directory but this seems to complex and think there must be a better way?