Skip to content

Commit

Permalink
Switch to hatch backend
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed May 15, 2022
1 parent f9c668a commit dcc3ed3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 96 deletions.
79 changes: 0 additions & 79 deletions buildapi.py

This file was deleted.

34 changes: 34 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Custom build script for hatch backend"""
import glob
import os
import subprocess

from hatchling.builders.hooks.plugin.interface import BuildHookInterface


class CustomHook(BuildHookInterface):
def initialize(self, version, build_data):
cmd = "build:prod" if version == "stable" else "build"
osp = os.path
here = osp.abspath(osp.dirname(__file__))
lab_path = osp.join(here, 'ipyparallel', 'labextension')

if os.environ.get("IPP_DISABLE_JS") == "1":
print("Skipping js installation")
return

# this tells us if labextension is built at all, not if it's up-to-date
labextension_built = glob.glob(osp.join(lab_path, "*"))
needs_js = True
if not osp.isdir(osp.join(here, ".git")):
print("Installing from a dist, not a repo")
# not in a repo, probably installing from sdist
# could be git-archive, though!
# skip rebuilding js if it's already present
if labextension_built:
print(f"Not regenerating labextension in {lab_path}")
needs_js = False

if needs_js:
subprocess.check_call(['jlpm'], cwd=here)
subprocess.check_call(['jlpm', 'run', cmd], cwd=here)
38 changes: 21 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[build-system]
requires = [
"jupyterlab>=3.0.0,==3.*",
"flit_core >=3.2,<4"
"hatchling"
]
build-backend = "buildapi"
backend-path = ["."]
build-backend = "hatchling.build"

[project]
name = "ipyparallel"
version = "8.4.0.dev"
authors = [{name = "IPython Development Team", email = "ipython-dev@scipy.org"}]
license = {file = "COPYING.md"}
readme = "README.md"
Expand Down Expand Up @@ -48,7 +48,6 @@ dependencies = [
"python-dateutil>=2.1",
"tqdm",
]
dynamic = ["version"]

[project.entry-points."ipyparallel.controller_launchers"]
batch = "ipyparallel.cluster.launcher:BatchControllerLauncher"
Expand Down Expand Up @@ -95,20 +94,22 @@ ipcluster = "ipyparallel.cluster.app:main"
ipcontroller = "ipyparallel.controller.app:main"
ipengine = "ipyparallel.engine.app:main"

[tool.flit.sdist]
include = [
"benchmarks/",
"docs/",
"*.json",
"yarn.lock",
"jupyter-data/",
"lab/",
"buildapi.py",
# Used to call hatch_build.py
[tool.hatch.build.targets.wheel.hooks.custom]
[tool.hatch.build.targets.sdist.hooks.custom]

[tool.hatch.build]
artifacts = [
"ipyparallel/**/*.*"
]
exclude = [
"lab/lib"
]
exclude = ["lab/lib/"]

[tool.flit.external-data]
directory = "jupyter-data"
[tool.hatch.build.targets.wheel.shared-data]
"jupyter-config" = "etc/jupyter"
"ipyparallel/nbextension/static" = "share/jupyter/nbextensions/ipyparallel"
"ipyparallel/labextension" = "share/jupyter/labextensions/ipyparallel-labextension"

[tool.black]
skip-string-normalization = true
Expand Down Expand Up @@ -139,7 +140,6 @@ filterwarnings = [
"ignore:the imp module is:DeprecationWarning",
]


[tool.tbump]
# Uncomment this if your project is hosted on GitHub:
github_url = "https://github.com/jupyterhub/jupyterhub"
Expand Down Expand Up @@ -172,6 +172,10 @@ tag_template = "{new_version}"
src = "ipyparallel/_version.py"
search = '__version__ = "{current_version}"'

[[tool.tbump.file]]
src = "pyproject.toml"
search = '"version" = "{current_version}"'

[[tool.tbump.file]]
src = "package.json"
search = '"version": "{current_version}"'
Expand Down

3 comments on commit dcc3ed3

@Onder71
Copy link

@Onder71 Onder71 commented on dcc3ed3 Sep 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yukardaki kodların açıklamasını yapabilirmisiniz bir metin şeklinde teşekkür ederim.
x

@Onder71
Copy link

@Onder71 Onder71 commented on dcc3ed3 Sep 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metin olarak ne işe yaradığı. Teşekkür ederim

@blink1073
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Onder71, we switched from using setuptools to using hatch to build the release files for ipyparallel. Hatch is a new project in the Python Packaging Authority. We are using the custom build hook to build the JupyterLab and Notebook extensions.

Please sign in to comment.