From afc4638f96efb265eb7f229af118e59d1bb2aef5 Mon Sep 17 00:00:00 2001 From: Martin Turoci Date: Thu, 19 Jan 2023 14:42:30 +0100 Subject: [PATCH] chore: Split wavelite and its web assets into separate python packages. #1796 --- py/Makefile | 15 +++++- py/h2o_wavelite/Makefile | 3 ++ py/h2o_wavelite/setup.py | 37 +++----------- py/h2o_wavelite_web/.gitignore | 1 + py/h2o_wavelite_web/MANIFEST.in | 1 + py/h2o_wavelite_web/Makefile | 7 +++ py/h2o_wavelite_web/README.md | 13 +++++ .../h2o_wavelite_web/__init__.py | 19 +++++++ .../h2o_wavelite_web/version.py | 1 + py/h2o_wavelite_web/setup.py | 50 +++++++++++++++++++ 10 files changed, 116 insertions(+), 31 deletions(-) create mode 100644 py/h2o_wavelite/Makefile create mode 100644 py/h2o_wavelite_web/.gitignore create mode 100644 py/h2o_wavelite_web/MANIFEST.in create mode 100644 py/h2o_wavelite_web/Makefile create mode 100644 py/h2o_wavelite_web/README.md create mode 100644 py/h2o_wavelite_web/h2o_wavelite_web/__init__.py create mode 100644 py/h2o_wavelite_web/h2o_wavelite_web/version.py create mode 100644 py/h2o_wavelite_web/setup.py diff --git a/py/Makefile b/py/Makefile index 74068dfd16..d976171ba3 100644 --- a/py/Makefile +++ b/py/Makefile @@ -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 @@ -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 @@ -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}' diff --git a/py/h2o_wavelite/Makefile b/py/h2o_wavelite/Makefile new file mode 100644 index 0000000000..8402f11cc2 --- /dev/null +++ b/py/h2o_wavelite/Makefile @@ -0,0 +1,3 @@ +.PHONY: build +build: + ../venv/bin/python setup.py bdist_wheel diff --git a/py/h2o_wavelite/setup.py b/py/h2o_wavelite/setup.py index beaf770e3e..11ccc32e16 100644 --- a/py/h2o_wavelite/setup.py +++ b/py/h2o_wavelite/setup.py @@ -14,36 +14,11 @@ 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, @@ -51,10 +26,9 @@ def get_data_files(): 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', @@ -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", + }, ) diff --git a/py/h2o_wavelite_web/.gitignore b/py/h2o_wavelite_web/.gitignore new file mode 100644 index 0000000000..3bfdfadafa --- /dev/null +++ b/py/h2o_wavelite_web/.gitignore @@ -0,0 +1 @@ +h2o_wavelite_web/www \ No newline at end of file diff --git a/py/h2o_wavelite_web/MANIFEST.in b/py/h2o_wavelite_web/MANIFEST.in new file mode 100644 index 0000000000..d791153339 --- /dev/null +++ b/py/h2o_wavelite_web/MANIFEST.in @@ -0,0 +1 @@ +recursive-include h2o_wavelite_web/www * diff --git a/py/h2o_wavelite_web/Makefile b/py/h2o_wavelite_web/Makefile new file mode 100644 index 0000000000..6b5552224a --- /dev/null +++ b/py/h2o_wavelite_web/Makefile @@ -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 \ No newline at end of file diff --git a/py/h2o_wavelite_web/README.md b/py/h2o_wavelite_web/README.md new file mode 100644 index 0000000000..21c4b8e1bd --- /dev/null +++ b/py/h2o_wavelite_web/README.md @@ -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. + + + + + diff --git a/py/h2o_wavelite_web/h2o_wavelite_web/__init__.py b/py/h2o_wavelite_web/h2o_wavelite_web/__init__.py new file mode 100644 index 0000000000..038e46e011 --- /dev/null +++ b/py/h2o_wavelite_web/h2o_wavelite_web/__init__.py @@ -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') diff --git a/py/h2o_wavelite_web/h2o_wavelite_web/version.py b/py/h2o_wavelite_web/h2o_wavelite_web/version.py new file mode 100644 index 0000000000..f8ab8c2e1f --- /dev/null +++ b/py/h2o_wavelite_web/h2o_wavelite_web/version.py @@ -0,0 +1 @@ +__version__ = '0.24.0' diff --git a/py/h2o_wavelite_web/setup.py b/py/h2o_wavelite_web/setup.py new file mode 100644 index 0000000000..6f2712885d --- /dev/null +++ b/py/h2o_wavelite_web/setup.py @@ -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", + }, +)