Skip to content

Consolidate package metadata and template others #224

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

Merged
merged 3 commits into from
Apr 15, 2025

Conversation

jakirkham
Copy link
Member

@jakirkham jakirkham commented Mar 28, 2025

  • Add more metadata into package.json
  • Rely on hatch nodejs plugins to fill in pyproject.toml
  • Template Conda recipe with metadata
    • Prefer package.json first (primary source of truth)
    • Fallback to pyproject.toml second
    • Manually write the rest

@jakirkham jakirkham force-pushed the tmplt_conda branch 2 times, most recently from cffe168 to f6e34b4 Compare April 12, 2025 01:12
@jakirkham jakirkham changed the title [WIP] Reuse package metadata in Conda recipe Consolidate package metadata and template others Apr 12, 2025
@jakirkham jakirkham marked this pull request as ready for review April 12, 2025 01:13
Copy link
Member Author

@jakirkham jakirkham left a comment

Choose a reason for hiding this comment

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

Have added some notes below to describe the changes here

Generally the goal is to have metadata in a central place (mainly package.json followed by pyproject.toml)

This should make it easier to keep things in sync across package formats. Making maintenance of package metadata simpler

@@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/rapidsai/jupyterlab-nvdashboard/issues"
},
"license": "",
"license": "BSD-3-Clause",
Copy link
Member Author

Choose a reason for hiding this comment

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

Fill this in as SPDX. This can be loaded with hatch-nodejs-version

@@ -47,7 +49,7 @@ test = [
source = "nodejs"

[tool.hatch.metadata.hooks.nodejs]
fields = ["description", "authors", "urls"]
fields = ["license", "description", "authors", "urls"]
Copy link
Member Author

Choose a reason for hiding this comment

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

With the license added to package.json, we can now ask hatch-nodejs-version to pull it into pyproject.toml for us

@@ -33,7 +35,7 @@ dependencies = [
"psutil",
"pynvml>=12.0.0,<13.0.0a0",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit dependencies.yaml and run `rapids-dependency-file-generator`.
dynamic = ["version", "description", "authors", "urls", "keywords"]
dynamic = ["version", "license", "description", "authors", "urls", "keywords"]
Copy link
Member Author

Choose a reason for hiding this comment

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

Note we now flag the license field as dynamic since hatch-nodejs-version fills it in for us

Comment on lines -15 to +17
license = { file = "LICENSE" }
license-files = [
"LICENSE",
]
Copy link
Member Author

Choose a reason for hiding this comment

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

We drop the license field as it now is pulled in from package.json

Also PEP 639 defined the spec for handling license files. So we use that here


[build-system]
requires = [
"hatch-jupyter-builder>=0.5",
"hatch-nodejs-version>=0.3.2",
"hatchling>=1.5.0",
"hatchling>=1.27.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

Hatch 1.27.0 added support for license files with PR: pypa/hatch#1829

Hence we bump the minimum version accordingly

Comment on lines +1 to +2
{% set package_json = load_file_data("package.json") %}
{% set pyproject_toml = load_file_data("pyproject.toml") %}
Copy link
Member Author

Choose a reason for hiding this comment

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

In the Conda recipe we can also load from package.json. So we do so here

We fallback to pyproject.toml for anything else

{% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %}
{% set date_string = environ['RAPIDS_DATE_STRING'] %}

{% set python_min = "3.9" %}
{% set requires_python = pyproject_toml["project"]["requires-python"] %}
Copy link
Member Author

Choose a reason for hiding this comment

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

We reuse the Python requirement from pyproject.toml and use this below

Comment on lines 24 to +31
requirements:
host:
- python {{ python_min }}
- python {{ requires_python }}
- pip
- nodejs
- hatch-jupyter-builder >=0.5
- hatch-nodejs-version >=0.3.2
- hatchling >=1.5.0
- jupyterlab >=4.0.0
{% for r in pyproject_toml["build-system"]["requires"] %}
- {{ r }}
{% endfor %}
Copy link
Member Author

Choose a reason for hiding this comment

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

With the exception of some base requirements (python, pip & nodejs), we load all other build requirement from pyproject.toml

Comment on lines 32 to +36
run:
- python >={{ python_min }}
- jupyterlab >=4.0.0
- psutil
- pynvml >=12.0.0,<13.0.0a0
- python {{ requires_python }}
{% for r in pyproject_toml["project"]["dependencies"] %}
- {{ r }}
{% endfor %}
Copy link
Member Author

Choose a reason for hiding this comment

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

We repeat the same process loading pyproject.toml's run requirements

Comment on lines 47 to 54
about:
home: https://rapids.ai
license: BSD-3-Clause
license_family: BSD
home: {{ package_json["homepage"] }}
license: {{ package_json["license"] }}
license_file: ../../../LICENSE
summary: A JupyterLab extension for displaying dashboards of GPU usage
description: |
A JupyterLab extension for displaying dashboards of GPU usage.
doc_url: https://github.com/rapidsai/jupyterlab-nvdashboard
dev_url: https://github.com/rapidsai/jupyterlab-nvdashboard
summary: {{ package_json["description"] }}
description: {{ package_json["description"] }}
doc_url: {{ package_json["homepage"] }}
dev_url: {{ package_json["repository"]["url"] }}
Copy link
Member Author

Choose a reason for hiding this comment

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

Metadata is now loaded from package.json

* Add more metadata into `package.json`
* Rely on hatch nodejs plugins to fill in `pyproject.toml`
* Template Conda recipe with metadata
  * Prefer `package.json` first (primary source of truth)
  * Fallback to `pyproject.toml` second
  * Manually write the rest
Copy link
Member

@jacobtomlinson jacobtomlinson left a comment

Choose a reason for hiding this comment

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

LGTM thanks @jakirkham

@jacobtomlinson jacobtomlinson merged commit 4409718 into rapidsai:branch-0.14 Apr 15, 2025
11 checks passed
@jakirkham jakirkham deleted the tmplt_conda branch April 15, 2025 16:07
@jakirkham
Copy link
Member Author

Thanks all! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants