Skip to content

Commit

Permalink
Merge branch 'main' into bump-jaraco.test-to-py.typed-version
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Oct 21, 2024
2 parents 9e51855 + 99c75c9 commit 9a1f9a6
Show file tree
Hide file tree
Showing 38 changed files with 443 additions and 183 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 75.1.0
current_version = 75.2.0
commit = True
tag = True

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:
# For help with static-typing issues, or pyright update, ping @Avasam
#
# An exact version from https://github.com/microsoft/pyright/releases or "latest"
PYRIGHT_VERSION: "1.1.377"
PYRIGHT_VERSION: "1.1.385"

# Environment variable to support color support (jaraco/skeleton#66)
FORCE_COLOR: 1
Expand Down Expand Up @@ -73,4 +73,5 @@ jobs:
uses: jakebailey/pyright-action@v2
with:
version: ${{ env.PYRIGHT_VERSION }}
python-version: ${{ matrix.python }}
extra-args: --threads
30 changes: 30 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
v75.2.0
=======

Features
--------

- Made errors when parsing ``Distribution`` data more explicit about the expected type (``tuple[str, ...] | list[str]``) -- by :user:`Avasam` (#4578)


Bugfixes
--------

- Fix a `TypeError` when a ``Distribution``'s old included attribute was a `tuple` -- by :user:`Avasam` (#4578)
- Add workaround for ``bdist_wheel --dist-info-dir`` errors
when customisation does not inherit from setuptools. (#4684)


v75.1.1
=======

Bugfixes
--------

- Re-use pre-existing ``.dist-info`` dir when creating wheels via the build backend APIs (PEP 517) and the ``metadata_directory`` argument is passed -- by :user:`pelson`. (#1825)
- Changed ``egg_info`` command to avoid adding an empty ``.egg-info`` directory
while iterating over entry-points.
This avoids triggering integration problems with ``importlib.metadata``/``importlib_metadata``
(reference: pypa/pyproject-hooks#206). (#4680)


v75.1.0
=======

Expand Down
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
# Allow linking objects on other Sphinx sites seamlessly:
intersphinx_mapping.update(
# python=('https://docs.python.org/3', None),
python=('https://docs.python.org/3.11/', None),
python=('https://docs.python.org/3.11', None),
# ^-- Python 3.11 is required because it still contains `distutils`.
# Just leaving it as `3` would imply 3.12+, but that causes an
# error with the cross references to distutils functions.
Expand Down Expand Up @@ -237,9 +237,9 @@
intersphinx_mapping.update({
'pip': ('https://pip.pypa.io/en/latest', None),
'build': ('https://build.pypa.io/en/latest', None),
'PyPUG': ('https://packaging.python.org/en/latest/', None),
'packaging': ('https://packaging.pypa.io/en/latest/', None),
'twine': ('https://twine.readthedocs.io/en/stable/', None),
'PyPUG': ('https://packaging.python.org/en/latest', None),
'packaging': ('https://packaging.pypa.io/en/latest', None),
'twine': ('https://twine.readthedocs.io/en/stable', None),
'importlib-resources': (
'https://importlib-resources.readthedocs.io/en/latest',
None,
Expand Down
96 changes: 68 additions & 28 deletions docs/userguide/datafiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Data Files Support
====================

In the Python ecosystem, the term "data files" is used in various complex scenarios
and can have nuanced meanings. For the purposes of this documentation,
we define "data files" as non-Python files that are installed alongside Python
modules and packages on the user's machine when they install a
:term:`distribution <Distribution Package>` via :term:`wheel <Wheel>`.

These files are typically intended for use at **runtime** by the package itself or
to influence the behavior of other packages or systems.

Old packaging installation methods in the Python ecosystem
have traditionally allowed installation of "data files", which
are placed in a platform-specific location. However, the most common use case
Expand All @@ -19,10 +28,11 @@ Configuration Options

.. _include-package-data:

include_package_data
--------------------
1. ``include_package_data``
---------------------------

First, you can use the ``include_package_data`` keyword.

For example, if the package tree looks like this::

project_root_directory
Expand All @@ -35,16 +45,34 @@ For example, if the package tree looks like this::
├── data1.txt
└── data2.txt

and you supply this configuration:
When **at least one** of the following conditions are met:

1. These files are included via the :ref:`MANIFEST.in <Using MANIFEST.in>` file,
like so::

include src/mypkg/*.txt
include src/mypkg/*.rst

2. They are being tracked by a revision control system such as Git, Mercurial
or SVN, **AND** you have configured an appropriate plugin such as
:pypi:`setuptools-scm` or :pypi:`setuptools-svn`.
(See the section below on :ref:`Adding Support for Revision
Control Systems` for information on how to configure such plugins.)

then all the ``.txt`` and ``.rst`` files will be included into
the source distribution.

To further include them into the ``wheels``, you can use the
``include_package_data`` keyword:

.. tab:: pyproject.toml

.. code-block:: toml
[tool.setuptools]
# ...
# By default, include-package-data is true in pyproject.toml, so you do
# NOT have to specify this line.
# By default, include-package-data is true in pyproject.toml,
# so you do NOT have to specify this line.
include-package-data = true
[tool.setuptools.packages.find]
Expand Down Expand Up @@ -76,33 +104,18 @@ and you supply this configuration:
include_package_data=True
)
then all the ``.txt`` and ``.rst`` files will be automatically installed with
your package, provided:

1. These files are included via the :ref:`MANIFEST.in <Using MANIFEST.in>` file,
like so::

include src/mypkg/*.txt
include src/mypkg/*.rst

2. OR, they are being tracked by a revision control system such as Git, Mercurial
or SVN, and you have configured an appropriate plugin such as
:pypi:`setuptools-scm` or :pypi:`setuptools-svn`.
(See the section below on :ref:`Adding Support for Revision
Control Systems` for information on how to write such plugins.)

.. note::
.. versionadded:: v61.0.0
The default value for ``tool.setuptools.include-package-data`` is ``True``
The default value for ``tool.setuptools.include-package-data`` is ``true``
when projects are configured via ``pyproject.toml``.
This behaviour differs from ``setup.cfg`` and ``setup.py``
(where ``include_package_data=False`` by default), which was not changed
(where ``include_package_data`` is ``False`` by default), which was not changed
to ensure backwards compatibility with existing projects.

.. _package-data:

package_data
------------
2. ``package_data``
-------------------

By default, ``include_package_data`` considers **all** non ``.py`` files found inside
the package directory (``src/mypkg`` in this case) as data files, and includes those that
Expand Down Expand Up @@ -172,7 +185,7 @@ file, nor require to be added by a revision control system plugin.

.. note::
If your glob patterns use paths, you *must* use a forward slash (``/``) as
the path separator, even if you are on Windows. Setuptools automatically
the path separator, even if you are on Windows. ``setuptools`` automatically
converts slashes to appropriate platform-specific separators at build time.

.. important::
Expand Down Expand Up @@ -271,8 +284,8 @@ we specify that ``data1.rst`` from ``mypkg1`` alone should be captured as well.

.. _exclude-package-data:

exclude_package_data
--------------------
3. ``exclude_package_data``
---------------------------

Sometimes, the ``include_package_data`` or ``package_data`` options alone
aren't sufficient to precisely define what files you want included. For example,
Expand Down Expand Up @@ -337,6 +350,33 @@ Any files that match these patterns will be *excluded* from installation,
even if they were listed in ``package_data`` or were included as a result of using
``include_package_data``.

.. _interplay_package_data_keywords:

Interplay between these keywords
--------------------------------

Meanwhile, to further clarify the interplay between these three keywords,
to include certain data file into the source distribution, the following
logic condition has to be met::

MANIFEST.in or (package-data and not exclude-package-data)

In plain language, the file should be either:

1. included in ``MANIFEST.in``; or

2. selected by ``package-data`` AND not excluded by ``exclude-package-data``.

To include some data file into the ``.whl``::

(not exclude-package-data) and ((include-package-data and MANIFEST.in) or package-data)

In other words, the file should not be excluded by ``exclude-package-data``
(highest priority), AND should be either:

1. selected by ``package-data``; or

2. selected by ``MANIFEST.in`` AND use ``include-package-data = true``.

Summary
-------
Expand Down Expand Up @@ -450,7 +490,7 @@ With :ref:`package-data`, the configuration might look like this:
}
)
In other words, we allow Setuptools to scan for namespace packages in the ``src`` directory,
In other words, we allow ``setuptools`` to scan for namespace packages in the ``src`` directory,
which enables the ``data`` directory to be identified, and then, we separately specify data
files for the root package ``mypkg``, and the namespace package ``data`` under the package
``mypkg``.
Expand Down
24 changes: 18 additions & 6 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
[mypy]
# CI should test for all versions, local development gets hints for oldest supported
# But our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
# python_version = 3.8
## upstream

# Is the project well-typed?
strict = False

# Early opt-in even when strict = False
warn_unused_ignores = True
warn_redundant_casts = True
# required to support namespace packages: https://github.com/python/mypy/issues/14057
enable_error_code = ignore-without-code

# Support namespace packages per https://github.com/python/mypy/issues/14057
explicit_package_bases = True

disable_error_code =
# Disable due to many false positives
overload-overlap,

## local

# CI should test for all versions, local development gets hints for oldest supported
# But our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
# python_version = 3.8

exclude = (?x)(
# Avoid scanning Python files in generated folders
^build/
Expand Down Expand Up @@ -43,20 +53,22 @@ disable_error_code = import-not-found
# - or non-stdlib distutils typings are exposed
[mypy-distutils.*]
ignore_missing_imports = True

# - wheel: does not intend on exposing a programmatic API https://github.com/pypa/wheel/pull/610#issuecomment-2081687671
[mypy-wheel.*]
ignore_missing_imports = True
# - The following are not marked as py.typed:
# - jaraco: Since mypy 1.12, the root name of the untyped namespace package gets called-out too
# - jaraco.develop: https://github.com/jaraco/jaraco.develop/issues/22
# - jaraco.envs: https://github.com/jaraco/jaraco.envs/issues/7
# - jaraco.packaging: https://github.com/jaraco/jaraco.packaging/issues/20
# - jaraco.path: https://github.com/jaraco/jaraco.path/issues/2
# - jaraco.text: https://github.com/jaraco/jaraco.text/issues/17
[mypy-jaraco.develop,jaraco.envs,jaraco.packaging.*,jaraco.path,jaraco.text]
[mypy-jaraco,jaraco.develop,jaraco.envs,jaraco.packaging.*,jaraco.path,jaraco.text]
ignore_missing_imports = True

# Even when excluding a module, import issues can show up due to following import
# https://github.com/python/mypy/issues/11936#issuecomment-1466764006
[mypy-setuptools.config._validate_pyproject.*,setuptools._distutils.*]
[mypy-setuptools.config._validate_pyproject.*,setuptools._vendor.*,setuptools._distutils.*]
follow_imports = silent
# silent => ignore errors when following imports
1 change: 1 addition & 0 deletions newsfragments/4560.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bumped declared ``platformdirs`` dependency to ``>= 4.2.2`` to help platforms lacking `ctypes` support install setuptools seamlessly -- by :user:`Avasam`
4 changes: 4 additions & 0 deletions newsfragments/4567.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Ensured methods in ``setuptools.modified`` preferably raise a consistent
``distutils.errors.DistutilsError`` type
(except in the deprecated use case of ``SETUPTOOLS_USE_DISTUTILS=stdlib``)
-- by :user:`Avasam`
1 change: 1 addition & 0 deletions newsfragments/4575.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allowed using `dict` as an ordered type in ``setuptools.dist.check_requirements`` -- by :user:`Avasam`
4 changes: 4 additions & 0 deletions newsfragments/4696.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix clashes for ``optional-dependencies`` in ``pyproject.toml`` and
``extra_requires`` in ``setup.cfg/setup.py``.
As per PEP 621, ``optional-dependencies`` has to be honoured and dynamic
behaviour is not allowed.
2 changes: 1 addition & 1 deletion pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2777,7 +2777,7 @@ def load(
if require:
# We could pass `env` and `installer` directly,
# but keeping `*args` and `**kwargs` for backwards compatibility
self.require(*args, **kwargs) # type: ignore
self.require(*args, **kwargs) # type: ignore[arg-type]
return self.resolve()

def resolve(self) -> _ResolvedEntryPoint:
Expand Down
12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ backend-path = ["."]

[project]
name = "setuptools"
version = "75.1.0"
version = "75.2.0"
authors = [
{ name = "Python Packaging Authority", email = "distutils-sig@python.org" },
]
Expand Down Expand Up @@ -56,7 +56,7 @@ test = [
"pytest-home >= 0.5",
"pytest-subprocess",

# workaround for pypa/setuptools#4333
# workaround for pypa/pyproject-hooks#206
"pyproject-hooks!=1.1",

"jaraco.test>=5.5", # py.typed
Expand Down Expand Up @@ -99,7 +99,7 @@ core = [
"wheel>=0.43.0",

# pkg_resources
"platformdirs >= 2.6.2",
"platformdirs >= 4.2.2", # Made ctypes optional (see #4461)

# for distutils
"jaraco.collections",
Expand Down Expand Up @@ -136,7 +136,7 @@ type = [
# pin mypy version so a new version doesn't suddenly cause the CI to fail,
# until types-setuptools is removed from typeshed.
# For help with static-typing issues, or mypy update, ping @Avasam
"mypy==1.11.*",
"mypy==1.12.*",
# Typing fixes in version newer than we require at runtime
"importlib_metadata>=7.0.2; python_version < '3.10'",
# Imported unconditionally in tools/finalize.py
Expand Down Expand Up @@ -216,7 +216,3 @@ formats = "zip"


[tool.setuptools_scm]


[tool.pytest-enabler.mypy]
# Disabled due to jaraco/skeleton#143
5 changes: 3 additions & 2 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ extend-select = [

# local
"ANN2", # missing-return-type-*
"FA", # flake8-future-annotations
"F404", # late-future-import
"FA", # flake8-future-annotations
"I", # isort
"PYI", # flake8-pyi
"TRY", # tryceratops
"UP", # pyupgrade
"TRY",
"YTT", # flake8-2020
]
ignore = [
"TRY003", # raise-vanilla-args, avoid multitude of exception classes
"TRY301", # raise-within-try, it's handy
"UP015", # redundant-open-modes, explicit is preferred
"UP027", # unpacked-list-comprehension, is actually slower for cases relevant to unpacking, set for deprecation: https://github.com/astral-sh/ruff/issues/12754
"UP030", # temporarily disabled
"UP031", # temporarily disabled
"UP032", # temporarily disabled
Expand Down
Loading

0 comments on commit 9a1f9a6

Please sign in to comment.