-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mac os install script for intel users (#157)
* Add initial script * Add additional source + creation of required db * Make script executable * Fix script errors * Make modifications per request * Apply Ben's change request * Update readme to mention new script
- Loading branch information
Showing
2 changed files
with
100 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ A generic template for Django 4 using htmx based templates, Vite and Alpine.js t | |
|
||
The following items are required in order for this template to work. | ||
|
||
Note: There are scripts to install what you need for mac based operating systems automatically. | ||
|
||
## Dependencies | ||
|
||
* [node](https://nodejs.org/en/download/): | ||
|
@@ -32,55 +34,17 @@ There is also a certain amount of environmental configuration that must be done | |
|
||
### macOS | ||
|
||
Below is a sample configuration for macOS 11 Big Sur, but it should mostly work for any linux, unix, *nix based distribution. | ||
|
||
#### Dependencies | ||
|
||
* It is highly recommended to install the above dependencies, as well as anything below via homebrew. If you do not have homebrew, get the install command [here](https://brew.sh/) | ||
* You likely need to install libpq-dev, `brew install libpq-dev`, although if you install with homebrew it will have installed this already most likely. If your postgres instance is not working, run this command. | ||
* For file watching and debugging, install [watchman](https://facebook.github.io/watchman/). `brew install watchman` | ||
* You will likely need GSL as well, `brew install gsl`. | ||
* You will need to install Poetry (which requires python 3.10 or greater at the moment), `curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -` | ||
* In order for poetry to run on the correct python version, you will want to make sure that python3 resolves to python 3.10 in your shell | ||
* you will need to install direnv, `brew install direnv` and follow the shell specific instructions here <https://direnv.net/docs/hook.html> | ||
|
||
You must have postgres, python, poetry, and direnv ready to go on your system. | ||
|
||
#### Run-commands / profile | ||
|
||
You should have the following in your `.bashrc` or `.zshrc` or equivalent. | ||
To install on a mac based operating system, you can use the install script to setup everything. | ||
|
||
1. Setup the Path Variable (This is for Pyenv) | ||
Run the following script block to get setup: | ||
|
||
```bash | ||
# PATH definition using Pyenv | ||
export PATH="$(pyenv root)/shims:$PATH" | ||
``` bash | ||
git clone [email protected]:Lightmatter/generic-django-conf.git | ||
./generic-django-conf/scripts/mac_intel_install.sh | ||
``` | ||
|
||
2. Trigger pyenv, direnv inits, add poetry to PATH. | ||
```bash | ||
eval "$(pyenv init --path)" | ||
eval "$(pyenv init -)" | ||
eval "$(direnv hook zsh)" | ||
export PATH="$HOME/.poetry/bin:$PATH" | ||
``` | ||
|
||
* the direnv command will be slight different depending on your shell, follow the instructions at <https://direnv.net/docs/hook.html> | ||
|
||
3. Set up the environment variables for Postgres | ||
```bash | ||
alias pg_start="launchctl load ~/Library/LaunchAgents" | ||
alias pg_stop="launchctl unload ~/Library/LaunchAgents" | ||
export PGDATA="/usr/local/var/postgres/" | ||
``` | ||
|
||
4. If you had to install the Gnu-scientific-library (GSL), setup the library path and the following environment variables. | ||
```bash | ||
export LIBRARY_PATH=/usr/local/Cellar/gsl/2.7/lib/ | ||
|
||
export LDFLAGS="-L/usr/local/opt/openssl/lib" | ||
export CPPFLAGS="-I/usr/local/opt/openssl/include" | ||
``` | ||
It's recommended that you read the output of this script to ensure everything went smoothly, | ||
particularly if you are using Apple silicone (M1-based-mac). | ||
|
||
### Windows | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/bin/zsh | ||
set -e | ||
# The purpose of the prefix is to give an indication of the point | ||
# of execution of this script, so that if something breaks it's easier | ||
# to see where that broke. | ||
prefix="[LM Install Script] " | ||
|
||
# Credit, Taken from: https://stackoverflow.com/a/34389425 | ||
# Installs homebrew if it does not exist, or updates it if it does. | ||
which -s brew | ||
if [[ $? != 0 ]] ; then | ||
echo "${prefix}Installing homebrew" | ||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
else | ||
echo "${prefix}Updating homebrew" | ||
brew update | ||
fi | ||
|
||
echo "${prefix}Installing node" | ||
brew install node | ||
|
||
echo "${prefix}Installing node version manager (nvm)" | ||
brew install nvm | ||
|
||
echo "${prefix}Installing pyenv" | ||
brew install pyenv | ||
|
||
echo "${prefix}Installing git" | ||
brew install git | ||
|
||
echo "${prefix}Installing direnv" | ||
brew install direnv | ||
|
||
echo "${prefix}Installing postgres" | ||
brew install postgresql | ||
|
||
echo "${prefix}Installing libpq" | ||
brew install libpq | ||
|
||
echo "${prefix}Installing watchman" | ||
brew install watchman | ||
|
||
|
||
|
||
echo "${prefix}Adding pyenv, direnv, poetry and path config to .zshrc" | ||
|
||
echo "# START LM 3.0 Configuration" >> ~/.zshrc | ||
|
||
echo "eval \"\$(pyenv init --path)\"" >> ~/.zshrc | ||
echo "eval \"\$(pyenv init -)\"" >> ~/.zshrc | ||
echo "eval \"\$(direnv hook zsh)\"" >> ~/.zshrc | ||
echo "export PATH=\"\$HOME/.poetry/bin:\$PATH\"" >> ~/.zshrc | ||
|
||
echo "${prefix}Reloading zsh" | ||
source ~/.zshrc | ||
|
||
|
||
echo "${prefix}Attemping to change pyenv version to 3.10.2" | ||
pyenv install 3.10.2 | ||
pyenv global 3.10.2 | ||
|
||
echo "${prefix}Attempting to change nvm version to v16.14.0(default)" | ||
nvm install v16.14.0 | ||
nvm alias default v16.14.0 | ||
nvm use default | ||
|
||
echo "${prefix}Attempting to install poetry" | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
|
||
echo "# END LM 3.0 Configuration" >> ~/.zshrc | ||
|
||
|
||
echo "${prefix}Reloading zsh" | ||
source ~/.zshrc | ||
|
||
echo "${prefix}Creating default DB for postgres" | ||
|
||
db_name=$(whoami) | ||
|
||
if psql -lqt | cut -d \| -f 1 | grep -qw "${db_name}"; then | ||
echo "${prefix}Database ${db_name} already exists, skipping creation." | ||
else | ||
echo "${prefix}Database ${db_name} does not exist, creating." | ||
createdb "${db_name}" | ||
fi | ||
|
||
|
||
echo "Provided everything in this script executed without error" | ||
echo "You should now be setup" | ||
echo "You should check your ~/.zshrc" |