jupyterlab / extension-template

A `copier` template for JupyterLab extensions
Creative Commons Zero v1.0 Universal
51 stars 16 forks source link

`keywords` defined in the `package.json` file are not included in the Python package metadata #80

Closed joaopalmeiro closed 1 month ago

joaopalmeiro commented 2 months ago

Hi! 👋

Description

keywords is one of the fields defined as dynamic in the pyproject.toml file, similarly to description and urls, for example. If I'm correct, the values ​​for these fields are obtained from the package.json file via the hatch-nodejs-version metadata hook plugin.

However, the keywords defined in the package.json file are not included as metadata of the Python package built from this template as expected. To do so, it is necessary to configure the respective metadata hook plugin to include this field, keywords, as well.

Reproduce

  1. Create a Conda environment as described in the jupyterlab/extension-template repo. I used the following environment.yml file to do so:
name: try-jupyterlab-extension-template
channels:
  - conda-forge
  - nodefaults
dependencies:
  - python=3.10.14
  - pip=23.0.1
  - nodejs=18.18.2
  - jupyterlab=4.0.9
  - copier=9.2.0
  - jinja2-time=0.2.0

More information can be found in the try-jupyterlab-extension-template repo.

  1. Generate a new extension via Copier (a theme extension with the default values, for example).
  2. Install the extension in development mode.
  3. Build the Python package following the instructions available in the RELEASE.md file.
  4. Open the dist/ folder and unzip the wheel/built distribution and source distribution to manually check the metadata files. The PKG-INFO file from the source distribution, for example, should look like this (Dynamic: Keywords on line 4 is the relevant part):
Metadata-Version: 2.3
Name: mytheme
Version: 0.1.0
Dynamic: Keywords
Summary: A JupyterLab extension.
Project-URL: Homepage, https://gitlab.com/joaommpalmeiro/try-jupyterlab-extension-template
Project-URL: Bug Tracker, https://gitlab.com/joaommpalmeiro/try-jupyterlab-extension-template/issues
Project-URL: Repository, https://gitlab.com/joaommpalmeiro/try-jupyterlab-extension-template.git
Author-email: João Palmeiro <joaopalmeiro@proton.me>
License: BSD 3-Clause License

        Copyright (c) 2024, João Palmeiro
        All rights reserved.

        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:

        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.

        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.

        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.
License-File: LICENSE
Classifier: Framework :: Jupyter
Classifier: Framework :: Jupyter :: JupyterLab
Classifier: Framework :: Jupyter :: JupyterLab :: 4
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown

...

Expected behavior

The keywords defined in the package.json file are included as metadata in the Python package by including the "keywords" value in the hatch-nodejs-version metadata hook plugin configuration (pyproject.toml file):

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

Line 4 of the PKG-INFO file shared above should disappear, and the expected Keywords entry for the default package.json file should look like the following snippet:

Keywords: jupyter,jupyterlab,jupyterlab-extension

Let me know what you think and if I can open a PR.

Context

fcollonval commented 1 month ago

Thanks @joaopalmeiro for reporting. Would you be willing to open a PR for this?

joaopalmeiro commented 1 month ago

Sure! I'll open it later today.