├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .python-versions-used ├── LICENSE ├── README.md ├── constraints.txt ├── legacy_table.md ├── native ├── pkg_a │ ├── example_pkg │ │ └── a │ │ │ └── __init__.py │ ├── pyproject.toml │ └── setup.py └── pkg_b │ ├── example_pkg │ └── b │ │ └── __init__.py │ ├── pyproject.toml │ └── setup.py ├── noxfile.py ├── pkg_resources ├── pkg_a │ ├── example_pkg │ │ ├── __init__.py │ │ └── a │ │ │ └── __init__.py │ ├── pyproject.toml │ └── setup.py └── pkg_b │ ├── example_pkg │ ├── __init__.py │ └── b │ │ └── __init__.py │ ├── pyproject.toml │ └── setup.py ├── pkgutil ├── README.md ├── pkg_a │ ├── example_pkg │ │ ├── __init__.py │ │ └── a │ │ │ └── __init__.py │ ├── pyproject.toml │ └── setup.py └── pkg_b │ ├── example_pkg │ ├── __init__.py │ └── b │ │ └── __init__.py │ ├── pyproject.toml │ └── setup.py ├── report_to_table.py ├── requirements.txt ├── table.md └── verify_packages.py /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: ["master", "src-layout"] 5 | pull_request: 6 | branches: ["master", "src-layout"] 7 | schedule: 8 | - cron: "0 12 1 * *" 9 | 10 | permissions: 11 | contents: read 12 | 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | generate-compatibility-matrix: 19 | name: >- 20 | Check for any uncommitted 21 | table alteration 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v4 25 | - name: Determine Python versions 26 | run: | 27 | { 28 | echo 'PYTHON_VERSIONS<> $GITHUB_ENV 32 | - name: Set up Python 33 | uses: actions/setup-python@v5 34 | with: 35 | python-version: ${{ env.PYTHON_VERSIONS }} 36 | - name: Install dependencies 37 | run: | 38 | python -m pip install -r requirements.txt 39 | - name: Generate compatibility matrix with nox 40 | continue-on-error: true 41 | run: | 42 | python -m nox --report report.json 43 | - name: Verify table has not been altered 44 | run: | 45 | set -xeEuo pipefail 46 | cat report.json 47 | python report_to_table.py 48 | echo 'DIFF_FOR_TABLE<> "${GITHUB_OUTPUT}" 49 | git diff table.md | tee -a "${GITHUB_OUTPUT}" 50 | echo 'EOF' >> "${GITHUB_OUTPUT}" 51 | id: verify-table 52 | - name: Fail the job if the committed table differs from the calculated one 53 | if: steps.verify-table.outputs.DIFF_FOR_TABLE != '' 54 | run: | 55 | echo "::error file=table.md::Table has been altered but not committed!" 56 | exit 1 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | build 3 | __pycache__ 4 | *.pyc 5 | *.egg-info 6 | .nox 7 | report.json 8 | -------------------------------------------------------------------------------- /.python-versions-used: -------------------------------------------------------------------------------- 1 | 3.8 2 | 3.10 3 | 3.12 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python Namespace Package Examples 2 | 3 | This repository contains samples for the various ways to create namespace 4 | packages in Python. For more details, see the 5 | [documentation on namespace packages](https://packaging.python.org/namespace_packages/) 6 | 7 | 8 | ## Testing 9 | This repo also contains testing tools to exercise installation scenarios for 10 | namespace packages. 11 | 12 | To run the scenarios: 13 | 14 | ``` 15 | $ pip install -r requirements.txt 16 | $ nox --report report.json 17 | ``` 18 | 19 | `nox` will execute all of the scenarios and report whether the namespace 20 | packages are able to be imported successfully after installation. You can 21 | use `python report_to_table.py` to transform the report into a 22 | markdown-friendly table. 23 | 24 | # Current status 25 | 26 | To see the status since the last time the scenarios were run open [table.md](table.md)[^1]. 27 | 28 | Please note: 29 | * Mixing package types within a single namespace is not supported. While it may work in some cases, it may also break depending on the software versions used, the install commands issued, or the order of commands. It is generally advisable not to mix types. 30 | * The `pkg_resources` method of namspacing is [deprecated](https://setuptools.pypa.io/en/latest/pkg_resources.html). 31 | Whenever possible, developers are encouraged to migrate away from it. 32 | * [PEP 420](https://www.python.org/dev/peps/pep-0420/) was accepted as part of Python 3.3. For wider compatibility (going back to Python 2.3), use the `pkgutil` method. 33 | * Zipped eggs don't play nicely with namespace packaging, and may be implicitly installed by commands like `python setup.py install`. To prevent this, it is recommended that you set [`zip_safe=False`](http://setuptools.readthedocs.io/en/latest/setuptools.html#setting-the-zip-safe-flag) in `setup.py`, as we do here. Please also note that distributing packages via egg files is considered deprecated. 34 | * The tests reported in [table.md](table.md) use `pip` with *build isolation* and build-backend APIs. 35 | This is triggered by the presence of a `pyproject.toml` file in each package source directory. 36 | If your package does not have a `pyproject.toml` file, 37 | `pip` might select a legacy (and deprecated) installation procedure, which can behave differently. 38 | 39 | # Remarks on staggered migrations 40 | 41 | It is difficult migrate away from deprecated `pkg_resources` namepaces in large projects. 42 | Ideally, all packages sharing a namespace should coordinate and simultaneously drop `__init__.py` files to conform with PEP 420. 43 | However, developers might be interested in carrying out a *staggered migration* plan and temporarily mix different namespacing techniques 44 | to mitigate the migration effort and spread the work load in time. 45 | 46 | Based on the results for the scenarios mixing `pkg_resources` and other namespace methods reported in 47 | [table.md](table.md) and [legacy_table.md](legacy_table.md), 48 | we can see that (in principle) a staggered migration plan can be successful, 49 | as long as the developers are willing to accept some limitations: 50 | 51 | - Deprecated installation methods will not be supported (e.g. `python setup.py install`), 52 | - Editable installations will not be supported. 53 | 54 | Please note, however, that these are preliminary studies. 55 | Developers should carry out an independent investigation, and check for the 56 | specific use cases they are interested in supporting. 57 | 58 | 59 | [^1]: If you would like to know about deprecated installation methods (e.g. via 60 | `python setup.py install`) or Python 2.7, please have a look at [legacy_table.md](legacy_table.md). 61 | -------------------------------------------------------------------------------- /constraints.txt: -------------------------------------------------------------------------------- 1 | setuptools >= 68.2.2 2 | wheel >= 0.42.0 -------------------------------------------------------------------------------- /legacy_table.md: -------------------------------------------------------------------------------- 1 | | Type | Interpreter | Package A command | Package B command | Status | 2 | | --- | --- | --- | --- | --- | 3 | | pkgutil | python2.7 | pip install . | pip install . | ✅ | 4 | | pkgutil | python2.7 | pip install . | pip install -e . | ✅ | 5 | | pkgutil | python2.7 | pip install . | python setup.py install | ✅ | 6 | | pkgutil | python2.7 | pip install . | python setup.py develop | ✅ | 7 | | pkgutil | python2.7 | pip install -e . | pip install . | ✅ | 8 | | pkgutil | python2.7 | pip install -e . | pip install -e . | ✅ | 9 | | pkgutil | python2.7 | pip install -e . | python setup.py install | ✅ | 10 | | pkgutil | python2.7 | pip install -e . | python setup.py develop | ✅ | 11 | | pkgutil | python2.7 | python setup.py install | pip install . | ✅ | 12 | | pkgutil | python2.7 | python setup.py install | pip install -e . | ✅ | 13 | | pkgutil | python2.7 | python setup.py install | python setup.py install | ✅ | 14 | | pkgutil | python2.7 | python setup.py install | python setup.py develop | ✅ | 15 | | pkgutil | python2.7 | python setup.py develop | pip install . | ✅ | 16 | | pkgutil | python2.7 | python setup.py develop | pip install -e . | ✅ | 17 | | pkgutil | python2.7 | python setup.py develop | python setup.py install | ✅ | 18 | | pkgutil | python2.7 | python setup.py develop | python setup.py develop | ✅ | 19 | | pkgutil | python3.7 | pip install . | pip install . | ✅ | 20 | | pkgutil | python3.7 | pip install . | pip install -e . | ✅ | 21 | | pkgutil | python3.7 | pip install . | python setup.py install | ✅ | 22 | | pkgutil | python3.7 | pip install . | python setup.py develop | ✅ | 23 | | pkgutil | python3.7 | pip install -e . | pip install . | ✅ | 24 | | pkgutil | python3.7 | pip install -e . | pip install -e . | ✅ | 25 | | pkgutil | python3.7 | pip install -e . | python setup.py install | ✅ | 26 | | pkgutil | python3.7 | pip install -e . | python setup.py develop | ✅ | 27 | | pkgutil | python3.7 | python setup.py install | pip install . | ✅ | 28 | | pkgutil | python3.7 | python setup.py install | pip install -e . | ✅ | 29 | | pkgutil | python3.7 | python setup.py install | python setup.py install | ✅ | 30 | | pkgutil | python3.7 | python setup.py install | python setup.py develop | ✅ | 31 | | pkgutil | python3.7 | python setup.py develop | pip install . | ✅ | 32 | | pkgutil | python3.7 | python setup.py develop | pip install -e . | ✅ | 33 | | pkgutil | python3.7 | python setup.py develop | python setup.py install | ✅ | 34 | | pkgutil | python3.7 | python setup.py develop | python setup.py develop | ✅ | 35 | | pkg_resources | python2.7 | pip install . | pip install . | ✅ | 36 | | pkg_resources | python2.7 | pip install . | pip install -e . | ✅ | 37 | | pkg_resources | python2.7 | pip install . | python setup.py install | ❌ | 38 | | pkg_resources | python2.7 | pip install . | python setup.py develop | ✅ | 39 | | pkg_resources | python2.7 | pip install -e . | pip install . | ✅ | 40 | | pkg_resources | python2.7 | pip install -e . | pip install -e . | ✅ | 41 | | pkg_resources | python2.7 | pip install -e . | python setup.py install | ❌ | 42 | | pkg_resources | python2.7 | pip install -e . | python setup.py develop | ✅ | 43 | | pkg_resources | python2.7 | python setup.py install | pip install . | ❌ | 44 | | pkg_resources | python2.7 | python setup.py install | pip install -e . | ❌ | 45 | | pkg_resources | python2.7 | python setup.py install | python setup.py install | ✅ | 46 | | pkg_resources | python2.7 | python setup.py install | python setup.py develop | ❌ | 47 | | pkg_resources | python2.7 | python setup.py develop | pip install . | ✅ | 48 | | pkg_resources | python2.7 | python setup.py develop | pip install -e . | ✅ | 49 | | pkg_resources | python2.7 | python setup.py develop | python setup.py install | ❌ | 50 | | pkg_resources | python2.7 | python setup.py develop | python setup.py develop | ✅ | 51 | | pkg_resources | python3.7 | pip install . | pip install . | ✅ | 52 | | pkg_resources | python3.7 | pip install . | pip install -e . | ✅ | 53 | | pkg_resources | python3.7 | pip install . | python setup.py install | ❌ | 54 | | pkg_resources | python3.7 | pip install . | python setup.py develop | ✅ | 55 | | pkg_resources | python3.7 | pip install -e . | pip install . | ✅ | 56 | | pkg_resources | python3.7 | pip install -e . | pip install -e . | ✅ | 57 | | pkg_resources | python3.7 | pip install -e . | python setup.py install | ❌ | 58 | | pkg_resources | python3.7 | pip install -e . | python setup.py develop | ✅ | 59 | | pkg_resources | python3.7 | python setup.py install | pip install . | ❌ | 60 | | pkg_resources | python3.7 | python setup.py install | pip install -e . | ❌ | 61 | | pkg_resources | python3.7 | python setup.py install | python setup.py install | ✅ | 62 | | pkg_resources | python3.7 | python setup.py install | python setup.py develop | ❌ | 63 | | pkg_resources | python3.7 | python setup.py develop | pip install . | ✅ | 64 | | pkg_resources | python3.7 | python setup.py develop | pip install -e . | ✅ | 65 | | pkg_resources | python3.7 | python setup.py develop | python setup.py install | ❌ | 66 | | pkg_resources | python3.7 | python setup.py develop | python setup.py develop | ✅ | 67 | | pep420 | python2.7 | pip install . | pip install . | ❌ | 68 | | pep420 | python2.7 | pip install . | pip install -e . | ❌ | 69 | | pep420 | python2.7 | pip install . | python setup.py install | ❌ | 70 | | pep420 | python2.7 | pip install . | python setup.py develop | ❌ | 71 | | pep420 | python2.7 | pip install -e . | pip install . | ❌ | 72 | | pep420 | python2.7 | pip install -e . | pip install -e . | ❌ | 73 | | pep420 | python2.7 | pip install -e . | python setup.py install | ❌ | 74 | | pep420 | python2.7 | pip install -e . | python setup.py develop | ❌ | 75 | | pep420 | python2.7 | python setup.py install | pip install . | ❌ | 76 | | pep420 | python2.7 | python setup.py install | pip install -e . | ❌ | 77 | | pep420 | python2.7 | python setup.py install | python setup.py install | ❌ | 78 | | pep420 | python2.7 | python setup.py install | python setup.py develop | ❌ | 79 | | pep420 | python2.7 | python setup.py develop | pip install . | ❌ | 80 | | pep420 | python2.7 | python setup.py develop | pip install -e . | ❌ | 81 | | pep420 | python2.7 | python setup.py develop | python setup.py install | ❌ | 82 | | pep420 | python2.7 | python setup.py develop | python setup.py develop | ❌ | 83 | | pep420 | python3.7 | pip install . | pip install . | ✅ | 84 | | pep420 | python3.7 | pip install . | pip install -e . | ✅ | 85 | | pep420 | python3.7 | pip install . | python setup.py install | ✅ | 86 | | pep420 | python3.7 | pip install . | python setup.py develop | ✅ | 87 | | pep420 | python3.7 | pip install -e . | pip install . | ✅ | 88 | | pep420 | python3.7 | pip install -e . | pip install -e . | ✅ | 89 | | pep420 | python3.7 | pip install -e . | python setup.py install | ✅ | 90 | | pep420 | python3.7 | pip install -e . | python setup.py develop | ✅ | 91 | | pep420 | python3.7 | python setup.py install | pip install . | ✅ | 92 | | pep420 | python3.7 | python setup.py install | pip install -e . | ✅ | 93 | | pep420 | python3.7 | python setup.py install | python setup.py install | ✅ | 94 | | pep420 | python3.7 | python setup.py install | python setup.py develop | ✅ | 95 | | pep420 | python3.7 | python setup.py develop | pip install . | ✅ | 96 | | pep420 | python3.7 | python setup.py develop | pip install -e . | ✅ | 97 | | pep420 | python3.7 | python setup.py develop | python setup.py install | ✅ | 98 | | pep420 | python3.7 | python setup.py develop | python setup.py develop | ✅ | 99 | | cross_pkg_resources_pkgutil | python2.7 | pip install . | pip install . | ✅ | 100 | | cross_pkg_resources_pkgutil | python2.7 | pip install . | pip install -e . | ❌ | 101 | | cross_pkg_resources_pkgutil | python2.7 | pip install . | python setup.py install | ❌ | 102 | | cross_pkg_resources_pkgutil | python2.7 | pip install . | python setup.py develop | ❌ | 103 | | cross_pkg_resources_pkgutil | python2.7 | pip install -e . | pip install . | ❌ | 104 | | cross_pkg_resources_pkgutil | python2.7 | pip install -e . | pip install -e . | ❌ | 105 | | cross_pkg_resources_pkgutil | python2.7 | pip install -e . | python setup.py install | ❌ | 106 | | cross_pkg_resources_pkgutil | python2.7 | pip install -e . | python setup.py develop | ❌ | 107 | | cross_pkg_resources_pkgutil | python2.7 | python setup.py install | pip install . | ✅ | 108 | | cross_pkg_resources_pkgutil | python2.7 | python setup.py install | pip install -e . | ✅ | 109 | | cross_pkg_resources_pkgutil | python2.7 | python setup.py install | python setup.py install | ✅ | 110 | | cross_pkg_resources_pkgutil | python2.7 | python setup.py install | python setup.py develop | ✅ | 111 | | cross_pkg_resources_pkgutil | python2.7 | python setup.py develop | pip install . | ❌ | 112 | | cross_pkg_resources_pkgutil | python2.7 | python setup.py develop | pip install -e . | ❌ | 113 | | cross_pkg_resources_pkgutil | python2.7 | python setup.py develop | python setup.py install | ❌ | 114 | | cross_pkg_resources_pkgutil | python2.7 | python setup.py develop | python setup.py develop | ❌ | 115 | | cross_pkg_resources_pkgutil | python3.7 | pip install . | pip install . | ✅ | 116 | | cross_pkg_resources_pkgutil | python3.7 | pip install . | pip install -e . | ❌ | 117 | | cross_pkg_resources_pkgutil | python3.7 | pip install . | python setup.py install | ❌ | 118 | | cross_pkg_resources_pkgutil | python3.7 | pip install . | python setup.py develop | ❌ | 119 | | cross_pkg_resources_pkgutil | python3.7 | pip install -e . | pip install . | ❌ | 120 | | cross_pkg_resources_pkgutil | python3.7 | pip install -e . | pip install -e . | ❌ | 121 | | cross_pkg_resources_pkgutil | python3.7 | pip install -e . | python setup.py install | ❌ | 122 | | cross_pkg_resources_pkgutil | python3.7 | pip install -e . | python setup.py develop | ❌ | 123 | | cross_pkg_resources_pkgutil | python3.7 | python setup.py install | pip install . | ✅ | 124 | | cross_pkg_resources_pkgutil | python3.7 | python setup.py install | pip install -e . | ✅ | 125 | | cross_pkg_resources_pkgutil | python3.7 | python setup.py install | python setup.py install | ✅ | 126 | | cross_pkg_resources_pkgutil | python3.7 | python setup.py install | python setup.py develop | ✅ | 127 | | cross_pkg_resources_pkgutil | python3.7 | python setup.py develop | pip install . | ❌ | 128 | | cross_pkg_resources_pkgutil | python3.7 | python setup.py develop | pip install -e . | ❌ | 129 | | cross_pkg_resources_pkgutil | python3.7 | python setup.py develop | python setup.py install | ❌ | 130 | | cross_pkg_resources_pkgutil | python3.7 | python setup.py develop | python setup.py develop | ❌ | 131 | | cross_pep420_pkgutil | python2.7 | pip install . | pip install . | ✅ | 132 | | cross_pep420_pkgutil | python2.7 | pip install . | pip install -e . | ❌ | 133 | | cross_pep420_pkgutil | python2.7 | pip install . | python setup.py install | ❌ | 134 | | cross_pep420_pkgutil | python2.7 | pip install . | python setup.py develop | ❌ | 135 | | cross_pep420_pkgutil | python2.7 | pip install -e . | pip install . | ❌ | 136 | | cross_pep420_pkgutil | python2.7 | pip install -e . | pip install -e . | ❌ | 137 | | cross_pep420_pkgutil | python2.7 | pip install -e . | python setup.py install | ❌ | 138 | | cross_pep420_pkgutil | python2.7 | pip install -e . | python setup.py develop | ❌ | 139 | | cross_pep420_pkgutil | python2.7 | python setup.py install | pip install . | ❌ | 140 | | cross_pep420_pkgutil | python2.7 | python setup.py install | pip install -e . | ❌ | 141 | | cross_pep420_pkgutil | python2.7 | python setup.py install | python setup.py install | ❌ | 142 | | cross_pep420_pkgutil | python2.7 | python setup.py install | python setup.py develop | ❌ | 143 | | cross_pep420_pkgutil | python2.7 | python setup.py develop | pip install . | ❌ | 144 | | cross_pep420_pkgutil | python2.7 | python setup.py develop | pip install -e . | ❌ | 145 | | cross_pep420_pkgutil | python2.7 | python setup.py develop | python setup.py install | ❌ | 146 | | cross_pep420_pkgutil | python2.7 | python setup.py develop | python setup.py develop | ❌ | 147 | | cross_pep420_pkgutil | python3.7 | pip install . | pip install . | ✅ | 148 | | cross_pep420_pkgutil | python3.7 | pip install . | pip install -e . | ✅ | 149 | | cross_pep420_pkgutil | python3.7 | pip install . | python setup.py install | ✅ | 150 | | cross_pep420_pkgutil | python3.7 | pip install . | python setup.py develop | ✅ | 151 | | cross_pep420_pkgutil | python3.7 | pip install -e . | pip install . | ✅ | 152 | | cross_pep420_pkgutil | python3.7 | pip install -e . | pip install -e . | ✅ | 153 | | cross_pep420_pkgutil | python3.7 | pip install -e . | python setup.py install | ✅ | 154 | | cross_pep420_pkgutil | python3.7 | pip install -e . | python setup.py develop | ✅ | 155 | | cross_pep420_pkgutil | python3.7 | python setup.py install | pip install . | ✅ | 156 | | cross_pep420_pkgutil | python3.7 | python setup.py install | pip install -e . | ✅ | 157 | | cross_pep420_pkgutil | python3.7 | python setup.py install | python setup.py install | ✅ | 158 | | cross_pep420_pkgutil | python3.7 | python setup.py install | python setup.py develop | ✅ | 159 | | cross_pep420_pkgutil | python3.7 | python setup.py develop | pip install . | ✅ | 160 | | cross_pep420_pkgutil | python3.7 | python setup.py develop | pip install -e . | ✅ | 161 | | cross_pep420_pkgutil | python3.7 | python setup.py develop | python setup.py install | ✅ | 162 | | cross_pep420_pkgutil | python3.7 | python setup.py develop | python setup.py develop | ✅ | 163 | -------------------------------------------------------------------------------- /native/pkg_a/example_pkg/a/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name = 'a' 16 | -------------------------------------------------------------------------------- /native/pkg_a/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /native/pkg_a/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from setuptools import setup 16 | 17 | 18 | setup( 19 | name='example_pkg_a', 20 | 21 | version='1', 22 | 23 | description='', 24 | long_description='', 25 | 26 | author='Jon Wayne Parrott', 27 | author_email='jonwayne@google.com', 28 | 29 | license='Apache Software License', 30 | 31 | packages=['example_pkg.a'], 32 | zip_safe=False, 33 | ) 34 | -------------------------------------------------------------------------------- /native/pkg_b/example_pkg/b/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name = 'b' 16 | -------------------------------------------------------------------------------- /native/pkg_b/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /native/pkg_b/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from setuptools import setup 16 | 17 | 18 | setup( 19 | name='example_pkg_b', 20 | 21 | version='1', 22 | 23 | description='', 24 | long_description='', 25 | 26 | author='Jon Wayne Parrott', 27 | author_email='jonwayne@google.com', 28 | 29 | license='Apache Software License', 30 | 31 | packages=['example_pkg.b'], 32 | zip_safe=False, 33 | ) 34 | -------------------------------------------------------------------------------- /noxfile.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import os 16 | import nox 17 | 18 | HERE = os.path.abspath(os.path.dirname(__file__)) 19 | 20 | # -- REQUIRES: nox >= 2023.04.22 21 | # SEE: https://nox.thea.codes/en/stable/index.html 22 | USE_PYTHON_VERSIONS = os.environ.get("NOXFILE_PYTHON_VERSIONS", "").split() 23 | if not USE_PYTHON_VERSIONS: 24 | with open(os.path.join(HERE, ".python-versions-used"), "r") as file: 25 | USE_PYTHON_VERSIONS = [x.strip() for x in file] 26 | 27 | 28 | install_commands = (("pip", "install", "."), ("pip", "install", "-e", ".")) 29 | 30 | 31 | def install_packages(session, package_a, package_b, command_a, command_b): 32 | env = {**os.environ, "PIP_CONSTRAINT": f"{HERE}/constraints.txt"} 33 | session.install("--upgrade", "pip", env=env) 34 | session.chdir(package_a) 35 | session.run("rm", "-rf", "dist", "build", "*.egg-info") 36 | session.run(*command_a, env=env) 37 | session.chdir(HERE) 38 | session.chdir(package_b) 39 | session.run("rm", "-rf", "dist", "build", "*.egg-info") 40 | session.run(*command_b, env=env) 41 | session.chdir(HERE) 42 | 43 | 44 | @nox.session(python=USE_PYTHON_VERSIONS) 45 | @nox.parametrize("command_a", install_commands) 46 | @nox.parametrize("command_b", install_commands) 47 | def session_pkgutil(session, command_a, command_b): 48 | install_packages(session, "pkgutil/pkg_a", "pkgutil/pkg_b", command_a, command_b) 49 | session.run("python", "verify_packages.py") 50 | 51 | 52 | @nox.session(python=USE_PYTHON_VERSIONS) 53 | @nox.parametrize("command_a", install_commands) 54 | @nox.parametrize("command_b", install_commands) 55 | def session_pkg_resources(session, command_a, command_b): 56 | install_packages( 57 | session, "pkg_resources/pkg_a", "pkg_resources/pkg_b", command_a, command_b 58 | ) 59 | session.run("python", "verify_packages.py") 60 | 61 | 62 | @nox.session(python=USE_PYTHON_VERSIONS) 63 | @nox.parametrize("command_a", install_commands) 64 | @nox.parametrize("command_b", install_commands) 65 | def session_pep420(session, command_a, command_b): 66 | install_packages(session, "native/pkg_a", "native/pkg_b", command_a, command_b) 67 | session.run("python", "verify_packages.py") 68 | 69 | 70 | @nox.session(python=USE_PYTHON_VERSIONS) 71 | @nox.parametrize("command_a", install_commands) 72 | @nox.parametrize("command_b", install_commands) 73 | def session_cross_pkg_resources_pkgutil(session, command_a, command_b): 74 | install_packages( 75 | session, "pkg_resources/pkg_a", "pkgutil/pkg_b", command_a, command_b 76 | ) 77 | session.run("python", "-m", "pip", "list") 78 | session.run("python", "verify_packages.py") 79 | 80 | 81 | @nox.session(python=USE_PYTHON_VERSIONS) 82 | @nox.parametrize("command_a", install_commands) 83 | @nox.parametrize("command_b", install_commands) 84 | def session_cross_pep420_pkgutil(session, command_a, command_b): 85 | install_packages(session, "native/pkg_a", "pkgutil/pkg_b", command_a, command_b) 86 | session.run("python", "verify_packages.py") 87 | 88 | 89 | @nox.session(python=USE_PYTHON_VERSIONS) 90 | @nox.parametrize('command_a', install_commands) 91 | @nox.parametrize('command_b', install_commands) 92 | def session_cross_pep420_pkg_resources(session, command_a, command_b): 93 | install_packages( 94 | session, 'native/pkg_a', 'pkg_resources/pkg_b', command_a, command_b 95 | ) 96 | session.run("python", "verify_packages.py") 97 | 98 | 99 | @nox.session(python=USE_PYTHON_VERSIONS) 100 | @nox.parametrize('command_a', install_commands) 101 | @nox.parametrize('command_b', install_commands) 102 | def session_cross_pkg_resources_pep420(session, command_a, command_b): 103 | install_packages( 104 | session, 'pkg_resources/pkg_a', 'native/pkg_b', command_a, command_b 105 | ) 106 | session.run("python", "verify_packages.py") 107 | -------------------------------------------------------------------------------- /pkg_resources/pkg_a/example_pkg/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /pkg_resources/pkg_a/example_pkg/a/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name = 'a' 16 | -------------------------------------------------------------------------------- /pkg_resources/pkg_a/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /pkg_resources/pkg_a/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from setuptools import setup, find_packages 16 | 17 | 18 | setup( 19 | name='example_pkg_a', 20 | 21 | version='1', 22 | 23 | description='', 24 | long_description='', 25 | 26 | author='Jon Wayne Parrott', 27 | author_email='jonwayne@google.com', 28 | 29 | license='Apache Software License', 30 | 31 | packages=find_packages(), 32 | namespace_packages=['example_pkg'], 33 | zip_safe=False, 34 | ) 35 | -------------------------------------------------------------------------------- /pkg_resources/pkg_b/example_pkg/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /pkg_resources/pkg_b/example_pkg/b/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name = 'b' 16 | -------------------------------------------------------------------------------- /pkg_resources/pkg_b/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /pkg_resources/pkg_b/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from setuptools import setup, find_packages 16 | 17 | 18 | setup( 19 | name='example_pkg_b', 20 | 21 | version='1', 22 | 23 | description='', 24 | long_description='', 25 | 26 | author='Jon Wayne Parrott', 27 | author_email='jonwayne@google.com', 28 | 29 | license='Apache Software License', 30 | 31 | packages=find_packages(), 32 | namespace_packages=['example_pkg'], 33 | zip_safe=False, 34 | ) 35 | -------------------------------------------------------------------------------- /pkgutil/README.md: -------------------------------------------------------------------------------- 1 | # [pkgutil-style namespace packages](https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages) 2 | 3 | The following examples demonstrates the usage / installation of `pkgutil` style namespace packages. 4 | 5 | ``` 6 | pkgutil/ 7 | ├ pkg_a/ # the name of this dir doesn't matter 8 | │ ├ setup.py 9 | │ └ example_pkg/ # namespace package name 10 | │ ├__init__.py # special pkgutil namespace __init__.py 11 | │ └ a/ # dir name must match the package name from `setup.py` 12 | │ └ __init__.py 13 | │ ├ module1.py 14 | . 15 | . 16 | . 17 | └ pkg_b/ 18 | ``` 19 | 20 | The anatomy of a namespace package name is `.`. 21 | Namespaces can also be nested an take the form `..`. 22 | 23 | This subdirectory contains two packages (`"a"` & `"b"`) that share the namespace `example_pkg`. 24 | When installed these packages will have the names `example_pkg.a` & `example_pkg.b` respectively. 25 | 26 | ### Detailed Requirements 27 | The directories `pkg_a` and `pkg_b` in this subdirectory contain two different python packages. 28 | The names of these directories have no effect on the installed package. 29 | 30 | Each of these directories should at least contain: 31 | 1. A configuration file, in this case `setup.py`. 32 | 2. A directory, whose name determines the namespace name. 33 | 34 | In this example `example_pkg` is the name of the namespace. This directory should contain: 35 | 1. The `__init__.py` file for the namespace package, which must contain only the following: 36 | ```python 37 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 38 | ``` 39 | Nested namespaces must contain an identical `__init__.py`. 40 | 41 | 2. A directory, whose name determines the `package_name`. This directory holds the package's source code. 42 | - The directory name, must match the name given in the `setup.py`. 43 | 44 | ### Practical Usage 45 | When using namespace packages, it is helpful to understand that the delimiter between the 46 | `namespace` and the `package_name` is not consistent throughout common python workflows. 47 | 48 | For example, here is how to reference the namespace package `"a"` from this repository. 49 | - Creating your namespace package with setuptools in `setup.py`: 50 | - `setup(name="example_pkg_a")` 51 | - Installing / Uninstalling a namespace package with `pip`: 52 | - `pip install example-pkg-a` 53 | - Importing a namespace package with`python`: 54 | - `import example_pkg.a` 55 | 56 | From the root directory, running the following command will install a package called `example_pkg.a`. 57 | 58 | ```bash 59 | cd pkgutil/pkg_a 60 | 61 | python -m pip install . 62 | 63 | # Test the install by printing the `name` from the `__init__.py` file. 64 | python -c "import example_pkg.a as a; print(a.name)" 65 | ``` 66 | -------------------------------------------------------------------------------- /pkgutil/pkg_a/example_pkg/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /pkgutil/pkg_a/example_pkg/a/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name = 'a' 16 | -------------------------------------------------------------------------------- /pkgutil/pkg_a/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /pkgutil/pkg_a/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from setuptools import setup, find_packages 16 | 17 | 18 | setup( 19 | name='example_pkg_a', 20 | 21 | version='1', 22 | 23 | description='', 24 | long_description='', 25 | 26 | author='Jon Wayne Parrott', 27 | author_email='jonwayne@google.com', 28 | 29 | license='Apache Software License', 30 | 31 | packages=find_packages(), 32 | zip_safe=False, 33 | ) 34 | -------------------------------------------------------------------------------- /pkgutil/pkg_b/example_pkg/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /pkgutil/pkg_b/example_pkg/b/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name = 'b' 16 | -------------------------------------------------------------------------------- /pkgutil/pkg_b/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /pkgutil/pkg_b/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from setuptools import setup, find_packages 16 | 17 | 18 | setup( 19 | name='example_pkg_b', 20 | 21 | version='1', 22 | 23 | description='', 24 | long_description='', 25 | 26 | author='Jon Wayne Parrott', 27 | author_email='jonwayne@google.com', 28 | 29 | license='Apache Software License', 30 | 31 | packages=find_packages(), 32 | zip_safe=False, 33 | ) 34 | -------------------------------------------------------------------------------- /report_to_table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | import io 5 | import json 6 | 7 | 8 | with io.open('report.json', 'r') as f: 9 | data = json.load(f) 10 | 11 | with io.open('table.md', 'w') as f: 12 | f.write('| Type | Interpreter | Package A command | Package B command | Status |\n') 13 | f.write('| --- | --- | --- | --- | --- |\n') 14 | for session in data['sessions']: 15 | session_name = session['name'] 16 | session_detailled_name = session['signatures'][-1] 17 | session_interpreter = session_detailled_name.replace(session_name + "-", "python") 18 | # TODO: Replace with `str.removeprefix()` in Python 3.12 19 | session_name = session_name[len("session_") :] 20 | 21 | f.write('| {} | {} | {} | {} | {} |\n'.format( 22 | session_name, 23 | session_interpreter, 24 | ' '.join(session['args']['command_a']), 25 | ' '.join(session['args']['command_b']), 26 | '✅' if session['result_code'] else '❌' 27 | )) 28 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # -- PYTHON PACKAGE REQUIREMENTS: 2 | # USE: pip install -r 3 | 4 | nox >= 2023.04.22 5 | -------------------------------------------------------------------------------- /table.md: -------------------------------------------------------------------------------- 1 | | Type | Interpreter | Package A command | Package B command | Status | 2 | | --- | --- | --- | --- | --- | 3 | | pkgutil | python3.8 | pip install . | pip install . | ✅ | 4 | | pkgutil | python3.8 | pip install . | pip install -e . | ✅ | 5 | | pkgutil | python3.8 | pip install -e . | pip install . | ✅ | 6 | | pkgutil | python3.8 | pip install -e . | pip install -e . | ✅ | 7 | | pkgutil | python3.10 | pip install . | pip install . | ✅ | 8 | | pkgutil | python3.10 | pip install . | pip install -e . | ✅ | 9 | | pkgutil | python3.10 | pip install -e . | pip install . | ✅ | 10 | | pkgutil | python3.10 | pip install -e . | pip install -e . | ✅ | 11 | | pkgutil | python3.12 | pip install . | pip install . | ✅ | 12 | | pkgutil | python3.12 | pip install . | pip install -e . | ✅ | 13 | | pkgutil | python3.12 | pip install -e . | pip install . | ✅ | 14 | | pkgutil | python3.12 | pip install -e . | pip install -e . | ✅ | 15 | | pkg_resources | python3.8 | pip install . | pip install . | ✅ | 16 | | pkg_resources | python3.8 | pip install . | pip install -e . | ✅ | 17 | | pkg_resources | python3.8 | pip install -e . | pip install . | ✅ | 18 | | pkg_resources | python3.8 | pip install -e . | pip install -e . | ✅ | 19 | | pkg_resources | python3.10 | pip install . | pip install . | ✅ | 20 | | pkg_resources | python3.10 | pip install . | pip install -e . | ✅ | 21 | | pkg_resources | python3.10 | pip install -e . | pip install . | ✅ | 22 | | pkg_resources | python3.10 | pip install -e . | pip install -e . | ✅ | 23 | | pkg_resources | python3.12 | pip install . | pip install . | ✅ | 24 | | pkg_resources | python3.12 | pip install . | pip install -e . | ✅ | 25 | | pkg_resources | python3.12 | pip install -e . | pip install . | ✅ | 26 | | pkg_resources | python3.12 | pip install -e . | pip install -e . | ✅ | 27 | | pep420 | python3.8 | pip install . | pip install . | ✅ | 28 | | pep420 | python3.8 | pip install . | pip install -e . | ✅ | 29 | | pep420 | python3.8 | pip install -e . | pip install . | ✅ | 30 | | pep420 | python3.8 | pip install -e . | pip install -e . | ✅ | 31 | | pep420 | python3.10 | pip install . | pip install . | ✅ | 32 | | pep420 | python3.10 | pip install . | pip install -e . | ✅ | 33 | | pep420 | python3.10 | pip install -e . | pip install . | ✅ | 34 | | pep420 | python3.10 | pip install -e . | pip install -e . | ✅ | 35 | | pep420 | python3.12 | pip install . | pip install . | ✅ | 36 | | pep420 | python3.12 | pip install . | pip install -e . | ✅ | 37 | | pep420 | python3.12 | pip install -e . | pip install . | ✅ | 38 | | pep420 | python3.12 | pip install -e . | pip install -e . | ✅ | 39 | | cross_pkg_resources_pkgutil | python3.8 | pip install . | pip install . | ✅ | 40 | | cross_pkg_resources_pkgutil | python3.8 | pip install . | pip install -e . | ✅ | 41 | | cross_pkg_resources_pkgutil | python3.8 | pip install -e . | pip install . | ❌ | 42 | | cross_pkg_resources_pkgutil | python3.8 | pip install -e . | pip install -e . | ✅ | 43 | | cross_pkg_resources_pkgutil | python3.10 | pip install . | pip install . | ✅ | 44 | | cross_pkg_resources_pkgutil | python3.10 | pip install . | pip install -e . | ✅ | 45 | | cross_pkg_resources_pkgutil | python3.10 | pip install -e . | pip install . | ❌ | 46 | | cross_pkg_resources_pkgutil | python3.10 | pip install -e . | pip install -e . | ✅ | 47 | | cross_pkg_resources_pkgutil | python3.12 | pip install . | pip install . | ✅ | 48 | | cross_pkg_resources_pkgutil | python3.12 | pip install . | pip install -e . | ✅ | 49 | | cross_pkg_resources_pkgutil | python3.12 | pip install -e . | pip install . | ❌ | 50 | | cross_pkg_resources_pkgutil | python3.12 | pip install -e . | pip install -e . | ✅ | 51 | | cross_pep420_pkgutil | python3.8 | pip install . | pip install . | ✅ | 52 | | cross_pep420_pkgutil | python3.8 | pip install . | pip install -e . | ✅ | 53 | | cross_pep420_pkgutil | python3.8 | pip install -e . | pip install . | ✅ | 54 | | cross_pep420_pkgutil | python3.8 | pip install -e . | pip install -e . | ✅ | 55 | | cross_pep420_pkgutil | python3.10 | pip install . | pip install . | ✅ | 56 | | cross_pep420_pkgutil | python3.10 | pip install . | pip install -e . | ✅ | 57 | | cross_pep420_pkgutil | python3.10 | pip install -e . | pip install . | ✅ | 58 | | cross_pep420_pkgutil | python3.10 | pip install -e . | pip install -e . | ✅ | 59 | | cross_pep420_pkgutil | python3.12 | pip install . | pip install . | ✅ | 60 | | cross_pep420_pkgutil | python3.12 | pip install . | pip install -e . | ✅ | 61 | | cross_pep420_pkgutil | python3.12 | pip install -e . | pip install . | ✅ | 62 | | cross_pep420_pkgutil | python3.12 | pip install -e . | pip install -e . | ✅ | 63 | | cross_pep420_pkg_resources | python3.8 | pip install . | pip install . | ✅ | 64 | | cross_pep420_pkg_resources | python3.8 | pip install . | pip install -e . | ❌ | 65 | | cross_pep420_pkg_resources | python3.8 | pip install -e . | pip install . | ✅ | 66 | | cross_pep420_pkg_resources | python3.8 | pip install -e . | pip install -e . | ✅ | 67 | | cross_pep420_pkg_resources | python3.10 | pip install . | pip install . | ✅ | 68 | | cross_pep420_pkg_resources | python3.10 | pip install . | pip install -e . | ❌ | 69 | | cross_pep420_pkg_resources | python3.10 | pip install -e . | pip install . | ✅ | 70 | | cross_pep420_pkg_resources | python3.10 | pip install -e . | pip install -e . | ✅ | 71 | | cross_pep420_pkg_resources | python3.12 | pip install . | pip install . | ✅ | 72 | | cross_pep420_pkg_resources | python3.12 | pip install . | pip install -e . | ❌ | 73 | | cross_pep420_pkg_resources | python3.12 | pip install -e . | pip install . | ✅ | 74 | | cross_pep420_pkg_resources | python3.12 | pip install -e . | pip install -e . | ✅ | 75 | | cross_pkg_resources_pep420 | python3.8 | pip install . | pip install . | ✅ | 76 | | cross_pkg_resources_pep420 | python3.8 | pip install . | pip install -e . | ✅ | 77 | | cross_pkg_resources_pep420 | python3.8 | pip install -e . | pip install . | ❌ | 78 | | cross_pkg_resources_pep420 | python3.8 | pip install -e . | pip install -e . | ✅ | 79 | | cross_pkg_resources_pep420 | python3.10 | pip install . | pip install . | ✅ | 80 | | cross_pkg_resources_pep420 | python3.10 | pip install . | pip install -e . | ✅ | 81 | | cross_pkg_resources_pep420 | python3.10 | pip install -e . | pip install . | ❌ | 82 | | cross_pkg_resources_pep420 | python3.10 | pip install -e . | pip install -e . | ✅ | 83 | | cross_pkg_resources_pep420 | python3.12 | pip install . | pip install . | ✅ | 84 | | cross_pkg_resources_pep420 | python3.12 | pip install . | pip install -e . | ✅ | 85 | | cross_pkg_resources_pep420 | python3.12 | pip install -e . | pip install . | ❌ | 86 | | cross_pkg_resources_pep420 | python3.12 | pip install -e . | pip install -e . | ✅ | 87 | -------------------------------------------------------------------------------- /verify_packages.py: -------------------------------------------------------------------------------- 1 | from example_pkg import a 2 | from example_pkg import b 3 | 4 | print(a.name) 5 | print(a.__path__) 6 | print(b.name) 7 | print(b.__path__) 8 | --------------------------------------------------------------------------------