From c255b01541e22c06aed6da040770b85bbecfd78b Mon Sep 17 00:00:00 2001 From: chrysle Date: Wed, 29 Nov 2023 16:07:14 +0100 Subject: [PATCH] Migrate examples to `src-layout` --- native/pkg_a/setup.py | 5 +++-- native/pkg_a/{ => src}/example_pkg/a/__init__.py | 0 native/pkg_b/setup.py | 5 +++-- native/pkg_b/{ => src}/example_pkg/b/__init__.py | 0 pkg_resources/pkg_a/setup.py | 3 ++- pkg_resources/pkg_a/{ => src}/example_pkg/__init__.py | 0 pkg_resources/pkg_a/{ => src}/example_pkg/a/__init__.py | 0 pkg_resources/pkg_b/setup.py | 3 ++- pkg_resources/pkg_b/{ => src}/example_pkg/__init__.py | 0 pkg_resources/pkg_b/{ => src}/example_pkg/b/__init__.py | 0 pkgutil/README.md | 2 +- pkgutil/pkg_a/setup.py | 3 ++- pkgutil/pkg_a/{ => src}/example_pkg/__init__.py | 0 pkgutil/pkg_a/{ => src}/example_pkg/a/__init__.py | 0 pkgutil/pkg_b/setup.py | 3 ++- pkgutil/pkg_b/{ => src}/example_pkg/__init__.py | 0 pkgutil/pkg_b/{ => src}/example_pkg/b/__init__.py | 0 17 files changed, 15 insertions(+), 9 deletions(-) rename native/pkg_a/{ => src}/example_pkg/a/__init__.py (100%) rename native/pkg_b/{ => src}/example_pkg/b/__init__.py (100%) rename pkg_resources/pkg_a/{ => src}/example_pkg/__init__.py (100%) rename pkg_resources/pkg_a/{ => src}/example_pkg/a/__init__.py (100%) rename pkg_resources/pkg_b/{ => src}/example_pkg/__init__.py (100%) rename pkg_resources/pkg_b/{ => src}/example_pkg/b/__init__.py (100%) rename pkgutil/pkg_a/{ => src}/example_pkg/__init__.py (100%) rename pkgutil/pkg_a/{ => src}/example_pkg/a/__init__.py (100%) rename pkgutil/pkg_b/{ => src}/example_pkg/__init__.py (100%) rename pkgutil/pkg_b/{ => src}/example_pkg/b/__init__.py (100%) diff --git a/native/pkg_a/setup.py b/native/pkg_a/setup.py index 8021a7a..ed4090f 100644 --- a/native/pkg_a/setup.py +++ b/native/pkg_a/setup.py @@ -27,7 +27,8 @@ author_email='jonwayne@google.com', license='Apache Software License', - - packages=['example_pkg.a'], + # This example uses automatic discovery. You can also implement custom discovery like this: + # packages=find_namespace_packages(where='src', include=['example_pkg.a']), + # package_dir={'': 'src'}, zip_safe=False, ) diff --git a/native/pkg_a/example_pkg/a/__init__.py b/native/pkg_a/src/example_pkg/a/__init__.py similarity index 100% rename from native/pkg_a/example_pkg/a/__init__.py rename to native/pkg_a/src/example_pkg/a/__init__.py diff --git a/native/pkg_b/setup.py b/native/pkg_b/setup.py index 872122a..5072cff 100644 --- a/native/pkg_b/setup.py +++ b/native/pkg_b/setup.py @@ -27,7 +27,8 @@ author_email='jonwayne@google.com', license='Apache Software License', - - packages=['example_pkg.b'], + # This example uses automatic discovery. You can also implement custom discovery like this: + # packages=find_namespace_packages(where='src', include=['example_pkg.b']), + # package_dir={'': 'src'}, zip_safe=False, ) diff --git a/native/pkg_b/example_pkg/b/__init__.py b/native/pkg_b/src/example_pkg/b/__init__.py similarity index 100% rename from native/pkg_b/example_pkg/b/__init__.py rename to native/pkg_b/src/example_pkg/b/__init__.py diff --git a/pkg_resources/pkg_a/setup.py b/pkg_resources/pkg_a/setup.py index 1cd580c..b7c68a5 100644 --- a/pkg_resources/pkg_a/setup.py +++ b/pkg_resources/pkg_a/setup.py @@ -28,7 +28,8 @@ license='Apache Software License', - packages=find_packages(), + packages=find_packages(where='src'), namespace_packages=['example_pkg'], + package_dir={'': 'src'}, zip_safe=False, ) diff --git a/pkg_resources/pkg_a/example_pkg/__init__.py b/pkg_resources/pkg_a/src/example_pkg/__init__.py similarity index 100% rename from pkg_resources/pkg_a/example_pkg/__init__.py rename to pkg_resources/pkg_a/src/example_pkg/__init__.py diff --git a/pkg_resources/pkg_a/example_pkg/a/__init__.py b/pkg_resources/pkg_a/src/example_pkg/a/__init__.py similarity index 100% rename from pkg_resources/pkg_a/example_pkg/a/__init__.py rename to pkg_resources/pkg_a/src/example_pkg/a/__init__.py diff --git a/pkg_resources/pkg_b/setup.py b/pkg_resources/pkg_b/setup.py index 03444e1..c163459 100644 --- a/pkg_resources/pkg_b/setup.py +++ b/pkg_resources/pkg_b/setup.py @@ -28,7 +28,8 @@ license='Apache Software License', - packages=find_packages(), + packages=find_packages(where='src'), namespace_packages=['example_pkg'], + package_dir={'': 'src'}, zip_safe=False, ) diff --git a/pkg_resources/pkg_b/example_pkg/__init__.py b/pkg_resources/pkg_b/src/example_pkg/__init__.py similarity index 100% rename from pkg_resources/pkg_b/example_pkg/__init__.py rename to pkg_resources/pkg_b/src/example_pkg/__init__.py diff --git a/pkg_resources/pkg_b/example_pkg/b/__init__.py b/pkg_resources/pkg_b/src/example_pkg/b/__init__.py similarity index 100% rename from pkg_resources/pkg_b/example_pkg/b/__init__.py rename to pkg_resources/pkg_b/src/example_pkg/b/__init__.py diff --git a/pkgutil/README.md b/pkgutil/README.md index 426525b..ff092f9 100644 --- a/pkgutil/README.md +++ b/pkgutil/README.md @@ -61,5 +61,5 @@ cd pkgutil/pkg_a pip install . # Test the install by printing the `name` from the `__init__.py` file. -python -c "import example_pkg.a as a; print a.name" +python -c "import example_pkg.a as a; print(a.name)" ``` diff --git a/pkgutil/pkg_a/setup.py b/pkgutil/pkg_a/setup.py index 27b9352..e846c84 100644 --- a/pkgutil/pkg_a/setup.py +++ b/pkgutil/pkg_a/setup.py @@ -28,6 +28,7 @@ license='Apache Software License', - packages=find_packages(), + packages=find_packages(where='src'), + package_dir={'': 'src'}, zip_safe=False, ) diff --git a/pkgutil/pkg_a/example_pkg/__init__.py b/pkgutil/pkg_a/src/example_pkg/__init__.py similarity index 100% rename from pkgutil/pkg_a/example_pkg/__init__.py rename to pkgutil/pkg_a/src/example_pkg/__init__.py diff --git a/pkgutil/pkg_a/example_pkg/a/__init__.py b/pkgutil/pkg_a/src/example_pkg/a/__init__.py similarity index 100% rename from pkgutil/pkg_a/example_pkg/a/__init__.py rename to pkgutil/pkg_a/src/example_pkg/a/__init__.py diff --git a/pkgutil/pkg_b/setup.py b/pkgutil/pkg_b/setup.py index 88d3397..3340df5 100644 --- a/pkgutil/pkg_b/setup.py +++ b/pkgutil/pkg_b/setup.py @@ -28,6 +28,7 @@ license='Apache Software License', - packages=find_packages(), + packages=find_packages(where='src'), + package_dir={'': 'src'}, zip_safe=False, ) diff --git a/pkgutil/pkg_b/example_pkg/__init__.py b/pkgutil/pkg_b/src/example_pkg/__init__.py similarity index 100% rename from pkgutil/pkg_b/example_pkg/__init__.py rename to pkgutil/pkg_b/src/example_pkg/__init__.py diff --git a/pkgutil/pkg_b/example_pkg/b/__init__.py b/pkgutil/pkg_b/src/example_pkg/b/__init__.py similarity index 100% rename from pkgutil/pkg_b/example_pkg/b/__init__.py rename to pkgutil/pkg_b/src/example_pkg/b/__init__.py