From fe0521b6dc5784b0ee34a365112cb2ffb128f865 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Wed, 5 Feb 2020 20:41:37 +0000 Subject: [PATCH] install mycfg stub along with the package --- my/__init__.py | 2 +- my/{fake_mycfg => mycfg_stub}/__init__.py | 0 my/{fake_mycfg => mycfg_stub}/repos/.gitkeep | 0 setup.py | 8 +++++++- tox.ini | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) rename my/{fake_mycfg => mycfg_stub}/__init__.py (100%) rename my/{fake_mycfg => mycfg_stub}/repos/.gitkeep (100%) diff --git a/my/__init__.py b/my/__init__.py index f41f6a3..48d26dd 100644 --- a/my/__init__.py +++ b/my/__init__.py @@ -6,7 +6,7 @@ except ImportError: import warnings warnings.warn("mycfg package isn't found! That might result in issues") - from . import fake_mycfg as mycfg # type: ignore[no-redef] + from . import mycfg_stub as mycfg # type: ignore[no-redef] import sys sys.modules['mycfg'] = mycfg del sys diff --git a/my/fake_mycfg/__init__.py b/my/mycfg_stub/__init__.py similarity index 100% rename from my/fake_mycfg/__init__.py rename to my/mycfg_stub/__init__.py diff --git a/my/fake_mycfg/repos/.gitkeep b/my/mycfg_stub/repos/.gitkeep similarity index 100% rename from my/fake_mycfg/repos/.gitkeep rename to my/mycfg_stub/repos/.gitkeep diff --git a/setup.py b/setup.py index ee0402b..8ed5a12 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,13 @@ def main(): # package_dir={'': ''}, packages=find_packages(), package_data={ - 'my': ['py.typed'], + 'my': [ + # for mypy + 'py.typed', + + # empty dir, necessary for proper dynamic imports + 'mycfg_stub/repos/.gitkeep', + ], }, python_requires='>=3.5', # depends on the modules though.. diff --git a/tox.ini b/tox.ini index 94e5117..13c542b 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ commands = # TODO ?? # python -m pytest {posargs} python3 -c 'import my; print(my.__path__)' + python3 -c 'import my; import mycfg.repos' # shouldn't fail at least # TODO run demo.py? just make sure with_my is a bit cleverer? # TODO e.g. under CI, rely on installing