Skip to content

Commit

Permalink
Merge branch 'main' into feature/origin
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Dec 3, 2023
2 parents f480907 + e886c99 commit 51b3be4
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 124 deletions.
88 changes: 25 additions & 63 deletions .github/workflows/main.yml
Expand Up @@ -6,35 +6,17 @@ permissions:
contents: read

env:
# Environment variables to support color support (jaraco/skeleton#66):
# Request colored output from CLI tools supporting it. Different tools
# interpret the value differently. For some, just being set is sufficient.
# For others, it must be a non-zero integer. For yet others, being set
# to a non-empty value is sufficient. For tox, it must be one of
# <blank>, 0, 1, false, no, off, on, true, yes. The only enabling value
# in common is "1".
# Environment variable to support color support (jaraco/skeleton#66)
FORCE_COLOR: 1
# MyPy's color enforcement (must be a non-zero number)
MYPY_FORCE_COLOR: -42
# Recognized by the `py` package, dependency of `pytest` (must be "1")
PY_COLORS: 1
# Make tox-wrapped tools see color requests
TOX_TESTENV_PASSENV: >-
FORCE_COLOR
MYPY_FORCE_COLOR
NO_COLOR
PY_COLORS
PYTEST_THEME
PYTEST_THEME_MODE

# Suppress noisy pip warnings
PIP_DISABLE_PIP_VERSION_CHECK: 'true'
PIP_NO_PYTHON_VERSION_WARNING: 'true'
PIP_NO_WARN_SCRIPT_LOCATION: 'true'

# Disable the spinner, noise in GHA; TODO(webknjaz): Fix this upstream
# Must be "1".
TOX_PARALLEL_NO_SPINNER: 1
# Ensure tests can sense settings about the environment
TOX_OVERRIDE: >-
testenv.pass_env+=GITHUB_*,FORCE_COLOR
jobs:
Expand All @@ -54,48 +36,47 @@ jobs:
platform: ubuntu-latest
- python: "3.10"
platform: ubuntu-latest
# disabled for #463
# - python: pypy3.9
# platform: ubuntu-latest
- python: pypy3.10
platform: ubuntu-latest
runs-on: ${{ matrix.platform }}
continue-on-error: ${{ matrix.python == '3.12' }}
continue-on-error: ${{ matrix.python == '3.13' }}
steps:
- uses: actions/checkout@v3
with:
# fetch all branches and tags (to get tags for versioning)
# ref actions/checkout#448
fetch-depth: 0
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
- name: Install tox
run: |
python -m pip install tox
run: python -m pip install tox
- name: Run
run: tox

docs:
collateral:
strategy:
fail-fast: false
matrix:
job: [diffcov, docs]
runs-on: ubuntu-latest
env:
TOXENV: docs
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install tox
run: |
python -m pip install tox
- name: Run
run: tox
run: python -m pip install tox
- name: Eval ${{ matrix.job }}
run: tox -e ${{ matrix.job }}

check: # This job does nothing and is only used for the branch protection
if: always()

needs:
- test
- docs
- collateral

runs-on: ubuntu-latest

Expand All @@ -104,24 +85,6 @@ jobs:
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

diffcov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install tox
run: |
python -m pip install tox
- name: Evaluate coverage
run: tox
env:
TOXENV: diffcov

release:
permissions:
Expand All @@ -132,14 +95,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install tox
run: |
python -m pip install tox
run: python -m pip install tox
- name: Run
run: tox -e release
env:
Expand Down
22 changes: 22 additions & 0 deletions NEWS.rst
@@ -1,3 +1,21 @@
v6.10.0
=======

Features
--------

- Added diagnose script. (#461)


v6.9.0
======

Features
--------

- Added EntryPoints.__repr__ (#473)


v6.8.0
======

Expand Down Expand Up @@ -131,6 +149,10 @@ v4.11.4
duplicate entry points by packages varying only by non-normalized
name are hidden.

Note (#459): This change had a backward-incompatible effect for
any installers that created metadata in the filesystem with dashes
in the package names (not replaced by underscores).

v4.11.3
=======

Expand Down
7 changes: 7 additions & 0 deletions importlib_metadata/__init__.py
Expand Up @@ -295,6 +295,13 @@ def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override]
except StopIteration:
raise KeyError(name)

def __repr__(self):
"""
Repr with classname and tuple constructor to
signal that we deviate from regular tuple behavior.
"""
return '%s(%r)' % (self.__class__.__name__, tuple(self))

def select(self, **params):
"""
Select entry points from self that match the
Expand Down
2 changes: 1 addition & 1 deletion importlib_metadata/_adapters.py
Expand Up @@ -54,7 +54,7 @@ def __iter__(self):
def __getitem__(self, item):
"""
Warn users that a ``KeyError`` can be expected when a
mising key is supplied. Ref python/importlib_metadata#371.
missing key is supplied. Ref python/importlib_metadata#371.
"""
res = super().__getitem__(item)
if res is None:
Expand Down
21 changes: 21 additions & 0 deletions importlib_metadata/diagnose.py
@@ -0,0 +1,21 @@
import sys

from . import Distribution


def inspect(path):
print("Inspecting", path)
dists = list(Distribution.discover(path=[path]))
if not dists:
return
print("Found", len(dists), "packages:", end=' ')
print(', '.join(dist.name for dist in dists))


def run():
for path in sys.path:
inspect(path)


if __name__ == '__main__':
run()
3 changes: 3 additions & 0 deletions pytest.ini
Expand Up @@ -24,4 +24,7 @@ filterwarnings=
# pypa/build#615
ignore:'encoding' argument not specified::build.env

# dateutil/dateutil#1284
ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning:dateutil.tz.tz

## end upstream
2 changes: 2 additions & 0 deletions setup.cfg
Expand Up @@ -53,6 +53,8 @@ testing =
docs =
# upstream
sphinx >= 3.5
# workaround for sphinx/sphinx-doc#11662
sphinx < 7.2.5
jaraco.packaging >= 9.3
rst.linker >= 1.9
furo
Expand Down
66 changes: 18 additions & 48 deletions tests/fixtures.py
Expand Up @@ -86,7 +86,15 @@ def setUp(self):
self.fixtures.enter_context(self.add_sys_path(self.site_dir))


class DistInfoPkg(OnSysPath, SiteDir):
class SiteBuilder(SiteDir):
def setUp(self):
super().setUp()
for cls in self.__class__.mro():
with contextlib.suppress(AttributeError):
build_files(cls.files, prefix=self.site_dir)


class DistInfoPkg(OnSysPath, SiteBuilder):
files: FilesSpec = {
"distinfo_pkg-1.0.0.dist-info": {
"METADATA": """
Expand All @@ -113,10 +121,6 @@ def main():
""",
}

def setUp(self):
super().setUp()
build_files(DistInfoPkg.files, self.site_dir)

def make_uppercase(self):
"""
Rewrite metadata with everything uppercase.
Expand Down Expand Up @@ -148,12 +152,8 @@ class DistInfoPkgEditable(DistInfoPkg):
},
}

