pypa / pypa/setuptools

[FR] Replace `entry-points` keyword with `scripts` in a `dynamic` table`

Open
#4,146 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Needs Triage
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

What's the problem this feature will solve?

As of setuptools 69.0.0, it looks like you need to include scripts in a dynamic definition if you were previously using entry-points.

As an example:

# Pre 69
dynamic = ["entry-points"]

[tool.setuptools.dynamic]
entry-points = {file = "entrypoints.txt"}

Then post-69

dynamic = ["scripts"]

[tool.setuptools.dynamic]
entry-points = {file = "entrypoints.txt"}

Note that if you do this:

[tool.setuptools.dynamic]
scripts = {file = "scripts.txt"}

setuptools will fail, since scripts is not currently defined as a valid key in the dynamic table

Describe the solution you'd like

Simply replace entry-points as a dynamic table entry with scripts, and deprecate the usage of entry-points entirely.

Alternative Solutions

Re-instate the usage of entry-points without using scripts

Additional context

This is the error received if you continue to use entrypoints without using scripts instead (pre setuptools 69 example):

      setuptools.errors.InvalidConfigError:
          The following seems to be defined outside of `pyproject.toml`:
      
          `scripts = <a table of scripts>`
      
          According to the spec (see the link below), however, setuptools CANNOT
          consider this value unless `scripts` is listed as `dynamic`.
      
          https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

This is the error if you define scripts in the dynamic table:

× Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [275 lines of output]
      configuration error: `tool.setuptools.dynamic` must not contain {'scripts'} properties
      DESCRIPTION:
          Instructions for loading :pep:`621`-related metadata dynamically
      
      GIVEN VALUE:
          {
              "version": {
                  "attr": "w.__version__"
              },
              "scripts": {
                  "file": "scripts.txt"
              }
          }
      
      OFFENDING RULE: 'additionalProperties'
      
      DEFINITION:
          {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                  "version": {
                      "$$description": [
                          "A version dynamically loaded via either the ``attr:`` or ``file:``",
                          "directives. Please make sure the given file or attribute respects :pep:`4[40](https://github.com/<url>)`."
                      ],
                      "oneOf": [
                          {
                              "title": "'attr:' directive",
                              "$id": "#/definitions/attr-directive",
                              "$$description": [
                                  "Value is read from a module attribute. Supports callables and iterables;",
                                  "unsupported types are cast via ``str()``"
                              ],
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                  "attr": {
                                      "type": "string"
                                  }
                              },
                              "required": [
                                  "attr"
                              ]
                          },
                          {
                              "$id": "#/definitions/file-directive",
                              "title": "'file:' directive",
                              "description": "Value is read from a file (or list of files and then concatenated)",
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                  "file": {
                                      "oneOf": [
                                          {
                                              "type": "string"
                                          },
                                          {
                                              "type": "array",
                                              "items": {
                                                  "type": "string"
                                              }
                                          }
                                      ]
                                  }
                              },
                              "required": [
                                  "file"
                              ]
                          }
                      ]
                  },
                  "classifiers": {
                      "$id": "#/definitions/file-directive",
                      "title": "'file:' directive",
                      "description": "Value is read from a file (or list of files and then concatenated)",
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                          "file": {
                              "oneOf": [
                                  {
                                      "type": "string"
                                  },
                                  {
                                      "type": "array",
                                      "items": {
                                          "type": "string"
                                      }
                                  }
                              ]
                          }
                      },
                      "required": [
                          "file"
                      ]
                  },
                  "description": {
                      "$id": "#/definitions/file-directive",
                      "title": "'file:' directive",
                      "description": "Value is read from a file (or list of files and then concatenated)",
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                          "file": {
                              "oneOf": [
                                  {
                                      "type": "string"
                                  },
                                  {
                                      "type": "array",
                                      "items": {
                                          "type": "string"
                                      }
                                  }
                              ]
                          }
                      },
                      "required": [
                          "file"
                      ]
                  },
                  "dependencies": {
                      "$id": "#/definitions/file-directive",
                      "title": "'file:' directive",
                      "description": "Value is read from a file (or list of files and then concatenated)",
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                          "file": {
                              "oneOf": [
                                  {
                                      "type": "string"
                                  },
                                  {
                                      "type": "array",
                                      "items": {
                                          "type": "string"
                                      }
                                  }
                              ]
                          }
                      },
                      "required": [
                          "file"
                      ]
                  },
                  "entry-points": {
                      "$id": "#/definitions/file-directive",
                      "title": "'file:' directive",
                      "description": "Value is read from a file (or list of files and then concatenated)",
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                          "file": {
                              "oneOf": [
                                  {
                                      "type": "string"
                                  },
                                  {
                                      "type": "array",
                                      "items": {
                                          "type": "string"
                                      }
                                  }
                              ]
                          }
                      },
                      "required": [
                          "file"
                      ]
                  },
                  "optional-dependencies": {
                      "type": "object",
                      "propertyNames": {
                          "format": "python-identifier"
                      },
                      "additionalProperties": false,
                      "patternProperties": {
                          ".+": {
                              "$id": "#/definitions/file-directive",
                              "title": "'file:' directive",
                              "description": "Value is read from a file (or list of files and then concatenated)",
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                  "file": {
                                      "oneOf": [
                                          {
                                              "type": "string"
                                          },
                                          {
                                              "type": "array",
                                              "items": {
                                                  "type": "string"
                                              }
                                          }
                                      ]
                                  }
                              },
                              "required": [
                                  "file"
                              ]
                          }
                      }
                  },
                  "readme": {
                      "anyOf": [
                          {
                              "$id": "#/definitions/file-directive",
                              "title": "'file:' directive",
                              "description": "Value is read from a file (or list of files and then concatenated)",
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                  "file": {
                                      "oneOf": [
                                          {
                                              "type": "string"
                                          },
                                          {
                                              "type": "array",
                                              "items": {
                                                  "type": "string"
                                              }
                                          }
                                      ]
                                  }
                              },
                              "required": [
                                  "file"
                              ]
                          },
                          {
                              "properties": {
                                  "content-type": {
                                      "type": "string"
                                  }
                              }
                          }
                      ],
                      "required": [
                          "file"
                      ]
                  }
              }
          }
Code of Conduct
  • I agree to follow the PSF Code of Conduct

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the dynamic-table schema and the handling for the entry-points key in setuptools. Reproduce the two configuration examples from the issue, then verify that the supported scripts form is accepted and the legacy form is handled as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.