Skip to main content

Package Discovery

Test CodeQL Code Coverage Maintainability Dependabot PyPI - Python Version Twitter URL

Package discovery based on Setuptools.

Advantage

  1. Debug packages that Setuptools discovered
  2. Easy to filter packages to root packages only

1. Debug packages that Setuptools discovered

You can check the discovered packages by running the following Python code.

print_packages.py:

from packagediscovery import Setuptools

print(Setuptools().packages)
$ python print_packages.py
['packagediscovery']

Since Package Discovery settings of Setuptools is a bit complicated so that we may want to know what packages Setuptools are discovering now.

cf. Package Discovery and Namespace Packages - setuptools documentation

2. Easy to filter packages to root packages only

You can filter the discovered packages to only include root packages by using the root_packages property.

filter_packages.py:

from packagediscovery import Packages, Setuptools

setuptools = Setuptools()
print(f"Packages = {setuptools.packages}")
print(f"Root packages = {Packages(setuptools.packages).list_roots_only}")
$ python filter_packages.py
Packages = ['pyvelocity', 'pyvelocity.checks', 'pyvelocity.configurations', 'pyvelocity.configurations.files', 'pyvelocity.configurations.files.sections', 'pyvelocity.configurations.files.sections.pylint', 'pyvelocity.configurations.tools', 'pyvelocity.configurations.files.sections.pylint', 'pyvelocity.configurations.files.sections', 'pyvelocity.configurations.files', 'pyvelocity.checks', 'pyvelocity.configurations.tools', 'pyvelocity.configurations']
Root packages = ['pyvelocity']

Quickstart

Install the package

$ pip install packagediscovery

How do I...

Discover packages

from packagediscovery import Setuptools

setuptools = Setuptools()
print(f"Packages = {setuptools.packages}")

Discover py modules

from packagediscovery import Setuptools

setuptools = Setuptools()
print(f"Py modules = {setuptools.py_modules}")

Discover project root

from packagediscovery import Setuptools

setuptools = Setuptools()
print(f"Project root = {setuptools.project_root}")

Filter packages to root packages only

from packagediscovery import Packages, Setuptools

setuptools = Setuptools()
print(f"Packages = {setuptools.packages}")
print(f"Root packages = {Packages(setuptools.packages).list_roots_only}")

Credits

This package was created with Cookiecutter and the yukihiko-shinoda/cookiecutter-pypackage project template.

Metadata

Release files for packagediscovery 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for packagediscovery 0.3.0
File Size Uploaded
packagediscovery-0.3.0.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for packagediscovery 0.3.0
File Interpreter ABI Platform
packagediscovery-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.8 kB

Release files / packagediscovery-0.3.0.tar.gz

Download URL packagediscovery-0.3.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
58ade07927f126dc0354ac677a39178869921a81279c29193395fb9a6d0adf24
BLAKE2b-256 checksum
How to use checksums
dc44d10dae339f8949a2f5d51bc338c31ea457721710315821f22dfd46228039
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / packagediscovery-0.3.0-py3-none-any.whl

Download URL packagediscovery-0.3.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef218a2d3052309290ca66362cbc0923a0cbc42199a3b0730bd4f19b61140c05
BLAKE2b-256 checksum
How to use checksums
39add6558d90c0c953400197c2382df3f000b87220e103a8745dc4c6248cad27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page