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

v2.0 Rewrite #30

Draft
wants to merge 132 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
d54812e
Type-annotate src/
jwodder Oct 13, 2021
eb2be5e
Type-annotate test/
jwodder Oct 13, 2021
69444a9
Add type-checking config
jwodder Oct 13, 2021
bcc315c
Fix typing errors
jwodder Oct 13, 2021
ff92235
Fix
jwodder Oct 13, 2021
8385681
Update CHANGELOG
jwodder Oct 13, 2021
948a28c
Update .gitignore
jwodder Oct 13, 2021
7cf2ea6
Remove SCHEMA
jwodder Oct 13, 2021
ac72917
Stop re-exporting wheel-filename
jwodder Oct 13, 2021
065b20f
Restructure records
jwodder Oct 13, 2021
1b4a1ed
Adjustments
jwodder Oct 13, 2021
df156bf
Make open_dist_info_file() capable of opening files in text mode
jwodder Oct 13, 2021
f7485c2
Define exception classes with attrs
jwodder Oct 13, 2021
85db441
Detect negative file sizes while parsing RECORD
jwodder Oct 13, 2021
2c597f7
Give Record a `dump()` method
jwodder Oct 13, 2021
6ea3b55
Restructuring of Digest
jwodder Oct 14, 2021
d2b8b88
Better name
jwodder Oct 14, 2021
070c2dd
Set `auto_exc` on attrs-ified exception classes
jwodder Oct 14, 2021
35786ff
Eliminate "file" property, and other tweaks
jwodder Oct 14, 2021
fc88dc9
Redo record type
jwodder Oct 14, 2021
f1a3a49
Eliminate the specific subclasses of MissingDistInfoFileError
jwodder Oct 14, 2021
646feed
Use attrs' "next generation" API
jwodder Oct 14, 2021
2a896a7
Give FileProvider an open() method
jwodder Oct 14, 2021
6a09320
Give DistInfoProvider an `entry_points` property
jwodder Oct 14, 2021
2561758
Add an option for disabling digest verification
jwodder Oct 14, 2021
a1fafbc
Use entry-points-txt v0.2
jwodder Oct 14, 2021
bbb2fca
Detect NullEntryError's while parsing the RECORD
jwodder Oct 14, 2021
0a8319a
Redo how digest_file() reports filesize
jwodder Oct 14, 2021
93b7110
Added an intermediate BackedDistInfo class
jwodder Oct 15, 2021
e2688f9
Use BackedDistInfo
jwodder Oct 15, 2021
35844e6
`dist_info` → `dist_info_dirname`
jwodder Oct 15, 2021
5364f53
Give `WheelFile.from_path()` a `strict` argument
jwodder Oct 15, 2021
f9bfe34
Make WheelFile.closed() idempotent
jwodder Oct 15, 2021
34a5941
MissingFileError → NoSuchFileError
jwodder Oct 15, 2021
b5acd7f
Reorganize exception hierarchy
jwodder Oct 15, 2021
92d84d0
Can't believe I forgot to do this
jwodder Oct 15, 2021
f669ec5
Set up Sphinx docs
jwodder Oct 15, 2021
5e03e02
for_json() function
jwodder Oct 15, 2021
6e3dfbc
Add exceptions inheritance diagram to docs
jwodder Oct 15, 2021
8e37853
Reorganize filename properties in inspection results
jwodder Oct 15, 2021
3ff97ea
attr.ib → attr.field
jwodder Oct 15, 2021
cf92c4f
attrs-based mapping classes
jwodder Oct 15, 2021
ffa3be2
Redid RECORD again
jwodder Oct 15, 2021
5b31488
Give WheelFile a `data_dirname` property
jwodder Oct 15, 2021
b327e5a
Give FileProvider a `has_file()` method
jwodder Oct 15, 2021
940c145
Compatibility with older Pythons
jwodder Oct 15, 2021
e954df3
get_file_hash() → get_file_digest()
jwodder Oct 15, 2021
20b37fc
Typo
jwodder Oct 15, 2021
bf3f405
Let FileProvider.open() take RecordNodes
jwodder Oct 15, 2021
403b6bc
Support creating a WheelFile from an open binary filehandle
jwodder Oct 15, 2021
9539907
Superfluous
jwodder Oct 15, 2021
dd9abae
Fix rST
jwodder Oct 15, 2021
3819b54
Eliminate DIST_INFO_SCHEMA
jwodder Oct 15, 2021
bf52dcc
Sync changelogs
jwodder Oct 15, 2021
3ea380e
Fix some Sphinx bits
jwodder Oct 15, 2021
0581b22
Minor fixes
jwodder Oct 16, 2021
a2207c2
PathLike ABC
jwodder Oct 15, 2021
10f6ffb
Make RecordNode (now RecordPath) PathLike
jwodder Oct 16, 2021
129ccd0
Let's not do that.
jwodder Oct 16, 2021
765d235
validate() method; DistInfoDir.from_path()
jwodder Oct 16, 2021
d068d4c
Make `strict` default to True
jwodder Oct 16, 2021
8108e81
list_top_level_dirs()
jwodder Oct 16, 2021
9dc80b5
Move some WheelFile attributes to BackedDistInfo
jwodder Oct 16, 2021
3ee69e9
Define some `__repr__`'s
jwodder Oct 16, 2021
16d8239
PathLike → Path
jwodder Oct 16, 2021
1b5b36a
More accurate --help string
jwodder Oct 16, 2021
1e566ae
Explain
jwodder Oct 16, 2021
da7c887
Factor out some logic
jwodder Oct 16, 2021
3e8cc6c
Move & rename WheelFile.filename
jwodder Oct 16, 2021
f62562c
Move individual file verification to BackedDistInfo
jwodder Oct 16, 2021
0ba80b9
get_path_type(); NoSuchFileError → NoSuchPathError
jwodder Oct 16, 2021
af3644c
is_record_file()
jwodder Oct 16, 2021
bdd94e0
Tweak some strings
jwodder Oct 16, 2021
f8900cc
PathType.UNKNOWN → PathType.OTHER
jwodder Oct 16, 2021
31343fa
Not sure why this worked in 3.8 but not 3.7
jwodder Oct 16, 2021
8164966
Detect path type mismatches between RECORD and backing
jwodder Oct 16, 2021
5023f79
MissingFileError → MissingPathError
jwodder Oct 16, 2021
475e468
Make get_file_digest() concrete
jwodder Oct 16, 2021
067531e
ExtraFileError → UnrecordedPathError
jwodder Oct 16, 2021
ae5f78f
RecordPath.path_type
jwodder Oct 16, 2021
a9c037e
Show error attributes inherited from parents
jwodder Oct 16, 2021
aa1cc5b
WheelFile.from_zipfile()
jwodder Oct 16, 2021
83ecab7
verify_record() → verify()
jwodder Oct 16, 2021
0b9ae0c
Give Record `dist_info_dirname` and `data_dirname` properties
jwodder Oct 16, 2021
070b2b2
Convert DistInfoDir.path in from_path()
jwodder Oct 16, 2021
f848e6d
Use backports.cached-property for its type annotations
jwodder Oct 16, 2021
53999ec
Special-case Record.__getitem__
jwodder Oct 17, 2021
8bf357d
Properties for setuptools egg files
jwodder Oct 17, 2021
3855a5b
Separate validation & verification errors
jwodder Oct 17, 2021
e225396
Only use MissingDistInfoFileError for required files
jwodder Oct 17, 2021
47f895a
Make RecordPath.get_subpath() handle . and ..
jwodder Oct 17, 2021
9005576
Allow RECORD signatures to be listed in the RECORD without sizes & di…
jwodder Oct 17, 2021
86d56fd
Instead of toggling the whole of file verification, only toggle diges…
jwodder Oct 17, 2021
f145e13
Change from_zipfile()'s wheel_name argument to a path
jwodder Oct 17, 2021
6a544c7
Give the open*() methods "mode" arguments
jwodder Oct 17, 2021
f9a3193
Adjust error JSONification
jwodder Oct 17, 2021
698d6ce
Give FileProvider verify_record() and verify_file()
jwodder Oct 17, 2021
e4be246
Error if a file operation is attempted on a directory
jwodder Oct 17, 2021
abb7966
Properly error when opening a directory RecordPath
jwodder Oct 17, 2021
284bad7
Fix
jwodder Oct 17, 2021
c867736
Catch a potential error
jwodder Oct 18, 2021
db93f55
Once again, directories in wheels don't need to be listed in RECORD.
jwodder Oct 18, 2021
03d9c26
"Core Classes" sectioning
jwodder Oct 18, 2021
c4b4960
Test (and fix) RecordPaths
jwodder Oct 18, 2021
e8aaff4
Path-like API for filetree navigation
jwodder Oct 18, 2021
0cd342e
I'm going to assume this is an issue with backports.cached-property.
jwodder Oct 18, 2021
a76950d
Export more types and list them in the docs
jwodder Oct 18, 2021
22587b7
Test FileData digests
jwodder Oct 18, 2021
22a7a54
Remove dead code
jwodder Oct 18, 2021
55b48b0
Slightly more test coverage
jwodder Oct 18, 2021
1de1bb2
Merge a couple small files
jwodder Oct 19, 2021
55af382
Comment out an unused bit
jwodder Oct 19, 2021
93bc01a
Merge WheelFile.from_path() into from_file()
jwodder Oct 19, 2021
4f45c56
Add an UnpackedWheelDir class
jwodder Oct 19, 2021
700c011
Assert that iterdir() raises an error immediately
jwodder Oct 28, 2021
aec1687
Update Sphinx version
jwodder Nov 10, 2021
05fd3c8
@abstractproperty → @property @abstractmethod
jwodder Jan 12, 2022
df13181
Docs stuff
jwodder Jan 25, 2022
8561cf4
Expand git.io link in comment
jwodder Apr 26, 2022
d34b2b9
Update docs requirements
jwodder Jun 4, 2022
ff15e79
Run latest black
jwodder Jun 4, 2022
19ab6f6
Use iterpath 0.4.0's return_relative
jwodder Jun 26, 2022
96a7b8f
Use hashlib.new() instead of getattr(hashlib, ...)
jwodder Jun 29, 2022
6ac61b1
Use more future annotations
jwodder Jun 29, 2022
5ddd477
Silence a mypy error
jwodder Oct 12, 2022
2f4e48d
Boilerplate updates
jwodder Oct 16, 2022
24f4f3f
Spelling
jwodder Oct 26, 2022
8efce2b
flake8-bugbear update
jwodder Oct 28, 2022
79d8691
Update headerparser version
jwodder Oct 4, 2023
b554968
Update Sphinx version
jwodder Oct 4, 2023
262886a
Set `ignore_missing_imports = False`
jwodder Oct 9, 2023
80c6d31
Properly fill in __exit__ args
jwodder Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
include:
- python-version: '3.7'
toxenv: lint
- python-version: '3.7'
toxenv: typing
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
*.egg-info/
*.pyc
.cache/
.coverage
.coverage*
.eggs/
.mypy_cache/
.nox/
.pytest_cache/
.tox/
__pycache__/
build/
dist/
docs/.doctrees/
docs/_build/
pip-wheel-metadata/
venv/
36 changes: 34 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
In Development
--------------
v2.0.0 (in development)
-----------------------
- Dropped support for Python 3.6
- Support Python 3.11 and 3.12
- Moved to wheelodex organization
- Added type annotations
- Removed the old `SCHEMA` alias for `WHEEL_SCHEMA` (deprecated in v1.6.0)
- Removed the re-export of `ParsedWheelFilename` and `parse_wheel_filename()`
from `wheel-filename` (deprecated in v1.5.0)
- Digest algorithm names in `RECORD` files are now converted to lowercase
during parsing
- Schema changes:
- `RECORD`s are now represented by an object that maps each file path to
either `null` or a subobject with "algorithm", "digest", and "size"
properties
- The `.file` property in wheel inspection results (containing the file's
size and digest) has been removed
- The filename component properties have been organized into a
`"wheel_name"` subobject, and many of them have been renamed
- `DIST_INFO_SCHEMA` has been eliminated; `WHEEL_SCHEMA` is now used for
all inspection results
- The `dependency_links`, `entry_points`, `namespace_packages`,
`top_level`, and `zip_safe` properties of the `dist_info` object are now
`null` instead of absent if the respective files are absent from the
`*.dist-info` directory.
- `.validation_error.str` has been renamed to "message"
- `.validation_error` now contains an "args" field giving type-specific
properties
- `RECORD` entries with negative sizes are now detected & errored on earlier
- Gave `inspect_wheel()` a `digest_files` option for controlling verification
of files' digests
- Gave the CLI command a `--digest-files`/`--no-digest-files` option for
controlling verification of files' digests
- `RECORD` parsing now detects & errors when it encounters a file path that is
also a parent path of another entry
- Path type mismatches between the `RECORD` and the wheel now cause
verification to fail


