Skip to content

Commit

Permalink
Separate example client subpackage (#182)
Browse files Browse the repository at this point in the history
* Update h5web to version 13

Migrate TableDisplay and update Storybook version to 8.4.2

* Make a separate Python package for example client
  • Loading branch information
PeterC-DLS authored Nov 13, 2024
1 parent bf50d75 commit 7e9a900
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
- name: Build sdist and wheel
run: |
pipx run build server
pipx run build server/example-client --outdir server/dist
- name: Upload sdist and wheel as artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion client/example/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default defineConfig({
global: 'window', // this fixes global is not defined
},
build: {
outDir: "../../server/davidia/client",
outDir: "../../server/example-client/sdist",
},
});
6 changes: 5 additions & 1 deletion server/davidia/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ def add_client_endpoint(app, client_path):

def find_client_build():
dvd_pkg_dir = pathlib.Path(__file__).parent
# example client packaged or developing in source tree
# example client packaged
client_dir = dvd_pkg_dir / "client"
if client_dir.is_dir():
return client_dir
# or developing in source tree
client_dir = dvd_pkg_dir.parent / "example-client/sdist"
if client_dir.is_dir():
return client_dir
logger.warning(
Expand Down
28 changes: 28 additions & 0 deletions server/example-client/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from setuptools import setup

__version__ = "1.0.0"

setup(
name="davidia-example-client",
version=__version__,
description="Example frontend for Davidia",
long_description="Static files to serve for an example Davidia plot client",
author_email="[email protected]",
package_dir={
"davidia.client": "sdist",
},
package_data={
"davidia.client": ["*.png", "*.ico", "*.html", "*.txt", "*.json"],
"davidia.client.assets": ["*.css", "*.js"],
},
entry_points={
"console_scripts": [
"dvd-demo = davidia.demos.simple:start_and_run_all_demos",
],
},
python_requires=">=3.10",
install_requires=[
"davidia",
],
url="https://github.com/DiamondLightSource/davidia",
)
29 changes: 9 additions & 20 deletions server/setup.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import os
import pathlib
from setuptools import setup

# from davidia import __version__
__version__ = "1.0.0"


def get_readme(current_dir):
path = os.path.join(current_dir, "README.md")
return path if os.path.exists(path) else None


def find_readme():
current_dir = os.path.abspath(os.path.dirname(__file__))
readme = get_readme(current_dir)
if readme is not None:
return readme

parent_dir = os.path.dirname(current_dir)
readme = get_readme(parent_dir)
if readme is not None:
current_dir = pathlib.Path(__file__).absolute().parent
readme = current_dir / "README.md"
if not readme.is_file():
import shutil

return shutil.copy(readme, current_dir)

parent_dir = current_dir.parent
shutil.copy(parent_dir / "README.md", current_dir)
if readme.is_file():
return readme
raise FileNotFoundError(f"README.md not found in {current_dir} or {parent_dir}")


Expand All @@ -42,13 +33,10 @@ def find_readme():
},
package_data={
"davidia.data": ["*.png"],
"davidia.client": ["*.png", "*.ico", "*.html", "*.txt"],
"davidia.client.assets": ["*.css", "*.js"],
},
entry_points={
"console_scripts": [
"dvd-server = davidia.main:main",
"dvd-demo = davidia.demos.simple:start_and_run_all_demos",
"dvd-benchmark = davidia.demos.benchmark:main",
],
},
Expand All @@ -70,6 +58,7 @@ def find_readme():
"pytest",
"pytest-asyncio",
],
"all": ["davidia-example-client"],
},
url="https://github.com/DiamondLightSource/davidia",
)

0 comments on commit 7e9a900

Please sign in to comment.