Skip to content

Commit

Permalink
chore: Split wavelite and its web assets into separate python packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Jan 19, 2023
1 parent 538b673 commit afc4638
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 31 deletions.
15 changes: 13 additions & 2 deletions py/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ build: purge
H2O_WAVE_BUILD_OS=darwin H2O_WAVE_BUILD_ARCH=arm64 ./venv/bin/python3 h2o_wave/setup.py bdist_wheel --plat-name=macosx_11_0_arm64
H2O_WAVE_BUILD_OS=darwin H2O_WAVE_BUILD_ARCH=arm64 ./venv/bin/python3 h2o_wave/setup.py bdist_wheel --plat-name=macosx_12_0_arm64
H2O_WAVE_BUILD_OS=any ./venv/bin/python3 h2o_wave/setup.py bdist_wheel
./venv/bin/python3 h2o_wavelite/setup.py bdist_wheel
$(MAKE) build-wavelite
$(MAKE) build-wavelite-web

.PHONY: build-wavelite
build-wavelite:
cd h2o_wavelite && $(MAKE) build

.PHONY: build-wavelite-web
build-wavelite-web:
cd h2o_wavelite_web && $(MAKE) build
setup: ## Install dependencies
git clone --depth 1 --branch $(WAVE_ML_VERSION) https://github.com/h2oai/wave-ml.git h2o_wave_ml
python3 -m venv venv
Expand All @@ -24,6 +32,7 @@ setup: ## Install dependencies
./venv/bin/python -m pip install -r examples/requirements.txt
./venv/bin/python -m pip install --editable h2o_wave
./venv/bin/python -m pip install --editable h2o_wavelite
./venv/bin/python -m pip install --editable h2o_wavelite_web
rm -f h2o_wave/h2o_wave/metadata.py
echo "# Generated in setup.py\n__platform__ = 'linux'\n__arch__ = 'amd64'" > h2o_wave/h2o_wave/metadata.py

Expand All @@ -48,7 +57,9 @@ clean: purge ## Clean

.PHONY: tag
tag: # Bump version
$(SED) -i -r -e "s/__version__.+/__version__ = '$(VERSION)'/" h2o_wave/version.py
$(SED) -i -r -e "s/__version__.+/__version__ = '$(VERSION)'/" h2o_wave/h2o_wave/version.py
$(SED) -i -r -e "s/__version__.+/__version__ = '$(VERSION)'/" h2o_wavelite/h2o_wavelite/version.py
$(SED) -i -r -e "s/__version__.+/__version__ = '$(VERSION)'/" h2o_wavelite_web/h2o_wavelite_web/version.py

help: ## List all make tasks
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down
3 changes: 3 additions & 0 deletions py/h2o_wavelite/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: build
build:
../venv/bin/python setup.py bdist_wheel
37 changes: 8 additions & 29 deletions py/h2o_wavelite/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,21 @@

import setuptools
import os
from pathlib import Path

curr_dir_path = os.path.dirname(os.path.realpath(__file__))

with open(os.path.join(curr_dir_path, 'README.rst'), 'r') as readme:
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'README.rst'), 'r') as readme:
long_description = readme.read()

with open(os.path.join(curr_dir_path, 'README.md'), 'r') as readme_markdown:
conda_description = readme_markdown.read()

version = os.getenv('VERSION', 'DEV')


def get_data_files():
data_dict = {}

build_path = os.path.join(curr_dir_path, '..', '..', 'ui', 'build')
for p in Path(build_path).rglob('*'):
if os.path.isdir(p):
continue
*dirs, _ = p.relative_to(build_path).parts
key = os.path.join('h2o_wavelite', 'www', *dirs)
if key in data_dict:
data_dict[key].append(str(p))
else:
data_dict[key] = [str(p)]

return list(data_dict.items())


setuptools.setup(
name='h2o_wavelite',
version=version,
author='Martin Turoci',
author_email='martin.turoci@h2o.ai',
description='H2O Wave Python driver for integration with arbitrary python web frameworks.',
long_description=long_description,
conda_description=conda_description,
url='https://h2o.ai/products/h2o-wave',
packages=['h2o_wavelite'],
data_files=get_data_files(),
extras_require=dict(web=[f"h2o_wavelite_web=={version}"]),
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
Expand All @@ -70,5 +44,10 @@ def get_data_files():
'Topic :: Software Development :: Widget Sets',
'Topic :: System :: Distributed Computing',
],
python_requires='>=3.7.1'
python_requires='>=3.7.1',
project_urls={
"Documentation": "https://wave.h2o.ai/",
"Source": "https://github.com/h2oai/wave",
"Issues": "https://github.com/h2oai/wave/issues",
},
)
1 change: 1 addition & 0 deletions py/h2o_wavelite_web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h2o_wavelite_web/www
1 change: 1 addition & 0 deletions py/h2o_wavelite_web/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include h2o_wavelite_web/www *
7 changes: 7 additions & 0 deletions py/h2o_wavelite_web/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: build
build: purge
cp -R ../../ui/build h2o_wavelite_web/www
../venv/bin/python setup.py bdist_wheel

purge:
rm -rf h2o_wavelite_web/www
13 changes: 13 additions & 0 deletions py/h2o_wavelite_web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Create apps 10x quicker, without Javascript, HTML, or CSS.

[Documentation](https://nitro.h2o.ai) | [Source](https://github.com/h2oai/nitro)

Integrates with [Django](https://www.djangoproject.com/)
, [Flask](https://flask.palletsprojects.com/), [Starlette](https://www.starlette.io/)
, [Tornado](https://www.tornadoweb.org/), [Uvicorn](https://www.uvicorn.org/) and other popular frameworks. Can be
integrated into your existing applications.





19 changes: 19 additions & 0 deletions py/h2o_wavelite_web/h2o_wavelite_web/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2022 H2O.ai, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .version import __version__

import pathlib

web_directory = str(pathlib.Path(__file__).parent / 'www')
1 change: 1 addition & 0 deletions py/h2o_wavelite_web/h2o_wavelite_web/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.24.0'
50 changes: 50 additions & 0 deletions py/h2o_wavelite_web/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from setuptools import find_namespace_packages, setup


def get_long_description():
return open("README.md", "r", encoding="utf8").read()


setup(
name="h2o_wavelite_web",
version=os.getenv('VERSION', 'DEV'),
url="https://wave.h2o.ai/",
description="Web assets package for H2O Wavelite apps.",
long_description=get_long_description(),
long_description_content_type="text/markdown",
author="Martin Turoci",
author_email="martin.turoci@h2o.ai",
packages=find_namespace_packages(include=["h2o_wavelite_web*"]),
python_requires=">=3.7",
install_requires=[],
include_package_data=True,
license_files=('LICENSE',),
classifiers=[
'License :: OSI Approved :: Apache Software License',
'Development Status :: 2 - Pre-Alpha',
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Internet :: WWW/HTTP",
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Communications :: Chat',
'Topic :: Scientific/Engineering :: Visualization',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Software Development :: Widget Sets',
'Topic :: System :: Distributed Computing',
],
project_urls={
"Documentation": "https://wave.h2o.ai/",
"Source": "https://github.com/h2oai/wave",
"Issues": "https://github.com/h2oai/wave/issues",
},
)

0 comments on commit afc4638

Please sign in to comment.