v1.7.1 (2022-04-08)
Expand Down
17 changes: 4 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

``wheel-inspect`` examines Python wheel files & ``*.dist-info`` directories and
outputs various information about their contents as JSON-serializable objects.
It can be invoked in Python code as::
It can be invoked in Python code as:

.. code:: python

from wheel_inspect import inspect_wheel

Expand Down Expand Up @@ -291,10 +293,7 @@ API

``wheel_inspect.WHEEL_SCHEMA``
A `JSON Schema <http://json-schema.org>`_ for the structure returned by
``inspect_wheel()``. This value was previously exported under the name
"``SCHEMA``"; the old name continues to be available for backwards
compatibility, but it will go away in the future and should not be used in
new code.
``inspect_wheel()``.

``wheel_inspect.inspect_dist_info_dir(dirpath)``
Treat ``dirpath`` as a ``*.dist-info`` directory and inspect just it & its
Expand All @@ -305,14 +304,6 @@ API
Inspect the wheel file at the given ``path``. The structure of the return
value is described by ``WHEEL_SCHEMA``.

Previous versions of ``wheel-inspect`` provided a ``parse_wheel_filename()``
function. As of version 1.5.0, that feature has been split off into its own
package, `wheel-filename <https://github.com/jwodder/wheel-filename>`_.
``wheel-inspect`` continues to re-export this function in order to maintain API
compatibility with earlier versions, but this will change in the future. Code
that imports ``parse_wheel_filename()`` from ``wheel-inspect`` should be
updated to use ``wheel-filename`` instead.


