android-notify 1.60.0__py3-none-any.whl → 1.60.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of android-notify might be problematic. Click here for more details.
- android_notify/config.py +1 -1
- {android_notify-1.60.0.dist-info → android_notify-1.60.2.dist-info}/METADATA +4 -4
- {android_notify-1.60.0.dist-info → android_notify-1.60.2.dist-info}/RECORD +375 -6
- venv/Lib/site-packages/_distutils_hack/__init__.py +239 -0
- venv/Lib/site-packages/_distutils_hack/override.py +1 -0
- venv/Lib/site-packages/pkg_resources/__init__.py +3713 -0
- venv/Lib/site-packages/pkg_resources/py.typed +0 -0
- venv/Lib/site-packages/pkg_resources/tests/__init__.py +0 -0
- venv/Lib/site-packages/pkg_resources/tests/data/my-test-package-source/setup.py +7 -0
- venv/Lib/site-packages/pkg_resources/tests/test_find_distributions.py +56 -0
- venv/Lib/site-packages/pkg_resources/tests/test_integration_zope_interface.py +54 -0
- venv/Lib/site-packages/pkg_resources/tests/test_markers.py +8 -0
- venv/Lib/site-packages/pkg_resources/tests/test_pkg_resources.py +485 -0
- venv/Lib/site-packages/pkg_resources/tests/test_resources.py +869 -0
- venv/Lib/site-packages/pkg_resources/tests/test_working_set.py +505 -0
- venv/Lib/site-packages/setuptools/__init__.py +248 -0
- venv/Lib/site-packages/setuptools/_core_metadata.py +337 -0
- venv/Lib/site-packages/setuptools/_discovery.py +33 -0
- venv/Lib/site-packages/setuptools/_distutils/__init__.py +14 -0
- venv/Lib/site-packages/setuptools/_distutils/_log.py +3 -0
- venv/Lib/site-packages/setuptools/_distutils/_macos_compat.py +12 -0
- venv/Lib/site-packages/setuptools/_distutils/_modified.py +95 -0
- venv/Lib/site-packages/setuptools/_distutils/_msvccompiler.py +16 -0
- venv/Lib/site-packages/setuptools/_distutils/archive_util.py +294 -0
- venv/Lib/site-packages/setuptools/_distutils/ccompiler.py +26 -0
- venv/Lib/site-packages/setuptools/_distutils/cmd.py +554 -0
- venv/Lib/site-packages/setuptools/_distutils/command/__init__.py +23 -0
- venv/Lib/site-packages/setuptools/_distutils/command/_framework_compat.py +54 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist.py +167 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist_dumb.py +141 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist_rpm.py +598 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build.py +156 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_clib.py +201 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_ext.py +812 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_py.py +407 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +160 -0
- venv/Lib/site-packages/setuptools/_distutils/command/check.py +152 -0
- venv/Lib/site-packages/setuptools/_distutils/command/clean.py +77 -0
- venv/Lib/site-packages/setuptools/_distutils/command/config.py +358 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install.py +805 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_data.py +94 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_egg_info.py +91 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_headers.py +46 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_lib.py +238 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_scripts.py +62 -0
- venv/Lib/site-packages/setuptools/_distutils/command/sdist.py +521 -0
- venv/Lib/site-packages/setuptools/_distutils/compat/__init__.py +18 -0
- venv/Lib/site-packages/setuptools/_distutils/compat/numpy.py +2 -0
- venv/Lib/site-packages/setuptools/_distutils/compat/py39.py +66 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/base.py +1394 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/cygwin.py +340 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/errors.py +24 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/msvc.py +614 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_base.py +83 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_cygwin.py +76 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_mingw.py +48 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_msvc.py +136 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_unix.py +413 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/unix.py +422 -0
- venv/Lib/site-packages/setuptools/_distutils/compilers/C/zos.py +230 -0
- venv/Lib/site-packages/setuptools/_distutils/core.py +289 -0
- venv/Lib/site-packages/setuptools/_distutils/cygwinccompiler.py +31 -0
- venv/Lib/site-packages/setuptools/_distutils/debug.py +5 -0
- venv/Lib/site-packages/setuptools/_distutils/dep_util.py +14 -0
- venv/Lib/site-packages/setuptools/_distutils/dir_util.py +244 -0
- venv/Lib/site-packages/setuptools/_distutils/dist.py +1386 -0
- venv/Lib/site-packages/setuptools/_distutils/errors.py +108 -0
- venv/Lib/site-packages/setuptools/_distutils/extension.py +258 -0
- venv/Lib/site-packages/setuptools/_distutils/fancy_getopt.py +471 -0
- venv/Lib/site-packages/setuptools/_distutils/file_util.py +236 -0
- venv/Lib/site-packages/setuptools/_distutils/filelist.py +431 -0
- venv/Lib/site-packages/setuptools/_distutils/log.py +56 -0
- venv/Lib/site-packages/setuptools/_distutils/spawn.py +134 -0
- venv/Lib/site-packages/setuptools/_distutils/sysconfig.py +598 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/__init__.py +42 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/compat/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/compat/py39.py +40 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/support.py +134 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_archive_util.py +353 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_bdist.py +47 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_bdist_dumb.py +78 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_bdist_rpm.py +127 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_build.py +49 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_build_clib.py +134 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_build_ext.py +628 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_build_py.py +196 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_build_scripts.py +96 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_check.py +194 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_clean.py +45 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_cmd.py +107 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_config_cmd.py +87 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_core.py +130 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_dir_util.py +139 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_dist.py +552 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_extension.py +117 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_file_util.py +95 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_filelist.py +336 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_install.py +245 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_install_data.py +74 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_install_headers.py +33 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_install_lib.py +110 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_install_scripts.py +52 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_log.py +12 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_modified.py +126 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_sdist.py +470 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_spawn.py +141 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_sysconfig.py +319 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_text_file.py +127 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_util.py +243 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_version.py +80 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/test_versionpredicate.py +0 -0
- venv/Lib/site-packages/setuptools/_distutils/tests/unix_compat.py +17 -0
- venv/Lib/site-packages/setuptools/_distutils/text_file.py +286 -0
- venv/Lib/site-packages/setuptools/_distutils/unixccompiler.py +9 -0
- venv/Lib/site-packages/setuptools/_distutils/util.py +518 -0
- venv/Lib/site-packages/setuptools/_distutils/version.py +348 -0
- venv/Lib/site-packages/setuptools/_distutils/versionpredicate.py +175 -0
- venv/Lib/site-packages/setuptools/_distutils/zosccompiler.py +3 -0
- venv/Lib/site-packages/setuptools/_entry_points.py +94 -0
- venv/Lib/site-packages/setuptools/_imp.py +87 -0
- venv/Lib/site-packages/setuptools/_importlib.py +9 -0
- venv/Lib/site-packages/setuptools/_itertools.py +23 -0
- venv/Lib/site-packages/setuptools/_normalization.py +177 -0
- venv/Lib/site-packages/setuptools/_path.py +93 -0
- venv/Lib/site-packages/setuptools/_reqs.py +42 -0
- venv/Lib/site-packages/setuptools/_scripts.py +361 -0
- venv/Lib/site-packages/setuptools/_shutil.py +59 -0
- venv/Lib/site-packages/setuptools/_static.py +188 -0
- venv/Lib/site-packages/setuptools/_vendor/autocommand/__init__.py +27 -0
- venv/Lib/site-packages/setuptools/_vendor/autocommand/autoasync.py +142 -0
- venv/Lib/site-packages/setuptools/_vendor/autocommand/autocommand.py +70 -0
- venv/Lib/site-packages/setuptools/_vendor/autocommand/automain.py +59 -0
- venv/Lib/site-packages/setuptools/_vendor/autocommand/autoparse.py +333 -0
- venv/Lib/site-packages/setuptools/_vendor/autocommand/errors.py +23 -0
- venv/Lib/site-packages/setuptools/_vendor/backports/__init__.py +1 -0
- venv/Lib/site-packages/setuptools/_vendor/backports/tarfile/__init__.py +2937 -0
- venv/Lib/site-packages/setuptools/_vendor/backports/tarfile/__main__.py +5 -0
- venv/Lib/site-packages/setuptools/_vendor/backports/tarfile/compat/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/backports/tarfile/compat/py38.py +24 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/__init__.py +1083 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_adapters.py +83 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_collections.py +30 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_compat.py +57 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_functools.py +104 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_itertools.py +73 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_meta.py +67 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_text.py +99 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/compat/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/compat/py311.py +22 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/compat/py39.py +36 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/diagnose.py +21 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/py.typed +0 -0
- venv/Lib/site-packages/setuptools/_vendor/inflect/__init__.py +3986 -0
- venv/Lib/site-packages/setuptools/_vendor/inflect/compat/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/inflect/compat/py38.py +7 -0
- venv/Lib/site-packages/setuptools/_vendor/inflect/py.typed +0 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/collections/__init__.py +1091 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/collections/py.typed +0 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/context.py +361 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/functools/__init__.py +633 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/functools/__init__.pyi +125 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/functools/py.typed +0 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/text/__init__.py +624 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/text/layouts.py +25 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/text/show-newlines.py +33 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/text/strip-prefix.py +21 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/text/to-dvorak.py +6 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/text/to-qwerty.py +6 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/__init__.py +6 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/__init__.pyi +2 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/more.py +4806 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/more.pyi +709 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/py.typed +0 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/recipes.py +1046 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/recipes.pyi +136 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/__init__.py +15 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_elffile.py +110 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_manylinux.py +263 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_musllinux.py +85 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_parser.py +354 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_structures.py +61 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_tokenizer.py +194 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/licenses/__init__.py +145 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/licenses/_spdx.py +759 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/markers.py +331 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/metadata.py +863 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/py.typed +0 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/requirements.py +91 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/specifiers.py +1020 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/tags.py +617 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/utils.py +163 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/version.py +582 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/__init__.py +627 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/__main__.py +55 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/android.py +249 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/api.py +292 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/macos.py +130 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/py.typed +0 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/unix.py +275 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/version.py +16 -0
- venv/Lib/site-packages/setuptools/_vendor/platformdirs/windows.py +272 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/__init__.py +11 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_parser.py +691 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_re.py +107 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_types.py +10 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/py.typed +1 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/__init__.py +48 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_checkers.py +993 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_config.py +108 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_decorators.py +235 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_exceptions.py +42 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_functions.py +308 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_importhook.py +213 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_memo.py +48 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_pytest_plugin.py +127 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_suppression.py +86 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_transformer.py +1229 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_union_transformer.py +55 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/_utils.py +173 -0
- venv/Lib/site-packages/setuptools/_vendor/typeguard/py.typed +0 -0
- venv/Lib/site-packages/setuptools/_vendor/typing_extensions.py +3641 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/__init__.py +3 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/__main__.py +23 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/_bdist_wheel.py +613 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/_setuptools_logging.py +26 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/bdist_wheel.py +26 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/cli/__init__.py +155 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/cli/convert.py +332 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/cli/pack.py +85 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/cli/tags.py +139 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/cli/unpack.py +30 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/macosx_libfile.py +482 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/metadata.py +183 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/util.py +17 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/_elffile.py +108 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/_manylinux.py +260 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/_musllinux.py +83 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/_parser.py +356 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/_structures.py +61 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/_tokenizer.py +192 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/markers.py +253 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/requirements.py +90 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/specifiers.py +1011 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/tags.py +571 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/utils.py +172 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/vendored/packaging/version.py +561 -0
- venv/Lib/site-packages/setuptools/_vendor/wheel/wheelfile.py +227 -0
- venv/Lib/site-packages/setuptools/_vendor/zipp/__init__.py +501 -0
- venv/Lib/site-packages/setuptools/_vendor/zipp/compat/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/zipp/compat/py310.py +11 -0
- venv/Lib/site-packages/setuptools/_vendor/zipp/glob.py +106 -0
- venv/Lib/site-packages/setuptools/archive_util.py +219 -0
- venv/Lib/site-packages/setuptools/build_meta.py +548 -0
- venv/Lib/site-packages/setuptools/command/__init__.py +21 -0
- venv/Lib/site-packages/setuptools/command/_requirestxt.py +131 -0
- venv/Lib/site-packages/setuptools/command/alias.py +77 -0
- venv/Lib/site-packages/setuptools/command/bdist_egg.py +477 -0
- venv/Lib/site-packages/setuptools/command/bdist_rpm.py +42 -0
- venv/Lib/site-packages/setuptools/command/bdist_wheel.py +604 -0
- venv/Lib/site-packages/setuptools/command/build.py +135 -0
- venv/Lib/site-packages/setuptools/command/build_clib.py +103 -0
- venv/Lib/site-packages/setuptools/command/build_ext.py +470 -0
- venv/Lib/site-packages/setuptools/command/build_py.py +400 -0
- venv/Lib/site-packages/setuptools/command/develop.py +55 -0
- venv/Lib/site-packages/setuptools/command/dist_info.py +103 -0
- venv/Lib/site-packages/setuptools/command/easy_install.py +30 -0
- venv/Lib/site-packages/setuptools/command/editable_wheel.py +908 -0
- venv/Lib/site-packages/setuptools/command/egg_info.py +718 -0
- venv/Lib/site-packages/setuptools/command/install.py +131 -0
- venv/Lib/site-packages/setuptools/command/install_egg_info.py +58 -0
- venv/Lib/site-packages/setuptools/command/install_lib.py +137 -0
- venv/Lib/site-packages/setuptools/command/install_scripts.py +67 -0
- venv/Lib/site-packages/setuptools/command/rotate.py +65 -0
- venv/Lib/site-packages/setuptools/command/saveopts.py +21 -0
- venv/Lib/site-packages/setuptools/command/sdist.py +217 -0
- venv/Lib/site-packages/setuptools/command/setopt.py +141 -0
- venv/Lib/site-packages/setuptools/command/test.py +45 -0
- venv/Lib/site-packages/setuptools/compat/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/compat/py310.py +20 -0
- venv/Lib/site-packages/setuptools/compat/py311.py +27 -0
- venv/Lib/site-packages/setuptools/compat/py312.py +13 -0
- venv/Lib/site-packages/setuptools/compat/py39.py +9 -0
- venv/Lib/site-packages/setuptools/config/__init__.py +43 -0
- venv/Lib/site-packages/setuptools/config/_apply_pyprojecttoml.py +526 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/__init__.py +34 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/error_reporting.py +336 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/extra_validations.py +82 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py +51 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_validations.py +1412 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/formats.py +402 -0
- venv/Lib/site-packages/setuptools/config/expand.py +452 -0
- venv/Lib/site-packages/setuptools/config/pyprojecttoml.py +468 -0
- venv/Lib/site-packages/setuptools/config/setupcfg.py +780 -0
- venv/Lib/site-packages/setuptools/depends.py +185 -0
- venv/Lib/site-packages/setuptools/discovery.py +614 -0
- venv/Lib/site-packages/setuptools/dist.py +1119 -0
- venv/Lib/site-packages/setuptools/errors.py +67 -0
- venv/Lib/site-packages/setuptools/extension.py +177 -0
- venv/Lib/site-packages/setuptools/glob.py +185 -0
- venv/Lib/site-packages/setuptools/installer.py +155 -0
- venv/Lib/site-packages/setuptools/launch.py +36 -0
- venv/Lib/site-packages/setuptools/logging.py +40 -0
- venv/Lib/site-packages/setuptools/modified.py +18 -0
- venv/Lib/site-packages/setuptools/monkey.py +126 -0
- venv/Lib/site-packages/setuptools/msvc.py +1536 -0
- venv/Lib/site-packages/setuptools/namespaces.py +106 -0
- venv/Lib/site-packages/setuptools/tests/__init__.py +13 -0
- venv/Lib/site-packages/setuptools/tests/compat/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/tests/compat/py39.py +3 -0
- venv/Lib/site-packages/setuptools/tests/config/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/tests/config/downloads/__init__.py +59 -0
- venv/Lib/site-packages/setuptools/tests/config/downloads/preload.py +18 -0
- venv/Lib/site-packages/setuptools/tests/config/test_apply_pyprojecttoml.py +772 -0
- venv/Lib/site-packages/setuptools/tests/config/test_expand.py +247 -0
- venv/Lib/site-packages/setuptools/tests/config/test_pyprojecttoml.py +396 -0
- venv/Lib/site-packages/setuptools/tests/config/test_pyprojecttoml_dynamic_deps.py +109 -0
- venv/Lib/site-packages/setuptools/tests/config/test_setupcfg.py +980 -0
- venv/Lib/site-packages/setuptools/tests/contexts.py +131 -0
- venv/Lib/site-packages/setuptools/tests/environment.py +95 -0
- venv/Lib/site-packages/setuptools/tests/fixtures.py +392 -0
- venv/Lib/site-packages/setuptools/tests/integration/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/tests/integration/helpers.py +77 -0
- venv/Lib/site-packages/setuptools/tests/integration/test_pbr.py +20 -0
- venv/Lib/site-packages/setuptools/tests/integration/test_pip_install_sdist.py +223 -0
- venv/Lib/site-packages/setuptools/tests/mod_with_constant.py +1 -0
- venv/Lib/site-packages/setuptools/tests/namespaces.py +90 -0
- venv/Lib/site-packages/setuptools/tests/script-with-bom.py +1 -0
- venv/Lib/site-packages/setuptools/tests/test_archive_util.py +36 -0
- venv/Lib/site-packages/setuptools/tests/test_bdist_deprecations.py +28 -0
- venv/Lib/site-packages/setuptools/tests/test_bdist_egg.py +73 -0
- venv/Lib/site-packages/setuptools/tests/test_bdist_wheel.py +708 -0
- venv/Lib/site-packages/setuptools/tests/test_build.py +33 -0
- venv/Lib/site-packages/setuptools/tests/test_build_clib.py +84 -0
- venv/Lib/site-packages/setuptools/tests/test_build_ext.py +293 -0
- venv/Lib/site-packages/setuptools/tests/test_build_meta.py +959 -0
- venv/Lib/site-packages/setuptools/tests/test_build_py.py +480 -0
- venv/Lib/site-packages/setuptools/tests/test_config_discovery.py +647 -0
- venv/Lib/site-packages/setuptools/tests/test_core_metadata.py +622 -0
- venv/Lib/site-packages/setuptools/tests/test_depends.py +15 -0
- venv/Lib/site-packages/setuptools/tests/test_develop.py +112 -0
- venv/Lib/site-packages/setuptools/tests/test_dist.py +278 -0
- venv/Lib/site-packages/setuptools/tests/test_dist_info.py +147 -0
- venv/Lib/site-packages/setuptools/tests/test_distutils_adoption.py +198 -0
- venv/Lib/site-packages/setuptools/tests/test_editable_install.py +1263 -0
- venv/Lib/site-packages/setuptools/tests/test_egg_info.py +1306 -0
- venv/Lib/site-packages/setuptools/tests/test_extern.py +15 -0
- venv/Lib/site-packages/setuptools/tests/test_find_packages.py +218 -0
- venv/Lib/site-packages/setuptools/tests/test_find_py_modules.py +73 -0
- venv/Lib/site-packages/setuptools/tests/test_glob.py +45 -0
- venv/Lib/site-packages/setuptools/tests/test_install_scripts.py +89 -0
- venv/Lib/site-packages/setuptools/tests/test_logging.py +76 -0
- venv/Lib/site-packages/setuptools/tests/test_manifest.py +622 -0
- venv/Lib/site-packages/setuptools/tests/test_namespaces.py +138 -0
- venv/Lib/site-packages/setuptools/tests/test_scripts.py +12 -0
- venv/Lib/site-packages/setuptools/tests/test_sdist.py +984 -0
- venv/Lib/site-packages/setuptools/tests/test_setopt.py +40 -0
- venv/Lib/site-packages/setuptools/tests/test_setuptools.py +290 -0
- venv/Lib/site-packages/setuptools/tests/test_shutil_wrapper.py +23 -0
- venv/Lib/site-packages/setuptools/tests/test_unicode_utils.py +10 -0
- venv/Lib/site-packages/setuptools/tests/test_virtualenv.py +113 -0
- venv/Lib/site-packages/setuptools/tests/test_warnings.py +106 -0
- venv/Lib/site-packages/setuptools/tests/test_wheel.py +690 -0
- venv/Lib/site-packages/setuptools/tests/test_windows_wrappers.py +258 -0
- venv/Lib/site-packages/setuptools/tests/text.py +4 -0
- venv/Lib/site-packages/setuptools/tests/textwrap.py +6 -0
- venv/Lib/site-packages/setuptools/unicode_utils.py +102 -0
- venv/Lib/site-packages/setuptools/version.py +6 -0
- venv/Lib/site-packages/setuptools/warnings.py +110 -0
- venv/Lib/site-packages/setuptools/wheel.py +261 -0
- venv/Lib/site-packages/setuptools/windows_support.py +30 -0
- {android_notify-1.60.0.dist-info → android_notify-1.60.2.dist-info}/WHEEL +0 -0
- {android_notify-1.60.0.dist-info → android_notify-1.60.2.dist-info}/entry_points.txt +0 -0
- {android_notify-1.60.0.dist-info → android_notify-1.60.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,908 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Create a wheel that, when installed, will make the source package 'editable'
|
|
3
|
+
(add it to the interpreter's path, including metadata) per PEP 660. Replaces
|
|
4
|
+
'setup.py develop'.
|
|
5
|
+
|
|
6
|
+
.. note::
|
|
7
|
+
One of the mechanisms briefly mentioned in PEP 660 to implement editable installs is
|
|
8
|
+
to create a separated directory inside ``build`` and use a .pth file to point to that
|
|
9
|
+
directory. In the context of this file such directory is referred as
|
|
10
|
+
*auxiliary build directory* or ``auxiliary_dir``.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import io
|
|
16
|
+
import logging
|
|
17
|
+
import os
|
|
18
|
+
import shutil
|
|
19
|
+
import traceback
|
|
20
|
+
from collections.abc import Iterable, Iterator, Mapping
|
|
21
|
+
from contextlib import suppress
|
|
22
|
+
from enum import Enum
|
|
23
|
+
from inspect import cleandoc
|
|
24
|
+
from itertools import chain, starmap
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from tempfile import TemporaryDirectory
|
|
27
|
+
from types import TracebackType
|
|
28
|
+
from typing import TYPE_CHECKING, Protocol, TypeVar, cast
|
|
29
|
+
|
|
30
|
+
from .. import Command, _normalization, _path, _shutil, errors, namespaces
|
|
31
|
+
from .._path import StrPath
|
|
32
|
+
from ..compat import py310, py312
|
|
33
|
+
from ..discovery import find_package_path
|
|
34
|
+
from ..dist import Distribution
|
|
35
|
+
from ..warnings import InformationOnly, SetuptoolsDeprecationWarning
|
|
36
|
+
from .build import build as build_cls
|
|
37
|
+
from .build_py import build_py as build_py_cls
|
|
38
|
+
from .dist_info import dist_info as dist_info_cls
|
|
39
|
+
from .egg_info import egg_info as egg_info_cls
|
|
40
|
+
from .install import install as install_cls
|
|
41
|
+
from .install_scripts import install_scripts as install_scripts_cls
|
|
42
|
+
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from typing_extensions import Self
|
|
45
|
+
|
|
46
|
+
from .._vendor.wheel.wheelfile import WheelFile
|
|
47
|
+
|
|
48
|
+
_P = TypeVar("_P", bound=StrPath)
|
|
49
|
+
_logger = logging.getLogger(__name__)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class _EditableMode(Enum):
|
|
53
|
+
"""
|
|
54
|
+
Possible editable installation modes:
|
|
55
|
+
`lenient` (new files automatically added to the package - DEFAULT);
|
|
56
|
+
`strict` (requires a new installation when files are added/removed); or
|
|
57
|
+
`compat` (attempts to emulate `python setup.py develop` - DEPRECATED).
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
STRICT = "strict"
|
|
61
|
+
LENIENT = "lenient"
|
|
62
|
+
COMPAT = "compat" # TODO: Remove `compat` after Dec/2022.
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
def convert(cls, mode: str | None) -> _EditableMode:
|
|
66
|
+
if not mode:
|
|
67
|
+
return _EditableMode.LENIENT # default
|
|
68
|
+
|
|
69
|
+
_mode = mode.upper()
|
|
70
|
+
if _mode not in _EditableMode.__members__:
|
|
71
|
+
raise errors.OptionError(f"Invalid editable mode: {mode!r}. Try: 'strict'.")
|
|
72
|
+
|
|
73
|
+
if _mode == "COMPAT":
|
|
74
|
+
SetuptoolsDeprecationWarning.emit(
|
|
75
|
+
"Compat editable installs",
|
|
76
|
+
"""
|
|
77
|
+
The 'compat' editable mode is transitional and will be removed
|
|
78
|
+
in future versions of `setuptools`.
|
|
79
|
+
Please adapt your code accordingly to use either the 'strict' or the
|
|
80
|
+
'lenient' modes.
|
|
81
|
+
""",
|
|
82
|
+
see_docs="userguide/development_mode.html",
|
|
83
|
+
# TODO: define due_date
|
|
84
|
+
# There is a series of shortcomings with the available editable install
|
|
85
|
+
# methods, and they are very controversial. This is something that still
|
|
86
|
+
# needs work.
|
|
87
|
+
# Moreover, `pip` is still hiding this warning, so users are not aware.
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return _EditableMode[_mode]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
_STRICT_WARNING = """
|
|
94
|
+
New or renamed files may not be automatically picked up without a new installation.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
_LENIENT_WARNING = """
|
|
98
|
+
Options like `package-data`, `include/exclude-package-data` or
|
|
99
|
+
`packages.find.exclude/include` may have no effect.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class editable_wheel(Command):
|
|
104
|
+
"""Build 'editable' wheel for development.
|
|
105
|
+
This command is private and reserved for internal use of setuptools,
|
|
106
|
+
users should rely on ``setuptools.build_meta`` APIs.
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
description = "DO NOT CALL DIRECTLY, INTERNAL ONLY: create PEP 660 editable wheel"
|
|
110
|
+
|
|
111
|
+
user_options = [
|
|
112
|
+
("dist-dir=", "d", "directory to put final built distributions in"),
|
|
113
|
+
("dist-info-dir=", "I", "path to a pre-build .dist-info directory"),
|
|
114
|
+
("mode=", None, cleandoc(_EditableMode.__doc__ or "")),
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
def initialize_options(self):
|
|
118
|
+
self.dist_dir = None
|
|
119
|
+
self.dist_info_dir = None
|
|
120
|
+
self.project_dir = None
|
|
121
|
+
self.mode = None
|
|
122
|
+
|
|
123
|
+
def finalize_options(self) -> None:
|
|
124
|
+
dist = self.distribution
|
|
125
|
+
self.project_dir = dist.src_root or os.curdir
|
|
126
|
+
self.package_dir = dist.package_dir or {}
|
|
127
|
+
self.dist_dir = Path(self.dist_dir or os.path.join(self.project_dir, "dist"))
|
|
128
|
+
|
|
129
|
+
def run(self) -> None:
|
|
130
|
+
try:
|
|
131
|
+
self.dist_dir.mkdir(exist_ok=True)
|
|
132
|
+
self._ensure_dist_info()
|
|
133
|
+
|
|
134
|
+
# Add missing dist_info files
|
|
135
|
+
self.reinitialize_command("bdist_wheel")
|
|
136
|
+
bdist_wheel = self.get_finalized_command("bdist_wheel")
|
|
137
|
+
bdist_wheel.write_wheelfile(self.dist_info_dir)
|
|
138
|
+
|
|
139
|
+
self._create_wheel_file(bdist_wheel)
|
|
140
|
+
except Exception as ex:
|
|
141
|
+
project = self.distribution.name or self.distribution.get_name()
|
|
142
|
+
py310.add_note(
|
|
143
|
+
ex,
|
|
144
|
+
f"An error occurred when building editable wheel for {project}.\n"
|
|
145
|
+
"See debugging tips in: "
|
|
146
|
+
"https://setuptools.pypa.io/en/latest/userguide/development_mode.html#debugging-tips",
|
|
147
|
+
)
|
|
148
|
+
raise
|
|
149
|
+
|
|
150
|
+
def _ensure_dist_info(self):
|
|
151
|
+
if self.dist_info_dir is None:
|
|
152
|
+
dist_info = cast(dist_info_cls, self.reinitialize_command("dist_info"))
|
|
153
|
+
dist_info.output_dir = self.dist_dir
|
|
154
|
+
dist_info.ensure_finalized()
|
|
155
|
+
dist_info.run()
|
|
156
|
+
self.dist_info_dir = dist_info.dist_info_dir
|
|
157
|
+
else:
|
|
158
|
+
assert str(self.dist_info_dir).endswith(".dist-info")
|
|
159
|
+
assert Path(self.dist_info_dir, "METADATA").exists()
|
|
160
|
+
|
|
161
|
+
def _install_namespaces(self, installation_dir, pth_prefix):
|
|
162
|
+
# XXX: Only required to support the deprecated namespace practice
|
|
163
|
+
dist = self.distribution
|
|
164
|
+
if not dist.namespace_packages:
|
|
165
|
+
return
|
|
166
|
+
|
|
167
|
+
src_root = Path(self.project_dir, self.package_dir.get("", ".")).resolve()
|
|
168
|
+
installer = _NamespaceInstaller(dist, installation_dir, pth_prefix, src_root)
|
|
169
|
+
installer.install_namespaces()
|
|
170
|
+
|
|
171
|
+
def _find_egg_info_dir(self) -> str | None:
|
|
172
|
+
parent_dir = Path(self.dist_info_dir).parent if self.dist_info_dir else Path()
|
|
173
|
+
candidates = map(str, parent_dir.glob("*.egg-info"))
|
|
174
|
+
return next(candidates, None)
|
|
175
|
+
|
|
176
|
+
def _configure_build(
|
|
177
|
+
self, name: str, unpacked_wheel: StrPath, build_lib: StrPath, tmp_dir: StrPath
|
|
178
|
+
):
|
|
179
|
+
"""Configure commands to behave in the following ways:
|
|
180
|
+
|
|
181
|
+
- Build commands can write to ``build_lib`` if they really want to...
|
|
182
|
+
(but this folder is expected to be ignored and modules are expected to live
|
|
183
|
+
in the project directory...)
|
|
184
|
+
- Binary extensions should be built in-place (editable_mode = True)
|
|
185
|
+
- Data/header/script files are not part of the "editable" specification
|
|
186
|
+
so they are written directly to the unpacked_wheel directory.
|
|
187
|
+
"""
|
|
188
|
+
# Non-editable files (data, headers, scripts) are written directly to the
|
|
189
|
+
# unpacked_wheel
|
|
190
|
+
|
|
191
|
+
dist = self.distribution
|
|
192
|
+
wheel = str(unpacked_wheel)
|
|
193
|
+
build_lib = str(build_lib)
|
|
194
|
+
data = str(Path(unpacked_wheel, f"{name}.data", "data"))
|
|
195
|
+
headers = str(Path(unpacked_wheel, f"{name}.data", "headers"))
|
|
196
|
+
scripts = str(Path(unpacked_wheel, f"{name}.data", "scripts"))
|
|
197
|
+
|
|
198
|
+
# egg-info may be generated again to create a manifest (used for package data)
|
|
199
|
+
egg_info = cast(
|
|
200
|
+
egg_info_cls, dist.reinitialize_command("egg_info", reinit_subcommands=True)
|
|
201
|
+
)
|
|
202
|
+
egg_info.egg_base = str(tmp_dir)
|
|
203
|
+
egg_info.ignore_egg_info_in_manifest = True
|
|
204
|
+
|
|
205
|
+
build = cast(
|
|
206
|
+
build_cls, dist.reinitialize_command("build", reinit_subcommands=True)
|
|
207
|
+
)
|
|
208
|
+
install = cast(
|
|
209
|
+
install_cls, dist.reinitialize_command("install", reinit_subcommands=True)
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
build.build_platlib = build.build_purelib = build.build_lib = build_lib
|
|
213
|
+
install.install_purelib = install.install_platlib = install.install_lib = wheel
|
|
214
|
+
install.install_scripts = build.build_scripts = scripts
|
|
215
|
+
install.install_headers = headers
|
|
216
|
+
install.install_data = data
|
|
217
|
+
|
|
218
|
+
# For portability, ensure scripts are built with #!python shebang
|
|
219
|
+
# pypa/setuptools#4863
|
|
220
|
+
build_scripts = dist.get_command_obj("build_scripts")
|
|
221
|
+
build_scripts.executable = 'python'
|
|
222
|
+
|
|
223
|
+
install_scripts = cast(
|
|
224
|
+
install_scripts_cls, dist.get_command_obj("install_scripts")
|
|
225
|
+
)
|
|
226
|
+
install_scripts.no_ep = True
|
|
227
|
+
|
|
228
|
+
build.build_temp = str(tmp_dir)
|
|
229
|
+
|
|
230
|
+
build_py = cast(build_py_cls, dist.get_command_obj("build_py"))
|
|
231
|
+
build_py.compile = False
|
|
232
|
+
build_py.existing_egg_info_dir = self._find_egg_info_dir()
|
|
233
|
+
|
|
234
|
+
self._set_editable_mode()
|
|
235
|
+
|
|
236
|
+
build.ensure_finalized()
|
|
237
|
+
install.ensure_finalized()
|
|
238
|
+
|
|
239
|
+
def _set_editable_mode(self):
|
|
240
|
+
"""Set the ``editable_mode`` flag in the build sub-commands"""
|
|
241
|
+
dist = self.distribution
|
|
242
|
+
build = dist.get_command_obj("build")
|
|
243
|
+
for cmd_name in build.get_sub_commands():
|
|
244
|
+
cmd = dist.get_command_obj(cmd_name)
|
|
245
|
+
if hasattr(cmd, "editable_mode"):
|
|
246
|
+
cmd.editable_mode = True
|
|
247
|
+
elif hasattr(cmd, "inplace"):
|
|
248
|
+
cmd.inplace = True # backward compatibility with distutils
|
|
249
|
+
|
|
250
|
+
def _collect_build_outputs(self) -> tuple[list[str], dict[str, str]]:
|
|
251
|
+
files: list[str] = []
|
|
252
|
+
mapping: dict[str, str] = {}
|
|
253
|
+
build = self.get_finalized_command("build")
|
|
254
|
+
|
|
255
|
+
for cmd_name in build.get_sub_commands():
|
|
256
|
+
cmd = self.get_finalized_command(cmd_name)
|
|
257
|
+
if hasattr(cmd, "get_outputs"):
|
|
258
|
+
files.extend(cmd.get_outputs() or [])
|
|
259
|
+
if hasattr(cmd, "get_output_mapping"):
|
|
260
|
+
mapping.update(cmd.get_output_mapping() or {})
|
|
261
|
+
|
|
262
|
+
return files, mapping
|
|
263
|
+
|
|
264
|
+
def _run_build_commands(
|
|
265
|
+
self,
|
|
266
|
+
dist_name: str,
|
|
267
|
+
unpacked_wheel: StrPath,
|
|
268
|
+
build_lib: StrPath,
|
|
269
|
+
tmp_dir: StrPath,
|
|
270
|
+
) -> tuple[list[str], dict[str, str]]:
|
|
271
|
+
self._configure_build(dist_name, unpacked_wheel, build_lib, tmp_dir)
|
|
272
|
+
self._run_build_subcommands()
|
|
273
|
+
files, mapping = self._collect_build_outputs()
|
|
274
|
+
self._run_install("headers")
|
|
275
|
+
self._run_install("scripts")
|
|
276
|
+
self._run_install("data")
|
|
277
|
+
return files, mapping
|
|
278
|
+
|
|
279
|
+
def _run_build_subcommands(self) -> None:
|
|
280
|
+
"""
|
|
281
|
+
Issue #3501 indicates that some plugins/customizations might rely on:
|
|
282
|
+
|
|
283
|
+
1. ``build_py`` not running
|
|
284
|
+
2. ``build_py`` always copying files to ``build_lib``
|
|
285
|
+
|
|
286
|
+
However both these assumptions may be false in editable_wheel.
|
|
287
|
+
This method implements a temporary workaround to support the ecosystem
|
|
288
|
+
while the implementations catch up.
|
|
289
|
+
"""
|
|
290
|
+
# TODO: Once plugins/customizations had the chance to catch up, replace
|
|
291
|
+
# `self._run_build_subcommands()` with `self.run_command("build")`.
|
|
292
|
+
# Also remove _safely_run, TestCustomBuildPy. Suggested date: Aug/2023.
|
|
293
|
+
build = self.get_finalized_command("build")
|
|
294
|
+
for name in build.get_sub_commands():
|
|
295
|
+
cmd = self.get_finalized_command(name)
|
|
296
|
+
if name == "build_py" and type(cmd) is not build_py_cls:
|
|
297
|
+
self._safely_run(name)
|
|
298
|
+
else:
|
|
299
|
+
self.run_command(name)
|
|
300
|
+
|
|
301
|
+
def _safely_run(self, cmd_name: str):
|
|
302
|
+
try:
|
|
303
|
+
return self.run_command(cmd_name)
|
|
304
|
+
except Exception:
|
|
305
|
+
SetuptoolsDeprecationWarning.emit(
|
|
306
|
+
"Customization incompatible with editable install",
|
|
307
|
+
f"""
|
|
308
|
+
{traceback.format_exc()}
|
|
309
|
+
|
|
310
|
+
If you are seeing this warning it is very likely that a setuptools
|
|
311
|
+
plugin or customization overrides the `{cmd_name}` command, without
|
|
312
|
+
taking into consideration how editable installs run build steps
|
|
313
|
+
starting from setuptools v64.0.0.
|
|
314
|
+
|
|
315
|
+
Plugin authors and developers relying on custom build steps are
|
|
316
|
+
encouraged to update their `{cmd_name}` implementation considering the
|
|
317
|
+
information about editable installs in
|
|
318
|
+
https://setuptools.pypa.io/en/latest/userguide/extension.html.
|
|
319
|
+
|
|
320
|
+
For the time being `setuptools` will silence this error and ignore
|
|
321
|
+
the faulty command, but this behavior will change in future versions.
|
|
322
|
+
""",
|
|
323
|
+
# TODO: define due_date
|
|
324
|
+
# There is a series of shortcomings with the available editable install
|
|
325
|
+
# methods, and they are very controversial. This is something that still
|
|
326
|
+
# needs work.
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
def _create_wheel_file(self, bdist_wheel):
|
|
330
|
+
from wheel.wheelfile import WheelFile
|
|
331
|
+
|
|
332
|
+
dist_info = self.get_finalized_command("dist_info")
|
|
333
|
+
dist_name = dist_info.name
|
|
334
|
+
tag = "-".join(bdist_wheel.get_tag())
|
|
335
|
+
build_tag = "0.editable" # According to PEP 427 needs to start with digit
|
|
336
|
+
archive_name = f"{dist_name}-{build_tag}-{tag}.whl"
|
|
337
|
+
wheel_path = Path(self.dist_dir, archive_name)
|
|
338
|
+
if wheel_path.exists():
|
|
339
|
+
wheel_path.unlink()
|
|
340
|
+
|
|
341
|
+
unpacked_wheel = TemporaryDirectory(suffix=archive_name)
|
|
342
|
+
build_lib = TemporaryDirectory(suffix=".build-lib")
|
|
343
|
+
build_tmp = TemporaryDirectory(suffix=".build-temp")
|
|
344
|
+
|
|
345
|
+
with unpacked_wheel as unpacked, build_lib as lib, build_tmp as tmp:
|
|
346
|
+
unpacked_dist_info = Path(unpacked, Path(self.dist_info_dir).name)
|
|
347
|
+
shutil.copytree(self.dist_info_dir, unpacked_dist_info)
|
|
348
|
+
self._install_namespaces(unpacked, dist_name)
|
|
349
|
+
files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
|
|
350
|
+
strategy = self._select_strategy(dist_name, tag, lib)
|
|
351
|
+
with strategy, WheelFile(wheel_path, "w") as wheel_obj:
|
|
352
|
+
strategy(wheel_obj, files, mapping)
|
|
353
|
+
wheel_obj.write_files(unpacked)
|
|
354
|
+
|
|
355
|
+
return wheel_path
|
|
356
|
+
|
|
357
|
+
def _run_install(self, category: str):
|
|
358
|
+
has_category = getattr(self.distribution, f"has_{category}", None)
|
|
359
|
+
if has_category and has_category():
|
|
360
|
+
_logger.info(f"Installing {category} as non editable")
|
|
361
|
+
self.run_command(f"install_{category}")
|
|
362
|
+
|
|
363
|
+
def _select_strategy(
|
|
364
|
+
self,
|
|
365
|
+
name: str,
|
|
366
|
+
tag: str,
|
|
367
|
+
build_lib: StrPath,
|
|
368
|
+
) -> EditableStrategy:
|
|
369
|
+
"""Decides which strategy to use to implement an editable installation."""
|
|
370
|
+
build_name = f"__editable__.{name}-{tag}"
|
|
371
|
+
project_dir = Path(self.project_dir)
|
|
372
|
+
mode = _EditableMode.convert(self.mode)
|
|
373
|
+
|
|
374
|
+
if mode is _EditableMode.STRICT:
|
|
375
|
+
auxiliary_dir = _empty_dir(Path(self.project_dir, "build", build_name))
|
|
376
|
+
return _LinkTree(self.distribution, name, auxiliary_dir, build_lib)
|
|
377
|
+
|
|
378
|
+
packages = _find_packages(self.distribution)
|
|
379
|
+
has_simple_layout = _simple_layout(packages, self.package_dir, project_dir)
|
|
380
|
+
is_compat_mode = mode is _EditableMode.COMPAT
|
|
381
|
+
if set(self.package_dir) == {""} and has_simple_layout or is_compat_mode:
|
|
382
|
+
# src-layout(ish) is relatively safe for a simple pth file
|
|
383
|
+
src_dir = self.package_dir.get("", ".")
|
|
384
|
+
return _StaticPth(self.distribution, name, [Path(project_dir, src_dir)])
|
|
385
|
+
|
|
386
|
+
# Use a MetaPathFinder to avoid adding accidental top-level packages/modules
|
|
387
|
+
return _TopLevelFinder(self.distribution, name)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
class EditableStrategy(Protocol):
|
|
391
|
+
def __call__(
|
|
392
|
+
self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]
|
|
393
|
+
) -> object: ...
|
|
394
|
+
def __enter__(self) -> Self: ...
|
|
395
|
+
def __exit__(
|
|
396
|
+
self,
|
|
397
|
+
_exc_type: type[BaseException] | None,
|
|
398
|
+
_exc_value: BaseException | None,
|
|
399
|
+
_traceback: TracebackType | None,
|
|
400
|
+
) -> object: ...
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
class _StaticPth:
|
|
404
|
+
def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> None:
|
|
405
|
+
self.dist = dist
|
|
406
|
+
self.name = name
|
|
407
|
+
self.path_entries = path_entries
|
|
408
|
+
|
|
409
|
+
def __call__(self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]):
|
|
410
|
+
entries = "\n".join(str(p.resolve()) for p in self.path_entries)
|
|
411
|
+
contents = _encode_pth(f"{entries}\n")
|
|
412
|
+
wheel.writestr(f"__editable__.{self.name}.pth", contents)
|
|
413
|
+
|
|
414
|
+
def __enter__(self) -> Self:
|
|
415
|
+
msg = f"""
|
|
416
|
+
Editable install will be performed using .pth file to extend `sys.path` with:
|
|
417
|
+
{list(map(os.fspath, self.path_entries))!r}
|
|
418
|
+
"""
|
|
419
|
+
_logger.warning(msg + _LENIENT_WARNING)
|
|
420
|
+
return self
|
|
421
|
+
|
|
422
|
+
def __exit__(
|
|
423
|
+
self,
|
|
424
|
+
_exc_type: object,
|
|
425
|
+
_exc_value: object,
|
|
426
|
+
_traceback: object,
|
|
427
|
+
) -> None:
|
|
428
|
+
pass
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
class _LinkTree(_StaticPth):
|
|
432
|
+
"""
|
|
433
|
+
Creates a ``.pth`` file that points to a link tree in the ``auxiliary_dir``.
|
|
434
|
+
|
|
435
|
+
This strategy will only link files (not dirs), so it can be implemented in
|
|
436
|
+
any OS, even if that means using hardlinks instead of symlinks.
|
|
437
|
+
|
|
438
|
+
By collocating ``auxiliary_dir`` and the original source code, limitations
|
|
439
|
+
with hardlinks should be avoided.
|
|
440
|
+
"""
|
|
441
|
+
|
|
442
|
+
def __init__(
|
|
443
|
+
self,
|
|
444
|
+
dist: Distribution,
|
|
445
|
+
name: str,
|
|
446
|
+
auxiliary_dir: StrPath,
|
|
447
|
+
build_lib: StrPath,
|
|
448
|
+
) -> None:
|
|
449
|
+
self.auxiliary_dir = Path(auxiliary_dir)
|
|
450
|
+
self.build_lib = Path(build_lib).resolve()
|
|
451
|
+
self._file = dist.get_command_obj("build_py").copy_file
|
|
452
|
+
super().__init__(dist, name, [self.auxiliary_dir])
|
|
453
|
+
|
|
454
|
+
def __call__(self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]):
|
|
455
|
+
self._create_links(files, mapping)
|
|
456
|
+
super().__call__(wheel, files, mapping)
|
|
457
|
+
|
|
458
|
+
def _normalize_output(self, file: str) -> str | None:
|
|
459
|
+
# Files relative to build_lib will be normalized to None
|
|
460
|
+
with suppress(ValueError):
|
|
461
|
+
path = Path(file).resolve().relative_to(self.build_lib)
|
|
462
|
+
return str(path).replace(os.sep, '/')
|
|
463
|
+
return None
|
|
464
|
+
|
|
465
|
+
def _create_file(self, relative_output: str, src_file: str, link=None):
|
|
466
|
+
dest = self.auxiliary_dir / relative_output
|
|
467
|
+
if not dest.parent.is_dir():
|
|
468
|
+
dest.parent.mkdir(parents=True)
|
|
469
|
+
self._file(src_file, dest, link=link)
|
|
470
|
+
|
|
471
|
+
def _create_links(self, outputs, output_mapping: Mapping[str, str]):
|
|
472
|
+
self.auxiliary_dir.mkdir(parents=True, exist_ok=True)
|
|
473
|
+
link_type = "sym" if _can_symlink_files(self.auxiliary_dir) else "hard"
|
|
474
|
+
normalised = ((self._normalize_output(k), v) for k, v in output_mapping.items())
|
|
475
|
+
# remove files that are not relative to build_lib
|
|
476
|
+
mappings = {k: v for k, v in normalised if k is not None}
|
|
477
|
+
|
|
478
|
+
for output in outputs:
|
|
479
|
+
relative = self._normalize_output(output)
|
|
480
|
+
if relative and relative not in mappings:
|
|
481
|
+
self._create_file(relative, output)
|
|
482
|
+
|
|
483
|
+
for relative, src in mappings.items():
|
|
484
|
+
self._create_file(relative, src, link=link_type)
|
|
485
|
+
|
|
486
|
+
def __enter__(self) -> Self:
|
|
487
|
+
msg = "Strict editable install will be performed using a link tree.\n"
|
|
488
|
+
_logger.warning(msg + _STRICT_WARNING)
|
|
489
|
+
return self
|
|
490
|
+
|
|
491
|
+
def __exit__(
|
|
492
|
+
self,
|
|
493
|
+
_exc_type: object,
|
|
494
|
+
_exc_value: object,
|
|
495
|
+
_traceback: object,
|
|
496
|
+
) -> None:
|
|
497
|
+
msg = f"""\n
|
|
498
|
+
Strict editable installation performed using the auxiliary directory:
|
|
499
|
+
{self.auxiliary_dir}
|
|
500
|
+
|
|
501
|
+
Please be careful to not remove this directory, otherwise you might not be able
|
|
502
|
+
to import/use your package.
|
|
503
|
+
"""
|
|
504
|
+
InformationOnly.emit("Editable installation.", msg)
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
class _TopLevelFinder:
|
|
508
|
+
def __init__(self, dist: Distribution, name: str) -> None:
|
|
509
|
+
self.dist = dist
|
|
510
|
+
self.name = name
|
|
511
|
+
|
|
512
|
+
def template_vars(self) -> tuple[str, str, dict[str, str], dict[str, list[str]]]:
|
|
513
|
+
src_root = self.dist.src_root or os.curdir
|
|
514
|
+
top_level = chain(_find_packages(self.dist), _find_top_level_modules(self.dist))
|
|
515
|
+
package_dir = self.dist.package_dir or {}
|
|
516
|
+
roots = _find_package_roots(top_level, package_dir, src_root)
|
|
517
|
+
|
|
518
|
+
namespaces_ = dict(
|
|
519
|
+
chain(
|
|
520
|
+
_find_namespaces(self.dist.packages or [], roots),
|
|
521
|
+
((ns, []) for ns in _find_virtual_namespaces(roots)),
|
|
522
|
+
)
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
legacy_namespaces = {
|
|
526
|
+
pkg: find_package_path(pkg, roots, self.dist.src_root or "")
|
|
527
|
+
for pkg in self.dist.namespace_packages or []
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
mapping = {**roots, **legacy_namespaces}
|
|
531
|
+
# ^-- We need to explicitly add the legacy_namespaces to the mapping to be
|
|
532
|
+
# able to import their modules even if another package sharing the same
|
|
533
|
+
# namespace is installed in a conventional (non-editable) way.
|
|
534
|
+
|
|
535
|
+
name = f"__editable__.{self.name}.finder"
|
|
536
|
+
finder = _normalization.safe_identifier(name)
|
|
537
|
+
return finder, name, mapping, namespaces_
|
|
538
|
+
|
|
539
|
+
def get_implementation(self) -> Iterator[tuple[str, bytes]]:
|
|
540
|
+
finder, name, mapping, namespaces_ = self.template_vars()
|
|
541
|
+
|
|
542
|
+
content = bytes(_finder_template(name, mapping, namespaces_), "utf-8")
|
|
543
|
+
yield (f"{finder}.py", content)
|
|
544
|
+
|
|
545
|
+
content = _encode_pth(f"import {finder}; {finder}.install()")
|
|
546
|
+
yield (f"__editable__.{self.name}.pth", content)
|
|
547
|
+
|
|
548
|
+
def __call__(self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]):
|
|
549
|
+
for file, content in self.get_implementation():
|
|
550
|
+
wheel.writestr(file, content)
|
|
551
|
+
|
|
552
|
+
def __enter__(self) -> Self:
|
|
553
|
+
msg = "Editable install will be performed using a meta path finder.\n"
|
|
554
|
+
_logger.warning(msg + _LENIENT_WARNING)
|
|
555
|
+
return self
|
|
556
|
+
|
|
557
|
+
def __exit__(
|
|
558
|
+
self,
|
|
559
|
+
_exc_type: object,
|
|
560
|
+
_exc_value: object,
|
|
561
|
+
_traceback: object,
|
|
562
|
+
) -> None:
|
|
563
|
+
msg = """\n
|
|
564
|
+
Please be careful with folders in your working directory with the same
|
|
565
|
+
name as your package as they may take precedence during imports.
|
|
566
|
+
"""
|
|
567
|
+
InformationOnly.emit("Editable installation.", msg)
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
def _encode_pth(content: str) -> bytes:
|
|
571
|
+
"""
|
|
572
|
+
Prior to Python 3.13 (see https://github.com/python/cpython/issues/77102),
|
|
573
|
+
.pth files are always read with 'locale' encoding, the recommendation
|
|
574
|
+
from the cpython core developers is to write them as ``open(path, "w")``
|
|
575
|
+
and ignore warnings (see python/cpython#77102, pypa/setuptools#3937).
|
|
576
|
+
This function tries to simulate this behavior without having to create an
|
|
577
|
+
actual file, in a way that supports a range of active Python versions.
|
|
578
|
+
(There seems to be some variety in the way different version of Python handle
|
|
579
|
+
``encoding=None``, not all of them use ``locale.getpreferredencoding(False)``
|
|
580
|
+
or ``locale.getencoding()``).
|
|
581
|
+
"""
|
|
582
|
+
with io.BytesIO() as buffer:
|
|
583
|
+
wrapper = io.TextIOWrapper(buffer, encoding=py312.PTH_ENCODING)
|
|
584
|
+
# TODO: Python 3.13 replace the whole function with `bytes(content, "utf-8")`
|
|
585
|
+
wrapper.write(content)
|
|
586
|
+
wrapper.flush()
|
|
587
|
+
buffer.seek(0)
|
|
588
|
+
return buffer.read()
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
def _can_symlink_files(base_dir: Path) -> bool:
|
|
592
|
+
with TemporaryDirectory(dir=str(base_dir.resolve())) as tmp:
|
|
593
|
+
path1, path2 = Path(tmp, "file1.txt"), Path(tmp, "file2.txt")
|
|
594
|
+
path1.write_text("file1", encoding="utf-8")
|
|
595
|
+
with suppress(AttributeError, NotImplementedError, OSError):
|
|
596
|
+
os.symlink(path1, path2)
|
|
597
|
+
if path2.is_symlink() and path2.read_text(encoding="utf-8") == "file1":
|
|
598
|
+
return True
|
|
599
|
+
|
|
600
|
+
try:
|
|
601
|
+
os.link(path1, path2) # Ensure hard links can be created
|
|
602
|
+
except Exception as ex:
|
|
603
|
+
msg = (
|
|
604
|
+
"File system does not seem to support either symlinks or hard links. "
|
|
605
|
+
"Strict editable installs require one of them to be supported."
|
|
606
|
+
)
|
|
607
|
+
raise LinksNotSupported(msg) from ex
|
|
608
|
+
return False
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
def _simple_layout(
|
|
612
|
+
packages: Iterable[str], package_dir: dict[str, str], project_dir: StrPath
|
|
613
|
+
) -> bool:
|
|
614
|
+
"""Return ``True`` if:
|
|
615
|
+
- all packages are contained by the same parent directory, **and**
|
|
616
|
+
- all packages become importable if the parent directory is added to ``sys.path``.
|
|
617
|
+
|
|
618
|
+
>>> _simple_layout(['a'], {"": "src"}, "/tmp/myproj")
|
|
619
|
+
True
|
|
620
|
+
>>> _simple_layout(['a', 'a.b'], {"": "src"}, "/tmp/myproj")
|
|
621
|
+
True
|
|
622
|
+
>>> _simple_layout(['a', 'a.b'], {}, "/tmp/myproj")
|
|
623
|
+
True
|
|
624
|
+
>>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"": "src"}, "/tmp/myproj")
|
|
625
|
+
True
|
|
626
|
+
>>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "a", "b": "b"}, ".")
|
|
627
|
+
True
|
|
628
|
+
>>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "_a", "b": "_b"}, ".")
|
|
629
|
+
False
|
|
630
|
+
>>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "_a"}, "/tmp/myproj")
|
|
631
|
+
False
|
|
632
|
+
>>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a.a1.a2": "_a2"}, ".")
|
|
633
|
+
False
|
|
634
|
+
>>> _simple_layout(['a', 'a.b'], {"": "src", "a.b": "_ab"}, "/tmp/myproj")
|
|
635
|
+
False
|
|
636
|
+
>>> # Special cases, no packages yet:
|
|
637
|
+
>>> _simple_layout([], {"": "src"}, "/tmp/myproj")
|
|
638
|
+
True
|
|
639
|
+
>>> _simple_layout([], {"a": "_a", "": "src"}, "/tmp/myproj")
|
|
640
|
+
False
|
|
641
|
+
"""
|
|
642
|
+
layout = {pkg: find_package_path(pkg, package_dir, project_dir) for pkg in packages}
|
|
643
|
+
if not layout:
|
|
644
|
+
return set(package_dir) in ({}, {""})
|
|
645
|
+
parent = os.path.commonpath(starmap(_parent_path, layout.items()))
|
|
646
|
+
return all(
|
|
647
|
+
_path.same_path(Path(parent, *key.split('.')), value)
|
|
648
|
+
for key, value in layout.items()
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
def _parent_path(pkg, pkg_path):
|
|
653
|
+
"""Infer the parent path containing a package, that if added to ``sys.path`` would
|
|
654
|
+
allow importing that package.
|
|
655
|
+
When ``pkg`` is directly mapped into a directory with a different name, return its
|
|
656
|
+
own path.
|
|
657
|
+
>>> _parent_path("a", "src/a")
|
|
658
|
+
'src'
|
|
659
|
+
>>> _parent_path("b", "src/c")
|
|
660
|
+
'src/c'
|
|
661
|
+
"""
|
|
662
|
+
parent = pkg_path[: -len(pkg)] if pkg_path.endswith(pkg) else pkg_path
|
|
663
|
+
return parent.rstrip("/" + os.sep)
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
def _find_packages(dist: Distribution) -> Iterator[str]:
|
|
667
|
+
yield from iter(dist.packages or [])
|
|
668
|
+
|
|
669
|
+
py_modules = dist.py_modules or []
|
|
670
|
+
nested_modules = [mod for mod in py_modules if "." in mod]
|
|
671
|
+
if dist.ext_package:
|
|
672
|
+
yield dist.ext_package
|
|
673
|
+
else:
|
|
674
|
+
ext_modules = dist.ext_modules or []
|
|
675
|
+
nested_modules += [x.name for x in ext_modules if "." in x.name]
|
|
676
|
+
|
|
677
|
+
for module in nested_modules:
|
|
678
|
+
package, _, _ = module.rpartition(".")
|
|
679
|
+
yield package
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
def _find_top_level_modules(dist: Distribution) -> Iterator[str]:
|
|
683
|
+
py_modules = dist.py_modules or []
|
|
684
|
+
yield from (mod for mod in py_modules if "." not in mod)
|
|
685
|
+
|
|
686
|
+
if not dist.ext_package:
|
|
687
|
+
ext_modules = dist.ext_modules or []
|
|
688
|
+
yield from (x.name for x in ext_modules if "." not in x.name)
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
def _find_package_roots(
|
|
692
|
+
packages: Iterable[str],
|
|
693
|
+
package_dir: Mapping[str, str],
|
|
694
|
+
src_root: StrPath,
|
|
695
|
+
) -> dict[str, str]:
|
|
696
|
+
pkg_roots: dict[str, str] = {
|
|
697
|
+
pkg: _absolute_root(find_package_path(pkg, package_dir, src_root))
|
|
698
|
+
for pkg in sorted(packages)
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
return _remove_nested(pkg_roots)
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
def _absolute_root(path: StrPath) -> str:
|
|
705
|
+
"""Works for packages and top-level modules"""
|
|
706
|
+
path_ = Path(path)
|
|
707
|
+
parent = path_.parent
|
|
708
|
+
|
|
709
|
+
if path_.exists():
|
|
710
|
+
return str(path_.resolve())
|
|
711
|
+
else:
|
|
712
|
+
return str(parent.resolve() / path_.name)
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
def _find_virtual_namespaces(pkg_roots: dict[str, str]) -> Iterator[str]:
|
|
716
|
+
"""By carefully designing ``package_dir``, it is possible to implement the logical
|
|
717
|
+
structure of PEP 420 in a package without the corresponding directories.
|
|
718
|
+
|
|
719
|
+
Moreover a parent package can be purposefully/accidentally skipped in the discovery
|
|
720
|
+
phase (e.g. ``find_packages(include=["mypkg.*"])``, when ``mypkg.foo`` is included
|
|
721
|
+
by ``mypkg`` itself is not).
|
|
722
|
+
We consider this case to also be a virtual namespace (ignoring the original
|
|
723
|
+
directory) to emulate a non-editable installation.
|
|
724
|
+
|
|
725
|
+
This function will try to find these kinds of namespaces.
|
|
726
|
+
"""
|
|
727
|
+
for pkg in pkg_roots:
|
|
728
|
+
if "." not in pkg:
|
|
729
|
+
continue
|
|
730
|
+
parts = pkg.split(".")
|
|
731
|
+
for i in range(len(parts) - 1, 0, -1):
|
|
732
|
+
partial_name = ".".join(parts[:i])
|
|
733
|
+
path = Path(find_package_path(partial_name, pkg_roots, ""))
|
|
734
|
+
if not path.exists() or partial_name not in pkg_roots:
|
|
735
|
+
# partial_name not in pkg_roots ==> purposefully/accidentally skipped
|
|
736
|
+
yield partial_name
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
def _find_namespaces(
|
|
740
|
+
packages: list[str], pkg_roots: dict[str, str]
|
|
741
|
+
) -> Iterator[tuple[str, list[str]]]:
|
|
742
|
+
for pkg in packages:
|
|
743
|
+
path = find_package_path(pkg, pkg_roots, "")
|
|
744
|
+
if Path(path).exists() and not Path(path, "__init__.py").exists():
|
|
745
|
+
yield (pkg, [path])
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
def _remove_nested(pkg_roots: dict[str, str]) -> dict[str, str]:
|
|
749
|
+
output = dict(pkg_roots.copy())
|
|
750
|
+
|
|
751
|
+
for pkg, path in reversed(list(pkg_roots.items())):
|
|
752
|
+
if any(
|
|
753
|
+
pkg != other and _is_nested(pkg, path, other, other_path)
|
|
754
|
+
for other, other_path in pkg_roots.items()
|
|
755
|
+
):
|
|
756
|
+
output.pop(pkg)
|
|
757
|
+
|
|
758
|
+
return output
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
def _is_nested(pkg: str, pkg_path: str, parent: str, parent_path: str) -> bool:
|
|
762
|
+
"""
|
|
763
|
+
Return ``True`` if ``pkg`` is nested inside ``parent`` both logically and in the
|
|
764
|
+
file system.
|
|
765
|
+
>>> _is_nested("a.b", "path/a/b", "a", "path/a")
|
|
766
|
+
True
|
|
767
|
+
>>> _is_nested("a.b", "path/a/b", "a", "otherpath/a")
|
|
768
|
+
False
|
|
769
|
+
>>> _is_nested("a.b", "path/a/b", "c", "path/c")
|
|
770
|
+
False
|
|
771
|
+
>>> _is_nested("a.a", "path/a/a", "a", "path/a")
|
|
772
|
+
True
|
|
773
|
+
>>> _is_nested("b.a", "path/b/a", "a", "path/a")
|
|
774
|
+
False
|
|
775
|
+
"""
|
|
776
|
+
norm_pkg_path = _path.normpath(pkg_path)
|
|
777
|
+
rest = pkg.replace(parent, "", 1).strip(".").split(".")
|
|
778
|
+
return pkg.startswith(parent) and norm_pkg_path == _path.normpath(
|
|
779
|
+
Path(parent_path, *rest)
|
|
780
|
+
)
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
def _empty_dir(dir_: _P) -> _P:
|
|
784
|
+
"""Create a directory ensured to be empty. Existing files may be removed."""
|
|
785
|
+
_shutil.rmtree(dir_, ignore_errors=True)
|
|
786
|
+
os.makedirs(dir_)
|
|
787
|
+
return dir_
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
class _NamespaceInstaller(namespaces.Installer):
|
|
791
|
+
def __init__(self, distribution, installation_dir, editable_name, src_root) -> None:
|
|
792
|
+
self.distribution = distribution
|
|
793
|
+
self.src_root = src_root
|
|
794
|
+
self.installation_dir = installation_dir
|
|
795
|
+
self.editable_name = editable_name
|
|
796
|
+
self.outputs: list[str] = []
|
|
797
|
+
self.dry_run = False
|
|
798
|
+
|
|
799
|
+
def _get_nspkg_file(self):
|
|
800
|
+
"""Installation target."""
|
|
801
|
+
return os.path.join(self.installation_dir, self.editable_name + self.nspkg_ext)
|
|
802
|
+
|
|
803
|
+
def _get_root(self):
|
|
804
|
+
"""Where the modules/packages should be loaded from."""
|
|
805
|
+
return repr(str(self.src_root))
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
_FINDER_TEMPLATE = """\
|
|
809
|
+
from __future__ import annotations
|
|
810
|
+
import sys
|
|
811
|
+
from importlib.machinery import ModuleSpec, PathFinder
|
|
812
|
+
from importlib.machinery import all_suffixes as module_suffixes
|
|
813
|
+
from importlib.util import spec_from_file_location
|
|
814
|
+
from itertools import chain
|
|
815
|
+
from pathlib import Path
|
|
816
|
+
|
|
817
|
+
MAPPING: dict[str, str] = {mapping!r}
|
|
818
|
+
NAMESPACES: dict[str, list[str]] = {namespaces!r}
|
|
819
|
+
PATH_PLACEHOLDER = {name!r} + ".__path_hook__"
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
class _EditableFinder: # MetaPathFinder
|
|
823
|
+
@classmethod
|
|
824
|
+
def find_spec(cls, fullname: str, path=None, target=None) -> ModuleSpec | None: # type: ignore
|
|
825
|
+
# Top-level packages and modules (we know these exist in the FS)
|
|
826
|
+
if fullname in MAPPING:
|
|
827
|
+
pkg_path = MAPPING[fullname]
|
|
828
|
+
return cls._find_spec(fullname, Path(pkg_path))
|
|
829
|
+
|
|
830
|
+
# Handle immediate children modules (required for namespaces to work)
|
|
831
|
+
# To avoid problems with case sensitivity in the file system we delegate
|
|
832
|
+
# to the importlib.machinery implementation.
|
|
833
|
+
parent, _, child = fullname.rpartition(".")
|
|
834
|
+
if parent and parent in MAPPING:
|
|
835
|
+
return PathFinder.find_spec(fullname, path=[MAPPING[parent]])
|
|
836
|
+
|
|
837
|
+
# Other levels of nesting should be handled automatically by importlib
|
|
838
|
+
# using the parent path.
|
|
839
|
+
return None
|
|
840
|
+
|
|
841
|
+
@classmethod
|
|
842
|
+
def _find_spec(cls, fullname: str, candidate_path: Path) -> ModuleSpec | None:
|
|
843
|
+
init = candidate_path / "__init__.py"
|
|
844
|
+
candidates = (candidate_path.with_suffix(x) for x in module_suffixes())
|
|
845
|
+
for candidate in chain([init], candidates):
|
|
846
|
+
if candidate.exists():
|
|
847
|
+
return spec_from_file_location(fullname, candidate)
|
|
848
|
+
return None
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
class _EditableNamespaceFinder: # PathEntryFinder
|
|
852
|
+
@classmethod
|
|
853
|
+
def _path_hook(cls, path) -> type[_EditableNamespaceFinder]:
|
|
854
|
+
if path == PATH_PLACEHOLDER:
|
|
855
|
+
return cls
|
|
856
|
+
raise ImportError
|
|
857
|
+
|
|
858
|
+
@classmethod
|
|
859
|
+
def _paths(cls, fullname: str) -> list[str]:
|
|
860
|
+
paths = NAMESPACES[fullname]
|
|
861
|
+
if not paths and fullname in MAPPING:
|
|
862
|
+
paths = [MAPPING[fullname]]
|
|
863
|
+
# Always add placeholder, for 2 reasons:
|
|
864
|
+
# 1. __path__ cannot be empty for the spec to be considered namespace.
|
|
865
|
+
# 2. In the case of nested namespaces, we need to force
|
|
866
|
+
# import machinery to query _EditableNamespaceFinder again.
|
|
867
|
+
return [*paths, PATH_PLACEHOLDER]
|
|
868
|
+
|
|
869
|
+
@classmethod
|
|
870
|
+
def find_spec(cls, fullname: str, target=None) -> ModuleSpec | None: # type: ignore
|
|
871
|
+
if fullname in NAMESPACES:
|
|
872
|
+
spec = ModuleSpec(fullname, None, is_package=True)
|
|
873
|
+
spec.submodule_search_locations = cls._paths(fullname)
|
|
874
|
+
return spec
|
|
875
|
+
return None
|
|
876
|
+
|
|
877
|
+
@classmethod
|
|
878
|
+
def find_module(cls, _fullname) -> None:
|
|
879
|
+
return None
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
def install():
|
|
883
|
+
if not any(finder == _EditableFinder for finder in sys.meta_path):
|
|
884
|
+
sys.meta_path.append(_EditableFinder)
|
|
885
|
+
|
|
886
|
+
if not NAMESPACES:
|
|
887
|
+
return
|
|
888
|
+
|
|
889
|
+
if not any(hook == _EditableNamespaceFinder._path_hook for hook in sys.path_hooks):
|
|
890
|
+
# PathEntryFinder is needed to create NamespaceSpec without private APIS
|
|
891
|
+
sys.path_hooks.append(_EditableNamespaceFinder._path_hook)
|
|
892
|
+
if PATH_PLACEHOLDER not in sys.path:
|
|
893
|
+
sys.path.append(PATH_PLACEHOLDER) # Used just to trigger the path hook
|
|
894
|
+
"""
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
def _finder_template(
|
|
898
|
+
name: str, mapping: Mapping[str, str], namespaces: dict[str, list[str]]
|
|
899
|
+
) -> str:
|
|
900
|
+
"""Create a string containing the code for the``MetaPathFinder`` and
|
|
901
|
+
``PathEntryFinder``.
|
|
902
|
+
"""
|
|
903
|
+
mapping = dict(sorted(mapping.items(), key=lambda p: p[0]))
|
|
904
|
+
return _FINDER_TEMPLATE.format(name=name, mapping=mapping, namespaces=namespaces)
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
class LinksNotSupported(errors.FileError):
|
|
908
|
+
"""File system does not seem to support either symlinks or hard links."""
|