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

Support pyproject.toml-style configuration (PEP 621) - Round 2 #2970

Merged
merged 63 commits into from
Mar 24, 2022

Commits on Mar 5, 2022

  1. Rename config to config.setupcfg

    This will facilitate the implementation of other configuration formats
    (such as pyproject.toml as initially defined by PEP 621)
    abravalheri committed Mar 5, 2022
    1 Configuration menu
    Copy the full SHA
    49b7a60 View commit details
    Browse the repository at this point in the history
  2. Extract post-processing functions from config

    We can split the process of interpreting configuration files into 2 steps:
    
    1. The parsing the file contents from strings to value objects
       that can be understand by Python (for example a string with a comma
       separated list of keywords into an actual Python list of strings).
    
    2. The expansion (or post-processing) of these values according to the
       semantics ``setuptools`` assign to them (for example a configuration field
       with the ``file:`` directive should be expanded from a list of file paths to
       a single string with the contents of those files concatenated)
    
    The idea of this change is to extract the functions responsible for (2.)
    into a new module, so they can be reused between different config file
    formats.
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    f866876 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7d9ecc0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8330040 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    a148c33 View commit details
    Browse the repository at this point in the history
  6. Add news fragment

    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    d96e8bf View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    61a416b View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    ec2071a View commit details
    Browse the repository at this point in the history
  9. Adopt review suggestions

    Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
    abravalheri and webknjaz committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    25612c5 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    81c3faa View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    82779f9 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e5d2bc8 View commit details
    Browse the repository at this point in the history
  13. Add tomli as vendorised dependency

    This eventually will allow reading project metadata directly from
    `pyproject.toml`
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    099ac60 View commit details
    Browse the repository at this point in the history
  14. Add validate-pyproject as a vendored dependency

    In order to minimise dependencies, `validate-pyproject` has the ability
    to "dump" only the code necessary to run the validations to a given
    directory. This special strategy is used instead of the default
    `pip install -t`.
    
    The idea of using JSONSchema for validation was suggested in pypa#2671,
    and the rationale for that approach is further discussed in
    https://github.com/abravalheri/validate-pyproject/blob/main/docs/faq.rst
    
    Using a library such as `validate-pyproject` has the advantage of
    incentive sing reuse and collaboration with other projects.
    
    Currently `validate-pyproject` ships a JSONSchema for the proposed
    use of `pyproject.toml` as means of configuration for setuptools.
    In the future, if there is interest, setuptools could also ship its own
    schema and just use the shared infrastructure of `validate-pyproject`
    (by advertising the schemas via entry-points).
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    771488d View commit details
    Browse the repository at this point in the history
  15. Add news fragment

    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    78dc278 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    7371508 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    ccd2f07 View commit details
    Browse the repository at this point in the history
  18. Update vendored tomli to 2.0.1

    Enforcing local imports is no longer needed.
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    e0d61d4 View commit details
    Browse the repository at this point in the history
  19. Improve custom vendoring logic for validate-pyproject

    Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
    abravalheri and webknjaz committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    74c7341 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    e2f07dc View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    7f68bb4 View commit details
    Browse the repository at this point in the history
  22. Implement read_configuration from pyproject.toml

    This is the first step towards making setuptools understand
    `pyproject.toml` as a configuration file.
    
    The implementation deliberately allows splitting the act of loading the
    configuration from a file in 2 stages: the reading of the file itself
    and the expansion of directives (and other derived information).
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    af187e8 View commit details
    Browse the repository at this point in the history
  23. Expand dynamic entry_points from pyproject.toml

    The user might specify dynamic `entry-points` via a `file:`
    directive (a similar feature for `setup.cfg` is documented in
    [declarative config]).
    
    The changes introduced here add the ability to expand them
    when reading the configuration from `pyproject.toml`.
    
    [declarative config]: https://setuptools.pypa.io/en/latest/userguide/declarative_config.html
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    8826dc1 View commit details
    Browse the repository at this point in the history
  24. Make include_package_data=True for pyproject.toml configs

    There is frequent an opinion in the community that
    `include_package_data=True` is a better default
    (and a quality of life improvement).
    
    Since we are migrating to a new configuration file, this change can
    be implemented in a backward compatible way
    (to avoid breaking existing packages):
    
    - Config from `setup.cfg` defaults to `include_package_data=False`
    - Config from `pyproject.toml` defaults to `include_package_data=True`
    
    This also takes advantage that `ini2toml` (the provided library for
    automatic conversion between `setup.cfg` and `pyproject.toml`) will
    backfill `include_package_data=False` when the field is missing.
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    a8112d9 View commit details
    Browse the repository at this point in the history
  25. Add means of applying config read from pyproject.toml to dist

    Since the Distrubition and DistributionMetadata classes are modeled
    after (an old version of) core metadata, it is necessary to add a
    translation layer between them and the configuration read from
    pyproject.toml
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    9672a48 View commit details
    Browse the repository at this point in the history
  26. Add the apply_configuration API to setuptools.config.setupcfg

    The apply_configuration is implemented in a way that it is consistent
    for both pyproject.toml and setup.cfg
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    d7363d5 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    26a9264 View commit details
    Browse the repository at this point in the history
  28. Fix pyproject config when tool table is not present

    Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
    abravalheri and henryiii committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    051b825 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    c927227 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    905eed7 View commit details
    Browse the repository at this point in the history
  31. Prevent resource warnings in test_apply_pyprojecttoml

    Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
    abravalheri and webknjaz committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    b426b2b View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    e91969a View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    9ee2697 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    e5c5519 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    5d4457e View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    cf32acb View commit details
    Browse the repository at this point in the history
  37. Back-fill Description-Content-Type according to readme suffix

    According to PEP 621, the backend should fill-in the content-type if the
    `readme` field is passed as a string. The value is derived from the
    extension of the file (an error should be raised when that is not
    possible).
    
    Previously all READMEs were wrongly assumed rst.
    This error was reported in:
    
    https://discuss.python.org/t/help-testing-experimental-features-in-setuptools/13821/4
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    a4b474e View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    0497954 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    d385330 View commit details
    Browse the repository at this point in the history
  40. Add deprecation notice for config.{read,parse}_configuration

    Since now setuptools supports 2 types of files for configuration
    (`setup.cfg` and `pyproject.toml`), it is very trick to provide a single
    `read_configuration` function that will provide compatible outputs for
    both formats.
    
    Instead the `config.{setupcfg,pyprojecttoml}` modules have their own
    `read_configuration` functions that differ between themselves in terms
    of arguments and format of the return value.
    
    Therefore the users should be importing directly the specific submodule
    and calling the read function from there.
    
    The `config.setupcfg` submodule is advertised as "provisional" in the
    deprecation note because the main proposal debated in the setuptools
    issue tracker reached some level of consensus around deprecating
    `setup.cfg` files.
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    dea4be5 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    2b333e9 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    09f784f View commit details
    Browse the repository at this point in the history
  43. Replace skip in editable install test with xfail

    … as suggested in code review
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    9e8e3d3 View commit details
    Browse the repository at this point in the history
  44. Add news fragment

    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    aab5899 View commit details
    Browse the repository at this point in the history
  45. Ensure build_meta don't have problems with instructions after setup()

    This is a regression test for a problem identified in:
    pypa#2970 (comment)
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    c9cf0da View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    98c8edb View commit details
    Browse the repository at this point in the history
  47. Test static metadata in pyproject.toml is not overwritten by setup.py

    These tests were initially motivated by a discussion in:
    pybind/pybind11#3711 (comment)
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    86e6a10 View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    854969d View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    e9c1a32 View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    0cc7478 View commit details
    Browse the repository at this point in the history
  51. Removed unused import

    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    298e745 View commit details
    Browse the repository at this point in the history
  52. Separate setup.cfg parsing and extract common post-processing functio…

    …ns (pypa#3065)
    
    We can split the process of interpreting configuration files into 2
    steps:
    
    1. The parsing the file contents from strings to value objects that can be
       understand by Python (for example a string with a comma separated list
       of keywords into an actual Python list of strings).
    
    2. The expansion (or post-processing) of these values according to the
       semantics setuptools assign to them (for example a configuration field
       with the file: directive should be expanded from a list of file paths to
       a single string with the contents of those files concatenated)
    
    The idea of this change is to extract the functions responsible for (2.)
    into a new module, so they can be reused between different config file
    formats.
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    b44c648 View commit details
    Browse the repository at this point in the history
  53. Add vendored deps: tomli and validate-pyproject (pypa#3066)

    Some extra dependencies can be used to support ``pyproject.toml``
    configuration. This change just adds them as vendored packages.
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    088d467 View commit details
    Browse the repository at this point in the history
  54. Add means to apply configuration from pyproject.toml (pypa#3067)

    This change targets adding a standardised project configuration format
    as initially proposed by PEP 621 (with the possibility of
    modification/evolution according to follow-up PEPs).
    
    For the configuration fields not covered by the standards, the approach
    proposed in [ini2toml] is adopted.
    
    This operation relies on vendorised external libraries `tomli` and
    `validate-pyproject`.
    
    [ini2toml]: https://ini2toml.readthedocs.io/en/latest/setuptools_pep621.html
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    2cfcf0e View commit details
    Browse the repository at this point in the history
  55. Fix variable name error

    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    96adc4f View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    1bb0021 View commit details
    Browse the repository at this point in the history
  57. Configuration menu
    Copy the full SHA
    441a1fa View commit details
    Browse the repository at this point in the history
  58. Configuration menu
    Copy the full SHA
    d3e62b1 View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    54f6180 View commit details
    Browse the repository at this point in the history
  60. Add news fragment

    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    5c334b3 View commit details
    Browse the repository at this point in the history
  61. Integrate pyproject.toml configuration into existing classes (pypa#3068)

    This change builds on top of the recently added ability to parse and
    apply configurations from TOML files to distribution objects by tapping
    into the existing mechanism for handling configuration and making these
    TOML files to be read by default.
    
    A series of deprecation warnings and tests is also added.
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    f54e2d9 View commit details
    Browse the repository at this point in the history
  62. Add some type hints to the setuptools.config subpackage (pypa#3069)

    Type hints can help to increase confidence in the code and prevent
    unexpected bugs.
    
    To typecheck the subpackage the following command can be used:
    
    ```
    mypy setuptools/config --tb --show-error-codes --show-error-context --pretty
    ```
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    dd75299 View commit details
    Browse the repository at this point in the history
  63. Adopt namespaces by default when discovering packages (pypa#3125)

    The adoption of configuration via pyprojec.toml is a perfect opportunity
    to consider namespaces by default (PEP 420) when automatically finding
    projects.
    
    In projects using `setup.cfg` or `setup.py` nothing will be changed for
    backward compatibility, but for projects including metadata in
    `pyproject.toml` (as initially proposed in PEP 621), namespaces will be
    considered by default.
    abravalheri committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    64386ba View commit details
    Browse the repository at this point in the history