Command
=======
Expand Down
143 changes: 143 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
.. currentmodule:: wheel_inspect

Changelog
=========

v2.0.0 (in development)
-----------------------
- Dropped support for Python 3.6
- Support Python 3.11 and 3.12
- Moved to wheelodex organization
- Added type annotations
- Removed the old ``SCHEMA`` alias for `~wheel_inspect.schema.WHEEL_SCHEMA`
(deprecated in v1.6.0)
- Removed the re-export of ``ParsedWheelFilename`` and
``parse_wheel_filename()`` from ``wheel-filename`` (deprecated in v1.5.0)
- Digest algorithm names in :file:`RECORD` files are now converted to lowercase
during parsing
- Schema changes:

- :file:`RECORD`\s are now represented by an object that maps each file path
to either ``null`` or a subobject with "algorithm", "digest", and "size"
properties
- The ``.file`` property in wheel inspection results (containing the file's
size and digest) has been removed
- The filename component properties have been organized into a
``"wheel_name"`` subobject, and many of them have been renamed
- ``DIST_INFO_SCHEMA`` has been eliminated;
`~wheel_inspect.schema.WHEEL_SCHEMA` is now used for all inspection results
- The ``dependency_links``, ``entry_points``, ``namespace_packages``,
``top_level``, and ``zip_safe`` properties of the ``dist_info`` object are
now ``null`` instead of absent if the respective files are absent from the
:file:`*.dist-info` directory.
- ``.validation_error.str`` has been renamed to "message"
- ``.validation_error`` now contains an "args" field giving type-specific
properties

