Closed cboulay closed 11 months ago
I gave the same treatment to ezmsg
(containing core, util, etc) and it similarly fixed my IDE problems! No more issues inspecting / indexing ezmsg.core and ezmsg.util.
Here is what I did:
I moved ezmsg/ezmsg
to ezmsg/src/ezmsg
deleted setup.cfg
, setup.py
, and src/ezmsg/version/__version__.py
.
I modified pyproject.toml to look like:
[tool.poetry]
name = "ezmsg"
version = "3.3.4"
description = "A simple DAG-based computation model"
authors = ["Griffin Milsap <griffin.milsap@jhuapl.edu>"]
readme = "README.md"
homepage = "https://github.com/iscoe/ezmsg"
packages = [
{ include = "ezmsg", from = "src" }
]
[tool.poetry.dependencies]
python = ">=3.8,<3.13"
typing_extensions = "*"
[tool.poetry.scripts]
ezmsg = "ezmsg.core.command:cmdline"
[tool.poetry.extras]
all_ext = ["ezmsg-websocket", "ezmsg-sigproc", "ezmsg-zmq"]
[tool.poetry.group.test.dependencies]
pytest = "*"
pytest-asyncio = "*"
pytest-cov = "*"
numpy = "^1.24.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
src/ezmsg/version/__init__.py
as follows:import importlib.metadata
__version__ = importlib.metadata.version("ezmsg")
I haven't tested the [extras]
install.
I'm glad you spent some time to track down these issues! I found a workaround for myself was to not use pip install
but to instead invoke setup.py
directly (which is suboptimal for a number of reasons). Eager to move to poetry as well. @pperanich -- does this look right to you? I'm going to play with these changes to see if we can move the packaging to poetry this week.
Fixed in #72
My scripts run fine whether in debug via IDE or in a terminal; no issue importing the various ezmsg namespaced packages.
However, my two preferred IDEs (PyCharm & VS Code) recognize only some namespace packages which makes for an annoying dev experience because I don't get code completion or type checking.
Pycharm:
VS Code:
Until today, I was satisfied adding the other ezmsg packages directly to my workspace and manually setting the path, but this didn't always work. I seem to have lost whatever magic I had and now a bunch that were previous working are no longer.
So I was messing around today and "discovered" that my packages that used a src-layout and used poetry for package-config didn't have this problem.
One minor caveat: Poetry doesn't seem to support single-source for versioning unless that source is in pyproject.toml. So I use the toml file for versioning and then ezmsg.package.init.py has a couple lines to inspect the package to get the version. Thus, the package must be installed! Editable mode is ok:
pip install -e .
I usually tag on--no-deps
so I don't overwrite my core ezmsg.So, I refactored a couple packages from IDE-not-recognized to IDE-recognized. See:
Something really strange though:
ezmsg.sigproc
seems to work fine, but nothing else from the mainezmsg
repo works. Notcore
,util
,zmq
,websocket
, nothing.So I'm sure the fix isn't specific to poetry and/or src-layout, because ezmsg.sigproc doesn't use that.