traits icon indicating copy to clipboard operation
traits copied to clipboard

Make traits.examples.introduction a non-package?

Open kitchoi opened this issue 3 years ago • 6 comments

After #1348, traits.examples.introduction is now a package that can be imported:

from traits.examples.introduction import *

This makes the introduction a package and makes it look like part of the public library. But I believe the folder of Python files is also intended as data, not package.

Note that introduction has an __init__.py file in the introduction folder. However I believe it was added before the etsdemo switched to using an index.rst file to capture the folder description (see https://github.com/enthought/traitsui/issues/849).

kitchoi avatar Nov 17 '20 10:11 kitchoi

Note that introduction has an init.py file in the introduction folder. However I believe it was added before the etsdemo switched to using an index.rst file to capture the folder description

That is now changed by #1358.

kitchoi avatar Nov 17 '20 10:11 kitchoi

@kitchoi It looks as though this issue can now be closed. Is that correct?

mdickinson avatar Nov 18 '20 15:11 mdickinson

Hmmm but I can still import traits.examples.introduction

$ python3.9 -m venv ../py39-venv/traits-env-2
$ source ../py39-venv/traits-env-2/bin/activate
$ pip install .
$ cd
$ python
>>> from traits.examples import introduction
>>>

So may be we can't close it yet.

kitchoi avatar Nov 18 '20 17:11 kitchoi

(Updated snippet as I did change directory to make sure I did not just pick up the packages from source)

kitchoi avatar Nov 18 '20 17:11 kitchoi

but I can still import traits.examples.introduction

I think that's just Python 3's (implicit) namespace packages at work. I don't think there's anything we can reasonably do about that.

mdickinson avatar Nov 18 '20 17:11 mdickinson

It is true that the folder is considered a namespace package ever since the files are moved under traits and are included as package data.

If we really want to avoid accidentally exposing public-looking packages, I think we can nest introduction under another folder that contains a hyphen. I will leave this up to our maintainer. I mainly open the issue to describe what I observe.

kitchoi avatar Nov 18 '20 17:11 kitchoi