Before using the project, either install it by following instructions in Installation section, or configure a development environment by following instructions in Development section.
-
Output project version
actransit-rt version
-
Retrieve latest vehicle positions
actransit-rt archive retrieve-vehicle-positions --input-dir=gs://tvrr-transit-snapshots/actransit/gtfs-rt --limit=10
If not developing, then no need to clone this repo. You can use pipx to install the project directly. If you don't have pipx
then first install it.
-
Install the project:
pipx install git+https://github.com/bryanculbertson/actransit-rt
-
Test your installation!
actransit-rt --help
If developing, then clone this repo, setup a development environment, and run the project from there.
This project uses pyenv and poetry to manage python virtual environment and dependencies. If you have a working python
system with those tools installed then you can skip system environment setup and go straight to Setup Project Environment.
If you know what you are doing, then you can skip using pyenv
as long as you have the version of python installed that is specified in .python-version
.
-
Create a Codespace or open in VS Code locally
Follow Github instructions to Create a Codespace for this project, or VS Code instructions to open repo in container
-
Choose the local
.venv
python if given a choice.
-
Install python build dependencies:
sudo apt-get update sudo apt-get -y install --no-install-recommends \ bash \ build-essential \ curl \ expat \ fontconfig \ gcc \ git \ libbz2-dev \ libffi-dev \ liblzma-dev \ libmpfr-dev \ libncurses-dev \ libpq-dev \ libreadline-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ libxmlsec1-dev \ llvm \ locales \ make \ openssl \ sudo \ tk-dev \ unzip \ vim \ wget \ wget \ xz-utils \ zip \ zlib1g \ zlib1g-dev
-
Install project dependencies:
sudo apt-get update sudo apt-get -y install --no-install-recommends \ apt-transport-https \ ca-certificates \ gnupg \ shellcheck
-
Install pyenv (if you haven't already):
curl https://pyenv.run | bash
Add
pyenv
paths forbash
:{ echo '' echo 'export PYENV_ROOT="$HOME/.pyenv"' echo 'export PATH="$PYENV_ROOT/bin:$PATH"' echo 'eval "$(pyenv init --path)"' echo 'eval "$(pyenv init -)"' echo 'eval "$(pyenv virtualenv-init -)"' } >> ~/.bashrc
Refresh current shell with updated paths:
source ~/.bashrc
Check
pyenv
was installed correctly by verifyingpython
points to~/.pyenv/shims/python
:which python
If you have an issue, see pyenv's instructions.
-
Install project python version specified in
.python-version
:pyenv install
Check correct
python
version was installed by verifying it matches.python-version
:python --version cat .python-version
-
Install poetry (if you haven't already):
curl -sSL https://install.python-poetry.org | python3 -
Add
poetry
paths forbash
:echo 'export PATH="$HOME/.poetry/bin:$PATH"' >> ~/.bashrc
Refresh current shell with updated paths:
source ~/.bashrc
-
Install
gcloud-cli
(if you haven't already)https://cloud.google.com/sdk/docs/install-sdk#deb
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list sudo apt-get update && sudo apt-get install google-cloud-cli
-
Install homebrew (if you haven't already):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install python build dependencies:
brew install openssl readline sqlite3 xz zlib
-
Install project dependencies:
brew install shellcheck
-
Install pyenv (if you haven't already):
brew install pyenv
Add
pyenv
path forzsh
(or~/.bashrc
if usingbash
):echo 'eval "$(pyenv init --path)"' >> ~/.zprofile echo 'eval "$(pyenv init -)"' >> ~/.zshrc
Refresh current shell with updated paths:
source ~/.zprofile source ~/.zshrc
Check
pyenv
was installed correctly by verifyingpython
points to~/.pyenv/shims/python
:which python
If you have an issue, see pyenv's instructions.
-
Install project python version specified in
.python-version
:pyenv install
Check correct
python
version was installed by verifying it matches.python-version
:python --version cat .python-version
-
Install poetry (if you haven't already):
curl -sSL https://install.python-poetry.org | python3 -
Add
poetry
path forzsh
(or~/.bashrc
if usingbash
):echo 'export PATH="$HOME/.poetry/bin:$PATH"' >> ~/.zshrc
Refresh current shell with updated paths:
source ~/.zshrc
-
Install
gcloud-cli
(if you haven't already)Download and extract the
tar.gz
package for your Platform from here: https://cloud.google.com/sdk/docs/install-sdk#mac./google-cloud-sdk/install.sh
After setting up system environment with pyenv
and poetry
, then you can install the project and its depedancies.
-
Install project python version specified in
.python-version
:pyenv install
Check correct
python
version was installed by verifying it matches.python-version
:python --version cat .python-version
-
Install project and dependancies into local poetry managed
.venv
:poetry env use "$(cat .python-version)" poetry install
Add poetry plugins used by this project
poetry self add poetry-plugin-export poetry-plugin-dotenv
-
Test your installation!
poetry run actransit-rt --help
or
poetry shell actransit-rt --help
-
Init
gcloud
If you are working with TVRR then choose project
tvrr-409423
and compute zoneus-west1-b
:gcloud init gcloud auth application-default login
After setting up system and project environments you can run tests, formatting, linting, etc. with tox.
tox
is installed and managed within the local venv so either activate the venv
with poetry shell
, or prefix each command with poetry run
.
-
Run tests and linting
poetry run tox
-
Run tests
poetry run tox -qe test
-
Run linting
poetry run tox -qe lint
-
Enable pre-commit hooks:
poetry run tox -e install-hooks