Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup nixos environment and fix requirements #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use nix
layout python3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
.ipynb_checkpoints
3 changes: 3 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

rm -rf .direnv .venv
8 changes: 8 additions & 0 deletions jupyter-lab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
echo "🪛 Running Jupyter using Venv:"
echo "Switch the kernel to 'virtualenv'"
echo "after opening in its own window"
echo "--------------------------------"
python -m ipykernel install --user --name=virtualenv
jupyter kernelspec list
jupyter-lab
3 changes: 3 additions & 0 deletions list-vscode-extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

code --extensions-dir=".vscode-extensions" --list-extensions | xargs -L 1 echo code --extensions-dir=".vscode-extensions" --install-extension
205 changes: 196 additions & 9 deletions osm_LoD1_3DCityModel-walkthrough.ipynb

Large diffs are not rendered by default.

33 changes: 16 additions & 17 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#### ESSENTIAL LIBRARIES FOR MAIN FUNCTIONALITY ####
#-- conda-forge then pip

#conda
python = 3.8.18
geopandas = 0.13.2
mapbox_earcut = 1.0.1
pydeck = 0.8.0
topojson = 1.7

#pip
triangle = 20230923 #- python wrapper around Jonathan Richard Shewchuk's at rufat.be/triangle
cjio = 0.7.3 #- python CLI to process and manipulate CityJSON files
overpass = 0.7
osm2geojson = 0.2.4
openlocationcode = 1.0.1 #- google 'plus codes' at https://github.com/google/open-location-code

#### ESSENTIAL LIBRARIES FOR MAIN FUNCTIONALITY ####
#-- conda-forge then pip

#conda
#python==3.8.18
geopandas==0.13.2
mapbox_earcut==1.0.1
pydeck==0.8.0
topojson==1.7

#pip
triangle==20230923 #- python wrapper around Jonathan Richard Shewchuk's at rufat.be/triangle
cjio==0.7.3 #- python CLI to process and manipulate CityJSON files
overpass==0.7
osm2geojson==0.2.4
openlocationcode==1.0.1 #- google 'plus codes' at https://github.com/google/open-location-code
84 changes: 84 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
with import <nixpkgs> { };
let
# For packages pinned to a specific version
pinnedHash = "nixos-23.11";
pinnedPkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/${pinnedHash}.tar.gz") { };
pythonPackages = python3Packages;
in pkgs.mkShell rec {
name = "impurePythonEnv";
venvDir = "./.venv";
buildInputs = [
# A Python interpreter including the 'venv' module is required to bootstrap
# the environment.
pythonPackages.python

# This executes some shell code to initialize a venv in $venvDir before
# dropping into the shell
pythonPackages.venvShellHook
pinnedPkgs.virtualenv
# Those are dependencies that we would like to use from nixpkgs, which will
# add them to PYTHONPATH and thus make them accessible from within the venv.
pythonPackages.numpy
pinnedPkgs.git
pythonPackages.pip
pythonPackages.numpy
pythonPackages.overpy
pythonPackages.osmpythontools
pythonPackages.setuptools
pythonPackages.gdal
pythonPackages.geopandas
pythonPackages.mapbox-earcut
pythonPackages.pydeck
pythonPackages.overpy
pythonPackages.jupyter
pythonPackages.ipython
pythonPackages.ipympl
pinnedPkgs.vim
pinnedPkgs.git
pinnedPkgs.wget
pinnedPkgs.gotop
# For printing from jupyter
# The list after scheme-small and latex are all .sty latex
# modules that are needed for jupyter printing to work.
# I obtained the list from this issue:
# https://github.com/jupyter/nbconvert/issues/1328#issue-659661022
# Scheme-small is a small footprint latext install. The
# latex schemes and the sytax for the entry below are
# described here:
# https://nixos.wiki/wiki/TexLive
# To actually generate a pdf in jupyter, do
# File -> Save and export notebook as -> PDF
(pinnedPkgs.texlive.combine { inherit (texlive)
scheme-small latex adjustbox caption collectbox enumitem environ eurosym jknapltx
parskip pgf rsfs tcolorbox titling trimspaces ucs ulem upquote
lastpage titlesec advdate pdfcol soul
collection-langgerman collection-langenglish
;})
];
# Run this command, only after creating the virtual environment
PROJECT_ROOT = builtins.getEnv "PWD";

postVenvCreation = ''
unset SOURCE_DATE_EPOCH
pip install -r requirements.txt
echo "-----------------------"
echo "🌈 Your Dev Environment is prepared."
echo "Run ./impute.py"
echo ""
echo "📒 Note:"
echo "-----------------------"
echo "start vscode like this:"
echo ""
echo "./vscode.sh"
echo "-----------------------"
'';

# Now we can execute any commands within the virtual environment.
# This is optional and can be left out to run pip manually.
postShellHook = ''
# allow pip to install wheels
unset SOURCE_DATE_EPOCH
'';


}
18 changes: 18 additions & 0 deletions vscode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
echo "🪛 Installing VSCode Extensions:"
echo "--------------------------------"
code --extensions-dir=".vscode-extensions" --install-extension donjayamanne.python-environment-manager
code --extensions-dir=".vscode-extensions" --install-extension donjayamanne.python-extension-pack
code --extensions-dir=".vscode-extensions" --install-extension hbenl.vscode-test-explorer
code --extensions-dir=".vscode-extensions" --install-extension jamesqquick.python-class-generator
code --extensions-dir=".vscode-extensions" --install-extension KevinRose.vsc-python-indent
code --extensions-dir=".vscode-extensions" --install-extension littlefoxteam.vscode-python-test-adapter
code --extensions-dir=".vscode-extensions" --install-extension ms-python.debugpy
code --extensions-dir=".vscode-extensions" --install-extension ms-python.python
code --extensions-dir=".vscode-extensions" --install-extension ms-python.vscode-pylance
code --extensions-dir=".vscode-extensions" --install-extension ms-vscode.test-adapter-converter
code --extensions-dir=".vscode-extensions" --install-extension njpwerner.autodocstring
code --extensions-dir=".vscode-extensions" --install-extension VisualStudioExptTeam.intellicode-api-usage-examples
code --extensions-dir=".vscode-extensions" --install-extension VisualStudioExptTeam.vscodeintellicode

code --extensions-dir=".vscode-extensions" .