Skip to content
View j0nix's full-sized avatar

Block or report j0nix

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
j0nix/README.md

  j0nix




Level up your python development environment

It's all about Python and virtual environments. The "old way" is you fiddle:ing with [virtualenv](https://docs.python.org/3/library/venv.html) so you can separate your python development setup from your systems. But if you are like me, I always forget that `source venv/bin/activate` and suddenly you're messing up your system with all those `pip install random-package`.

Hence Direnv ...

From the manual: "direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory".



Ubuntu

Install Direnv

sudo apt-get install direnv or curl -sfL https://direnv.net/install.sh | bash

Shell configuration

Once direnv is installed you need to configure your $SHELL in order to hook it with your default shell.

It supports bash, zsh, fish, tcsh and elvish. I prefer Z-Shell with Oh My Zsh (since it looks cool and have a bunch of plugins like git, kubectl etc) so I proceed with examples for zsh, but the procedures are the same for those other shells

echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
source ~/.zshrc

Thanx to direnv we now can load a virtualenv as soon as we enter a specific folder.

  • All you need to to is to specify that layout command in a .envrc file located at the root of your project.

clone this repo

git clone [email protected]:j0nix/j0nix.git && cd j0nix

Create that .envrc file and define layout

echo 'layout python3' > .envrc
direnv allow

Now you have a virtual python environment, like doing that source venv/bin/activate but with automagic as soon as you enter that git repository folder.

So when you leave your project folder, you automagicly leave that virtualenv. Pretty neat!


Level up and get newer Python & Ansible than provided by your system ...

Pyenv

pyenv lets you easily switch between multiple versions of Python. We want the latest greatest so lets go get that into our system.

Install

curl -L https://pyenv.run | bash

configure your shell

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

Before proceeding getting a new cool python version, fire away this command

sudo apt install curl libncursesw5-dev libxml2-dev libxmlsec1-dev llvm make wget xz-utils build-essential tk-dev zlib1g-dev zlibc libbz2-dev libncurses-dev libffi-dev libreadline-dev libssl-dev liblzma-dev libsqlite3-dev

Above will hopefully prevent you from failing for hours when installing python via pip

install python

pyenv install 3.11.2

(latest 3.11 when this guide was created)

Now, in that git repo folder, instead instruct direnv to load pyenv 3.11.2

echo 'layout pyenv 3.11.2' > .envrc
direnv allow

If everything went according to plan, direnv will automagicly load python 3.11.2.

  • verify using which python

ex)

project git:(master) ✗ which python
  /home/j0nix/j0nix/.direnv/python-3.11.2/bin/python

finish up installing ansible

pip install ansible ansible-lint

Quickguide for Fedora

yum install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sudo yum install direnv
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
source ~/.zshrc
sudo yum install zlib-devel bzip2-devel bzip2-libs ncurses-devel ncurses-libs libffi-devel openssl-devel readline-devel tk-devel libsqlite3x-devel xz-devel
git clone [email protected]:j0nix/platform-services.git && cd platform-services
curl -L https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
pyenv install 3.11.2
echo 'layout pyenv 3.11.2' > .envrc
direnv allow

j0nix

Pinned Loading

  1. j0nix-rest-api j0nix-rest-api Public

    Lightweight REST API. OOP style. For you who just wants REST and don't want to "get down and boogie" with a cool framework...

    PHP 1

  2. poc-parking-calculator poc-parking-calculator Public

    A POC of creating a parking calculator, just for fun and stuff ...

    PHP 1

  3. announce2mattermost announce2mattermost Public

    Simple go app to have uniform/standardized announcements to mattermost (or slack I guess)

    Go 1

  4. dockeree-k8s-quota-monitoring dockeree-k8s-quota-monitoring Public

    DockerEnterprise k8s quota monitoring.

    Python 1

  5. j0nixRSS j0nixRSS Public

    ... Hack for my site since google shut down their rss feed api ...

    PHP 1

  6. sensordata-assigment sensordata-assigment Public

    The assignment is to read input from a number of sensors and output log files

    Python 1