Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to hatch #48

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 3 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install node
uses: actions/setup-node@v1
with:
node-version: '14.x'

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
architecture: 'x64'

- name: Setup pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-3.9-${{ hashFiles('setup.cfg') }}
restore-keys: |
pip-3.9-
pip-

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Setup yarn cache
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install jupyterlab

- name: Build the extension
run: |
jlpm
Expand Down
47 changes: 12 additions & 35 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: 'x64'
- name: Install node
uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v1
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg', 'setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache checked links
uses: actions/cache@v2
with:
path: ~/.cache/pytest-link-check
key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/.md') }}-md-links
restore-keys: |
${{ runner.os }}-linkcheck-
- name: Upgrade packaging dependencies
run: |
pip install --upgrade pip setuptools wheel jupyter-packaging~=0.10 --user
- name: Install Dependencies
run: |
pip install .
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Distributions
uses: actions/upload-artifact@v2
with:
name: jupyterlab-link-share-releaser-dist-${{ '{{ github.run_number }}' }}
path: .jupyter_releaser_checkout/dist
24 changes: 0 additions & 24 deletions MANIFEST.in

This file was deleted.

24 changes: 5 additions & 19 deletions jupyterlab_link_share/_version.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import json
from pathlib import Path

__all__ = ["__version__"]

def _fetchVersion():
HERE = Path(__file__).parent.resolve()

for settings in HERE.rglob("package.json"):
try:
with settings.open() as f:
return json.load(f)["version"]
except FileNotFoundError:
pass

raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}")

__version__ = _fetchVersion()

# -*- coding: utf-8 -*-
# This file is auto-generated by Hatchling. As such, do not:
# - modify
# - track in version control e.g. be sure to add to .gitignore
__version__ = VERSION = '0.2.4'
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"url": "https://github.com/jupyterlab-contrib/jupyterlab-link-share/issues"
},
"license": "BSD-3-Clause",
"author": "Project Jupyter Contributors",
"author": {
"name": "Project Jupyter Contributors",
"email": ""
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/**/*.{css,.js,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
Expand Down
77 changes: 65 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,73 @@
[build-system]
requires = ["jupyter_packaging~=0.10", "jupyterlab~=3.0"]
build-backend = "jupyter_packaging.build_api"
requires = ["hatchling>=1.4.0", "jupyterlab>=3.4.7,<4.0.0", "hatch-nodejs-version"]
build-backend = "hatchling.build"

[license]
file="LICENSE"
[project]
name = "jupyterlab_link_share"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.7"
classifiers = [
"Framework :: Jupyter",
"Framework :: Jupyter :: JupyterLab",
"Framework :: Jupyter :: JupyterLab :: 3",
"Framework :: Jupyter :: JupyterLab :: Extensions",
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"jupyter_server>=1.6,<3"
]
dynamic = ["version", "description", "authors", "urls", "keywords"]

[tool.jupyter-packaging.options]
skip-if-exists = ["jupyterlab_link_share/labextension/static/style.js"]
ensured-targets = ["jupyterlab_link_share/labextension/static/style.js", "jupyterlab_link_share/labextension/package.json"]
[project.optional-dependencies]
test = [
]

[tool.hatch.version]
source = "nodejs"

[tool.hatch.metadata.hooks.nodejs]
fields = ["description", "authors", "urls"]

[tool.hatch.build.targets.sdist]
artifacts = ["jupyterlab_link_share/labextension"]
exclude = [".github", "binder"]

[tool.hatch.build.targets.wheel.shared-data]
"jupyterlab_link_share/labextension" = "share/jupyter/labextensions/jupyterlab-link-share"
"install.json" = "share/jupyter/labextensions/jupyterlab-link-share/install.json"
"jupyter-config/jupyter_server_config.d" = "etc/jupyter/jupyter_server_config.d"
"jupyter-config/jupyter_notebook_config.d" = "etc/jupyter/jupyter_notebook_config.d"

[tool.jupyter-packaging.builder]
factory = "jupyter_packaging.npm_builder"
[tool.hatch.build.hooks.version]
path = "jupyterlab_link_share/_version.py"

[tool.jupyter-packaging.build-args]
[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.5"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"jupyterlab_link_share/labextension/static/style.js",
"jupyterlab_link_share/labextension/package.json",
]
skip-if-exists = ["jupyterlab_link_share/labextension/static/style.js"]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
npm = ["jlpm"]

[tool.check-manifest]
ignore = [".binder/**", "*.json", "yarn.lock", ".*", "jupyterlab_link_share/labextension/**"]
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
build_cmd = "install:extension"
npm = ["jlpm"]
source_dir = "src"
build_dir = "jupyterlab_link_share/labextension"

[tool.jupyter-releaser.options]
version_cmd = "hatch version"
34 changes: 0 additions & 34 deletions setup.cfg

This file was deleted.

66 changes: 2 additions & 64 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,2 @@
"""
jupyterlab-link-share setup
"""
import json
from pathlib import Path

import setuptools

HERE = Path(__file__).parent.resolve()

# The name of the project
name = "jupyterlab-link-share"
package = name.replace('-', '_')

lab_path = HERE / package / "labextension"

# Representative files that should exist after a successful build
ensured_targets = [
str(lab_path / "package.json"),
str(lab_path / "static" / "style.js"),
]

package_data_spec = {package: ["*"]}

labext_name = "jupyterlab-link-share"

data_files_spec = [
("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"),
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),
(
"etc/jupyter/jupyter_server_config.d",
"jupyter-config/jupyter_server_config.d",
"jupyterlab_link_share.json",
),
(
"etc/jupyter/jupyter_notebook_config.d",
"jupyter-config/jupyter_notebook_config.d",
"jupyterlab_link_share.json",
),
]


# Get the package info from package.json
pkg_json = json.loads((HERE / "package.json").read_bytes())

try:
from jupyter_packaging import wrap_installers, npm_builder, get_data_files

# In develop mode, just run yarn
builder = npm_builder(build_cmd="build", build_dir=lab_path, source_dir="src")
cmdclass = wrap_installers(post_develop=builder, ensured_targets=ensured_targets)

setup_args = dict(
cmdclass=cmdclass,
data_files=get_data_files(data_files_spec),
)
except ImportError:
setup_args = dict()


setup_args["version"] = pkg_json["version"]

if __name__ == "__main__":
setuptools.setup(**setup_args)
# setup.py shim for use with applications that require it.
__import__("setuptools").setup()