Skip to content

Commit

Permalink
Make it possible to run citychef outside a notebook.
Browse files Browse the repository at this point in the history
Add a setup.py, to allow citychef to be installed as a library.
Remove the dependency on ipython introduced by the explicit use of
HaloNotebook.
Add missing dependencies to requirements.txt.
  • Loading branch information
andreweland committed Jun 23, 2020
1 parent 40656c4 commit 054e8b9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
17 changes: 14 additions & 3 deletions citychef/osm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
from halo import HaloNotebook as Halo
from lxml import etree as et
import os
import pandas as pd
import gzip

import halo

def Halo(*args, **kw):
ipython = False
try:
get_ipython()
ipython = True
except NameError:
pass
if ipython:
return halo.HaloNotebook(*args, **kw)
return halo.Halo(*args, **kw)

def is_xml(location):
return location.lower().endswith(".xml")
Expand All @@ -14,7 +24,7 @@ def is_gzip(location):


def create_local_dir(directory):
if not os.path.exists(directory):
if directory != "" and not os.path.exists(directory):
print('Creating {}'.format(directory))
os.makedirs(directory)

Expand All @@ -33,6 +43,7 @@ def xml_content(content):
return xml_version + tree



def write_content(content, location, **kwargs):
with Halo(text="\tWriting output to local file system at {}".format(location),
spinner='dots') as spinner:
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ geopandas==0.6.1
matplotlib==3.1.1
scipy==1.3.0
scikit_learn==0.22.2.post1
halo==0.0.29
lxml==4.5.1
ipywidgets==7.5.1
23 changes: 23 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import setuptools

with open("README.md", "r") as f:
long_description = f.read()

setuptools.setup(
name="citychef",
version="0.0.1",
author="Arup City Modelling Lab",
author_email="[email protected]",
description="Randomly generate a city, and output statistical data about it.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/fredshone/citychef",
packages=setuptools.find_packages(),
classifiers=[
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)

0 comments on commit 054e8b9

Please sign in to comment.