def setUp(self):
super().setUp()
build_files(DistInfoPkgEditable.files, self.site_dir)


class DistInfoPkgWithDot(OnSysPath, SiteDir):
class DistInfoPkgWithDot(OnSysPath, SiteBuilder):
files: FilesSpec = {
"pkg_dot-1.0.0.dist-info": {
"METADATA": """
Expand All @@ -163,12 +163,8 @@ class DistInfoPkgWithDot(OnSysPath, SiteDir):
},
}

def setUp(self):
super().setUp()
build_files(DistInfoPkgWithDot.files, self.site_dir)


class DistInfoPkgWithDotLegacy(OnSysPath, SiteDir):
class DistInfoPkgWithDotLegacy(OnSysPath, SiteBuilder):
files: FilesSpec = {
"pkg.dot-1.0.0.dist-info": {
"METADATA": """
Expand All @@ -184,18 +180,12 @@ class DistInfoPkgWithDotLegacy(OnSysPath, SiteDir):
},
}

def setUp(self):
super().setUp()
build_files(DistInfoPkgWithDotLegacy.files, self.site_dir)

class DistInfoPkgOffPath(SiteBuilder):
files = DistInfoPkg.files

class DistInfoPkgOffPath(SiteDir):
def setUp(self):
super().setUp()
build_files(DistInfoPkg.files, self.site_dir)


class EggInfoPkg(OnSysPath, SiteDir):
class EggInfoPkg(OnSysPath, SiteBuilder):
files: FilesSpec = {
"egginfo_pkg.egg-info": {
"PKG-INFO": """
Expand Down Expand Up @@ -230,12 +220,8 @@ def main():
""",
}

def setUp(self):
super().setUp()
build_files(EggInfoPkg.files, prefix=self.site_dir)


class EggInfoPkgPipInstalledNoToplevel(OnSysPath, SiteDir):
class EggInfoPkgPipInstalledNoToplevel(OnSysPath, SiteBuilder):
files: FilesSpec = {
"egg_with_module_pkg.egg-info": {
"PKG-INFO": "Name: egg_with_module-pkg",
Expand Down Expand Up @@ -265,12 +251,8 @@ def main():
""",
}

def setUp(self):
super().setUp()
build_files(EggInfoPkgPipInstalledNoToplevel.files, prefix=self.site_dir)


class EggInfoPkgPipInstalledNoModules(OnSysPath, SiteDir):
class EggInfoPkgPipInstalledNoModules(OnSysPath, SiteBuilder):
files: FilesSpec = {
"egg_with_no_modules_pkg.egg-info": {
"PKG-INFO": "Name: egg_with_no_modules-pkg",
Expand All @@ -295,12 +277,8 @@ class EggInfoPkgPipInstalledNoModules(OnSysPath, SiteDir):
},
}

def setUp(self):
super().setUp()
build_files(EggInfoPkgPipInstalledNoModules.files, prefix=self.site_dir)


class EggInfoPkgSourcesFallback(OnSysPath, SiteDir):
class EggInfoPkgSourcesFallback(OnSysPath, SiteBuilder):
files: FilesSpec = {
"sources_fallback_pkg.egg-info": {
"PKG-INFO": "Name: sources_fallback-pkg",
Expand All @@ -321,12 +299,8 @@ def main():
""",
}

def setUp(self):
super().setUp()
build_files(EggInfoPkgSourcesFallback.files, prefix=self.site_dir)


class EggInfoFile(OnSysPath, SiteDir):
class EggInfoFile(OnSysPath, SiteBuilder):
files: FilesSpec = {
"egginfo_file.egg-info": """
Metadata-Version: 1.0
Expand All @@ -342,10 +316,6 @@ class EggInfoFile(OnSysPath, SiteDir):
""",
}

def setUp(self):
super().setUp()
build_files(EggInfoFile.files, prefix=self.site_dir)


# dedent all text strings before writing
orig = _path.create.registry[str]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Expand Up @@ -400,7 +400,7 @@ def test_packages_distributions_all_module_types(self):

assert not any(name.endswith('.dist-info') for name in distributions)

def test_packages_distributions_symlinked_top_level(self):
def test_packages_distributions_symlinked_top_level(self) -> None:
"""
Distribution is resolvable from a simple top-level symlink in RECORD.
See #452.
Expand Down

0 comments on commit 51b3be4

Please sign in to comment.