From 6cbbfe48c173953aea1e738c3f7f6f8611cd7c6e Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Fri, 19 Jan 2024 13:35:20 -0600 Subject: [PATCH] Use src-layout in the source tree Closes #108. Src-layout as defined at https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/ This prevents spuriously using files under pymmcore/ when trying to test a locally installed pymmcore. --- .gitignore | 8 ++++---- maintainer-notes.md | 4 ++-- pyproject.toml | 5 ++--- setup.py | 4 +++- {pymmcore => src/pymmcore}/__init__.py | 0 {pymmcore => src/pymmcore}/__init__.pyi | 0 {pymmcore => src/pymmcore}/_version.py | 0 {pymmcore => src/pymmcore}/py.typed | 0 {pymmcore => src/pymmcore}/pymmcore_swig.i | 0 9 files changed, 11 insertions(+), 10 deletions(-) rename {pymmcore => src/pymmcore}/__init__.py (100%) rename {pymmcore => src/pymmcore}/__init__.pyi (100%) rename {pymmcore => src/pymmcore}/_version.py (100%) rename {pymmcore => src/pymmcore}/py.typed (100%) rename {pymmcore => src/pymmcore}/pymmcore_swig.i (100%) diff --git a/.gitignore b/.gitignore index 9743be3..216189a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,10 +10,10 @@ dist/ wheelhouse/ -pymmcore/pymmcore_swig_wrap.h -pymmcore/pymmcore_swig_wrap.cpp -pymmcore/_pymmcore_swig.cpython* -pymmcore/pymmcore_swig.py +src/pymmcore/pymmcore_swig_wrap.h +src/pymmcore/pymmcore_swig_wrap.cpp +src/pymmcore/_pymmcore_swig.* +src/pymmcore/pymmcore_swig.py pymmcore.egg-info .mypy_cache/ diff --git a/maintainer-notes.md b/maintainer-notes.md index a0b1f79..f5107e8 100644 --- a/maintainer-notes.md +++ b/maintainer-notes.md @@ -79,11 +79,11 @@ prefixed to the version: ```bash git checkout main -vim pymmcore/_version.py # Remove .dev0 +vim src/pymmcore/_version.py # Remove .dev0 git commit -a -m 'Version 1.2.3.42.4' git tag -a v1.2.3.42.4 -m Release -vim pymmcore/_version.py # Set version to 1.2.3.42.5.dev0 +vim src/pymmcore/_version.py # Set version to 1.2.3.42.5.dev0 git commit -a -m 'Version back to dev' git push upstream --follow-tags diff --git a/pyproject.toml b/pyproject.toml index c32d6f4..5bc331d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,12 +32,11 @@ dependencies = ["numpy >=1.12.0"] homepage = "https://micro-manager.org" repository = "https://github.com/micro-manager/pymmcore" - [tool.setuptools.dynamic] version = { attr = "pymmcore._version.__version__" } -[tool.setuptools.packages.find] -include = ["pymmcore*"] +[tool.setuptools.package-dir] +"" = "src" [tool.setuptools.package-data] "*" = ["py.typed", ".pyi"] diff --git a/setup.py b/setup.py index 5a288da..bb14b7f 100644 --- a/setup.py +++ b/setup.py @@ -101,7 +101,9 @@ def run(self): mmcore_extension = Extension( f"{PKG_NAME}._{SWIG_MOD_NAME}", - sources=mmcore_sources + [os.path.join(PKG_NAME, f"{SWIG_MOD_NAME}.i")], + sources=mmcore_sources + [os.path.join( + "src", PKG_NAME, f"{SWIG_MOD_NAME}.i", + )], swig_opts=[ "-c++", "-py3", diff --git a/pymmcore/__init__.py b/src/pymmcore/__init__.py similarity index 100% rename from pymmcore/__init__.py rename to src/pymmcore/__init__.py diff --git a/pymmcore/__init__.pyi b/src/pymmcore/__init__.pyi similarity index 100% rename from pymmcore/__init__.pyi rename to src/pymmcore/__init__.pyi diff --git a/pymmcore/_version.py b/src/pymmcore/_version.py similarity index 100% rename from pymmcore/_version.py rename to src/pymmcore/_version.py diff --git a/pymmcore/py.typed b/src/pymmcore/py.typed similarity index 100% rename from pymmcore/py.typed rename to src/pymmcore/py.typed diff --git a/pymmcore/pymmcore_swig.i b/src/pymmcore/pymmcore_swig.i similarity index 100% rename from pymmcore/pymmcore_swig.i rename to src/pymmcore/pymmcore_swig.i