- :file:`RECORD` entries with negative sizes are now detected & errored on
earlier
- Gave `inspect_wheel()` a ``digest_files`` option for controlling verification
of files' digests
- Gave the CLI command a :option:`wheel2json
--digest-files`/:option:`wheel2json --no-digest-files` option for controlling
verification of files' digests
- :file:`RECORD` parsing now detects & errors when it encounters a file path
that is also a parent path of another entry
- Path type mismatches between the :file:`RECORD` and the wheel now cause
verification to fail


v1.7.1 (2022-04-08)
-------------------
- Support Python 3.10
- Remove the upper bound on the ``readme_renderer`` dependency


v1.7.0 (2020-11-07)
-------------------
- When verifying a :file:`RECORD`, directory entries listed therein are now
checked for existence.
- Remove dependency on ``pkg_resources``
- Dropped support for Python 3.5
- Support Python 3.9
- Drop ``read_version`` build dependency
- Support wheels whose filenames and :file:`*.dist-info` directories use
different casings/spellings for the project name and/or version
- Better validation errors for wheels with missing or improper
:file:`*.dist_info` directories


v1.6.0 (2020-05-01)
-------------------
- Added an `inspect_dist_info_dir()` function for inspecting bare, unpacked
:file:`*.dist-info` directories
- Added a ``DIST_INFO_SCHEMA`` schema describing the return value of
`inspect_dist_info_dir()`
- Renamed ``SCHEMA`` to `~wheel_inspect.schema.WHEEL_SCHEMA`; the value remains
available under the old name for backwards compatibility
- The :command:`wheel2json` command now accepts directory arguments and
inspects them with `inspect_dist_info_dir()`


v1.5.0 (2020-04-21)
-------------------
- **Bugfix**: Now *actually* discard *all* empty keywords
- Split off the wheel filename processing code into its own package,
`wheel-filename <https://github.com/jwodder/wheel-filename>`_. Wheel-Inspect
currently re-exports ``ParsedWheelFilename`` and ``parse_wheel_filename()``
from this library in order to maintain API compatibility with earlier
versions, but this may change in the future.
- Adjusted the schema to indicate that ``.dist_info.metadata.description`` may
be ``null``
- Binary extension modules and modules located in ``*.data/{purelib,platlib}``
are now included in ``.derived.modules``


