setup.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. """
  2. yili-dag setup
  3. """
  4. import json
  5. import sys
  6. from pathlib import Path
  7. import setuptools
  8. HERE = Path(__file__).parent.resolve()
  9. # Get the package info from package.json
  10. pkg_json = json.loads((HERE / "package.json").read_bytes())
  11. # The name of the project
  12. name = "yili-dag"
  13. lab_path = (HERE / pkg_json["jupyterlab"]["outputDir"])
  14. # Representative files that should exist after a successful build
  15. ensured_targets = [
  16. str(lab_path / "package.json"),
  17. str(lab_path / "static/style.js")
  18. ]
  19. labext_name = pkg_json["name"]
  20. data_files_spec = [
  21. ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"),
  22. ("share/jupyter/labextensions/%s" % labext_name, str("."), "install.json"),
  23. ]
  24. long_description = (HERE / "README.md").read_text(encoding="utf8")
  25. version = (
  26. pkg_json["version"]
  27. .replace("-alpha.", "a")
  28. .replace("-beta.", "b")
  29. .replace("-rc.", "rc")
  30. )
  31. setup_args = dict(
  32. name=name,
  33. version=version,
  34. url=pkg_json["homepage"],
  35. author=pkg_json["author"]["name"],
  36. author_email=pkg_json["author"]["email"],
  37. description=pkg_json["description"],
  38. license=pkg_json["license"],
  39. license_file="LICENSE",
  40. long_description=long_description,
  41. long_description_content_type="text/markdown",
  42. packages=setuptools.find_packages(),
  43. zip_safe=False,
  44. include_package_data=True,
  45. python_requires=">=3.7",
  46. platforms="Linux, Mac OS X, Windows",
  47. keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
  48. classifiers=[
  49. "License :: OSI Approved :: BSD License",
  50. "Programming Language :: Python",
  51. "Programming Language :: Python :: 3",
  52. "Programming Language :: Python :: 3.7",
  53. "Programming Language :: Python :: 3.8",
  54. "Programming Language :: Python :: 3.9",
  55. "Programming Language :: Python :: 3.10",
  56. "Framework :: Jupyter",
  57. "Framework :: Jupyter :: JupyterLab",
  58. "Framework :: Jupyter :: JupyterLab :: 3",
  59. "Framework :: Jupyter :: JupyterLab :: Extensions",
  60. "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
  61. ],
  62. )
  63. try:
  64. from jupyter_packaging import (
  65. wrap_installers,
  66. npm_builder,
  67. get_data_files
  68. )
  69. post_develop = npm_builder(
  70. build_cmd="install:extension", source_dir="src", build_dir=lab_path
  71. )
  72. setup_args["cmdclass"] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)
  73. setup_args["data_files"] = get_data_files(data_files_spec)
  74. except ImportError as e:
  75. import logging
  76. logging.basicConfig(format="%(levelname)s: %(message)s")
  77. logging.warning("Build tool `jupyter-packaging` is missing. Install it with pip or conda.")
  78. if not ("--name" in sys.argv or "--version" in sys.argv):
  79. raise e
  80. if __name__ == "__main__":
  81. setuptools.setup(**setup_args)