Skip to content

Commit

Permalink
Update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Jan 19, 2024
1 parent 6624b59 commit d7e04e1
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install node
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: '18.x'
- name: Install configurable-http-proxy
run: npm -g install configurable-http-proxy
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Check out the official Docker documentation to know how to install Docker on you
Using `mamba` / `conda`:

```bash
mamba create -n tljh-repo2docker -c conda-forge python nodejs
mamba create -n tljh-repo2docker -c conda-forge python nodejs yarn=3
conda activate tljh-repo2docker
```

Expand Down
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
recursive-include tljh_repo2docker/templates/ *
recursive-include tljh_repo2docker/static/ *
recursive-include tljh_repo2docker/tests/ *
recursive-include frontend/ *

prune frontend/node_modules
prune frontend/lib
prune frontend/.yarn
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build:prod": "cross-env NODE_ENV=production webpack --config webpack.config.js",
"eslint": "eslint --ext .js,.jsx,.ts,.tsx src/",
"prettier": "prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"lint": "yarn prettier && yarn eslint"
"lint": "yarn prettier && yarn eslint",
"clean": "rimraf ./lib ../tljh_repo2docker/static/js/react"
},
"devDependencies": {
"@types/react": "^18.2.0",
Expand All @@ -26,6 +27,7 @@
"less": "^4.1.3",
"less-loader": "11.1.0",
"prettier": "^3.0.0",
"rimraf": "^5.0.5",
"sass": "^1.55.0",
"sass-loader": "^13.1.0",
"style-loader": "^3.3.3",
Expand Down
14 changes: 13 additions & 1 deletion frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,7 @@ __metadata:
languageName: node
linkType: hard

"glob@npm:^10.2.2, glob@npm:^10.3.10":
"glob@npm:^10.2.2, glob@npm:^10.3.10, glob@npm:^10.3.7":
version: 10.3.10
resolution: "glob@npm:10.3.10"
dependencies:
Expand Down Expand Up @@ -4347,6 +4347,17 @@ __metadata:
languageName: node
linkType: hard

"rimraf@npm:^5.0.5":
version: 5.0.5
resolution: "rimraf@npm:5.0.5"
dependencies:
glob: ^10.3.7
bin:
rimraf: dist/esm/bin.mjs
checksum: d66eef829b2e23b16445f34e73d75c7b7cf4cbc8834b04720def1c8f298eb0753c3d76df77325fad79d0a2c60470525d95f89c2475283ad985fd7441c32732d1
languageName: node
linkType: hard

"run-parallel@npm:^1.1.9":
version: 1.2.0
resolution: "run-parallel@npm:1.2.0"
Expand Down Expand Up @@ -4899,6 +4910,7 @@ __metadata:
prettier: ^3.0.0
react: ^18.2.0
react-dom: ^18.2.0
rimraf: ^5.0.5
sass: ^1.55.0
sass-loader: ^13.1.0
style-loader: ^3.3.3
Expand Down
77 changes: 75 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,83 @@
from setuptools import setup, find_packages
import shutil
from pathlib import Path
from subprocess import check_call

from setuptools import Command, find_packages, setup
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop
from setuptools.command.sdist import sdist

here = Path(__file__).parent


class BaseCommand(Command):
"""Copy from https://github.com/jupyterhub/jupyterhub/blob/main/setup.py#L62"""

user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def get_inputs(self):
return []

def get_outputs(self):
return []


class BuildFrontend(BaseCommand):
description = "build React app"
frontend_dir = str(here / "frontend")

def run(self):
if not shutil.which("yarn"):
raise Exception("yarn is not installed!")

check_call(
["yarn", "install"],
cwd=self.frontend_dir,
)

check_call(
["yarn", "clean"],
cwd=self.frontend_dir,
)

check_call(
["yarn", "run", "build:prod"],
cwd=self.frontend_dir,
)


def command_with_build_frontend(Cls):
class CommandWithBuildFrontend(Cls):

def run(self):
self.run_command("build_frontend")

return super().run()

return CommandWithBuildFrontend

setup(
name="tljh-repo2docker",
version="0.0.1",
entry_points={"tljh": ["tljh_repo2docker = tljh_repo2docker"]},
packages=find_packages(),
include_package_data=True,
install_requires=["dockerspawner~=12.1", "jupyter_client~=6.1", "aiodocker~=0.19", "sqlalchemy<2"],
install_requires=[
"dockerspawner~=12.1",
"jupyter_client~=6.1",
"aiodocker~=0.19",
"sqlalchemy<2",
],
cmdclass={
"build_frontend": BuildFrontend,
"develop": command_with_build_frontend(develop),
'build_py': command_with_build_frontend(build_py),
'sdist': command_with_build_frontend(sdist),
},
)

0 comments on commit d7e04e1

Please sign in to comment.