This commit is contained in:
William Guss
2024-09-08 21:05:52 -07:00
parent 45da7e7845
commit 507ecd3296
4 changed files with 58 additions and 72 deletions

24
LICENSE
View File

@@ -1,11 +1,21 @@
Copyright 2023 William Hebgen Guss
MIT License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Copyright (c) 2024 William Guss
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

37
build.py Normal file
View File

@@ -0,0 +1,37 @@
import os
import subprocess
import shutil
def run_command(command, cwd=None):
result = subprocess.run(command, shell=True, cwd=cwd)
if result.returncode != 0:
raise RuntimeError(
f"Command {command} failed with return code {result.returncode}"
)
def npm_install():
print("Running npm install")
run_command("npm install", cwd="ell-studio")
def npm_build():
print("Running npm build")
run_command("npm run build", cwd="ell-studio")
print("Copying static files")
source_dir = os.path.join("ell-studio", "build")
target_dir = os.path.join("src", "ell", "studio", "static")
shutil.rmtree(target_dir, ignore_errors=True)
shutil.copytree(source_dir, target_dir)
print(f"Copied static files from {source_dir} to {target_dir}")
def main():
npm_install()
npm_build()
if __name__ == "__main__":
main()

View File

@@ -1,51 +0,0 @@
import os
import subprocess
import shutil
def run_command(command, cwd=None):
result = subprocess.run(command, shell=True, cwd=cwd)
if result.returncode != 0:
raise RuntimeError(
f"Command {command} failed with return code {result.returncode}"
)
def sync_version():
version = (
subprocess.check_output(["poetry", "version", "-s"]).strip().decode("utf-8")
)
run_command(f"git tag -f {version}")
def python_install():
sync_version()
run_command("poetry self add poetry-dynamic-versioning")
run_command("poetry dynamic-versioning enable")
run_command("pip uninstall -y ell")
run_command("poetry install")
run_command("poetry build")
run_command("pip install dist/*.whl")
shutil.rmtree("dist", ignore_errors=True)
def npm_install():
print("Running npm install")
run_command("npm install", cwd="ell-studio")
def npm_build():
print("Running npm build")
run_command("npm run build", cwd="ell-studio")
print("Copying static files")
source_dir = os.path.join("ell-studio", "build")
target_dir = os.path.join("src", "ell", "studio", "static")
shutil.rmtree(target_dir, ignore_errors=True)
shutil.copytree(source_dir, target_dir)
print(f"Copied static files from {source_dir} to {target_dir}")
def main():
npm_install()
npm_build()
python_install()

View File

@@ -46,23 +46,13 @@ pytest = "^8.3.2"
sphinx = "<8.0.0"
sphinx-rtd-theme = "^2.0.0"
[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.plugins.build]
backend = "build:CustomBuildBackend"
[tool.poetry.scripts]
ell-studio = "ell.studio.__main__:main"
build-hook = "build_hook:main"
[tool.poetry.extras]
npm_install = ["invoke"]
npm_build = ["invoke"]
[tool.poetry-dynamic-versioning]
enable = true
metadata = true
format = "{base}"
# [tool.poetry.build]
# # script = "build.py"