Skip to main content

smooth_import

PyPI version Python versions License: MIT

An enhanced package importer for Python that handles complex import patterns including:

  • ✅ Relative imports without __init__.py
  • ✅ Mixed package and standalone structures
  • ✅ Dynamic import resolution
  • ✅ Automatic import rewriting
  • ✅ Circular dependency handling

Installation

pip install smooth_import

Quick Start

from smooth_import import resolve_import

# Resolve an import from a specific file
my_function = resolve_import("path/to/my_module.py", "my_function")

Features

  • Smart Import Resolution: Automatically handles complex import patterns
  • No init.py Required: Works with modern Python projects that don't use __init__.py files
  • Mixed Package Support: Handles both package and standalone module structures
  • Dynamic Import Rewriting: Automatically rewrites imports to work correctly
  • Circular Dependency Handling: Safely handles circular import scenarios

Usage Examples

Basic Usage

from smooth_import import resolve_import, PackageImporter

# Using the convenience function
my_function = resolve_import("path/to/my_module.py", "my_function")

# Using the PackageImporter class directly
importer = PackageImporter(verbose=True)
result = importer.resolve_import("path/to/my_module.py", "my_function")

Advanced Usage

from smooth_import import PackageImporter

# Create an importer with custom settings
importer = PackageImporter(verbose=False)

# Resolve imports from complex project structures
try:
    my_class = importer.resolve_import("src/myproject/modules/utils.py", "MyClass")
    print(f"Successfully imported: {my_class}")
except ImportError as e:
    print(f"Import failed: {e}")

Development

This project uses modern Python packaging with pyproject.toml. The redundant setup.py has been removed for cleaner project structure.

Building and Publishing

  1. Install build tools:

    pip install build twine
    
  2. Build the package:

    python -m build
    
  3. Test the build locally:

    pip install dist/smooth_import-1.0.0.tar.gz
    
  4. Upload to PyPI (replace with your PyPI credentials):

    twine upload dist/*
    

Development Setup

# Clone the repository
git clone https://github.com/sawradip/smooth_import.git
cd smooth_import

# Install in development mode
pip install -e .

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black .

# Lint code
flake8

Requirements

  • Python 3.7+
  • No external dependencies (uses only standard library)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If you encounter any issues or have questions:

  1. Check the documentation
  2. Open an issue
  3. Review the examples directory

Changelog

See CHANGELOG.md for a list of changes and version history.

Metadata

Release files for smooth-import 1.0.1

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

Source distribution (sdist)

Source distribution for smooth-import 1.0.1
File Size Uploaded Provenance Actions
smooth_import-1.0.1.tar.gz 10.5 kB Without provenance Details for smooth_import-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smooth-import 1.0.1
File Interpreter ABI Platform Actions
smooth_import-1.0.1-py3-none-any.whl Python 3 none any Details for smooth_import-1.0.1-py3-none-any.whl

Total release size: 19.3 kB

Release files / smooth_import-1.0.1.tar.gz

Download URL smooth_import-1.0.1.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2a76448652f2e2f2ae1e83a8dc231c416cb0e62abd77f3e01e5a3adebd6f5bbd
BLAKE2b-256 checksum
How to use checksums
f11c032e9c26085402eae20c619e1fad8ba2e667c84bd7597ef8ae92926ba2ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / smooth_import-1.0.1-py3-none-any.whl

Download URL smooth_import-1.0.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4fd455232c6f6c31982e9ec8df5db25984821fde91b12e534bc626d42a7fb6e0
BLAKE2b-256 checksum
How to use checksums
ab0b1e1edf69e0ca38bab1b1a5e88c4179024d9c4fee6922ad730806c93c0a1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Security for smooth-import 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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