v1.4.1 (2020-03-12)
-------------------
- Drop support for Python 3.4
- Update ``property-manager`` dependency, thereby eliminating a
DeprecationWarning


v1.4.0 (2020-01-25)
-------------------
- When splitting apart comma-separated keywords, trim whitespace and discard
any keywords that are empty or all-whitespace
- Support Python 3.8


v1.3.0 (2019-05-09)
-------------------
- Upgraded ``wheel_inspect.SCHEMA`` from JSON Schema draft 4 to draft 7
- Don't require directory entries in wheels to be listed in :file:`RECORD`


v1.2.1 (2019-04-20)
-------------------
- Include :file:`pyproject.toml` in :file:`MANIFEST.in`, thereby making it
possible to build from sdist


v1.2.0 (2019-04-20)
-------------------
- ``.derived.keywords`` is now sorted and duplicate-free


v1.1.0 (2018-10-28)
-------------------
- ``"buildver"`` is now `None`/``null`` instead of the empty string when there
is no build tag in the wheel's filename
- Added a ``parse_wheel_filename()`` function for parsing a wheel filename into
its components
- Validation of :file:`RECORD` files is now done directly by ``wheel-inspect``
instead of with ``distlib`` in order to achieve more descriptive error
messages


v1.0.0 (2018-10-12)
-------------------
Initial release

This project's code was previously part of `Wheelodex
<https://github.com/jwodder/wheelodex>`_.
40 changes: 40 additions & 0 deletions docs/classes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. currentmodule:: wheel_inspect

Core Classes
============

ABCs
----

.. autosummary::
:nosignatures:

DistInfoProvider
FileProvider
BackedDistInfo

.. autoclass:: DistInfoProvider

.. autoclass:: FileProvider

.. autoclass:: BackedDistInfo
:show-inheritance:

Concrete Classes
----------------

.. autosummary::
:nosignatures:

WheelFile
UnpackedWheelDir
DistInfoDir

.. autoclass:: WheelFile()
:show-inheritance:

.. autoclass:: UnpackedWheelDir()
:show-inheritance:

.. autoclass:: DistInfoDir()
:show-inheritance:
30 changes: 30 additions & 0 deletions docs/command.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. index:: wheel2json (command)

Command-Line Program
====================

::

wheel2json [<option>] [<path> ...]

``wheel-inspect`` provides a :command:`wheel2json` command (also accessible as
``python -m wheel_inspect``) that can be used to inspect wheels and
:file:`*.dist-info` directories from the command line. Each path passed to the
command is inspected separately (treated as a :file:`*.dist-info` directory if
it is a directory, treated as a wheel file otherwise), and the resulting data
is output as a pretty-printed JSON object. (Note that this results in a stream
of JSON objects with no separation when multiple paths are given.)

Options
-------

.. program:: wheel2json

.. option:: --digest-files

Verify the digests of files listed inside wheels' :file:`RECORD`\s. This
is the default.

.. option:: --no-digest-files

Do not verify file digests
46 changes: 46 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from wheel_inspect import __version__

project = "wheel-inspect"
author = "John Thorvald Wodder II"
copyright = "2017-2021 John Thorvald Wodder II" # noqa: A001

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx_copybutton",
]

autodoc_default_options = {
"members": True,
"undoc-members": True,
}
autodoc_typehints_format = "fully-qualified"

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}

exclude_patterns = ["_build"]
source_suffix = ".rst"
source_encoding = "utf-8"
master_doc = "index"
version = __version__
release = __version__
today_fmt = "%Y %b %d"
default_role = "py:obj"
pygments_style = "sphinx"
# nitpicky = True

html_theme = "furo"
html_last_updated_fmt = "%Y %b %d"
html_show_sourcelink = True
html_show_sphinx = True
html_show_copyright = True

copybutton_prompt_text = r">>> |\.\.\. |\$ "
copybutton_prompt_is_regexp = True

# inheritance_graph_attrs = {"rankdir": "TB"}
11 changes: 11 additions & 0 deletions docs/errors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Exceptions
==========

.. inheritance-diagram:: wheel_inspect.errors
:caption: Exception Hierarchy
:parts: 1

.. automodule:: wheel_inspect.errors
:member-order: bysource
:show-inheritance:
:inherited-members: Exception
Loading