genRSS icon indicating copy to clipboard operation
genRSS copied to clipboard

Directory structure reorganization

Open denilsonsa opened this issue 1 year ago • 0 comments

The current directory structure of this project is:

.
├── LICENSE
├── pyproject.toml
├── README.md
├── setup.py
├── src
│   ├── genRSS.py
│   └── util.py
└── test
    └── ...

Major issue: file pollution

When installing the package, this will happen:

venv/lib/python3.11/site-packages
├── eyed3/
├── filetype/
├── mutagen/
├── ...
├── genRSS.py
└── util.py

Both the genRSS.py and the util.py will be installed at the root of the python modules. This means it is possible to import util from anywhere:

$ ipython

In [1]: import util

In [2]: # ↑ That should have failed!

You can also check this behavior by inspecting the contents of the wheel file available from PyPI:

$ wget https://.../generss-0.3.0-py3-none-any.whl
$ unzip -l generss-0.3.0-py3-none-any.whl                                                   INT ✘ 
Archive:  generss-0.3.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
    10167  2023-09-13 21:15   genRSS.py
    19457  2023-09-13 19:33   util.py
     1074  2023-09-13 21:16   generss-0.3.0.dist-info/LICENSE
     3780  2023-09-13 21:16   generss-0.3.0.dist-info/METADATA
       92  2023-09-13 21:16   generss-0.3.0.dist-info/WHEEL
       39  2023-09-13 21:16   generss-0.3.0.dist-info/entry_points.txt
       12  2023-09-13 21:16   generss-0.3.0.dist-info/top_level.txt
      613  2023-09-13 21:16   generss-0.3.0.dist-info/RECORD
---------                     -------
    35234                     8 files

That's not good.

Expected structure (AKA solution)

I expected this structure:

venv/lib/python3.11/site-packages
├── ...
└── genRSS/
    ├── __main__.py
    └── util.py

Which means we have to move some files around the repository:

  • src/genRSS.pysrc/genRSS/__main__.py
  • src/util.pysrc/genRSS/util.py

And also setup Entry Points inside pyproject.toml.

See also:

  • https://stackoverflow.com/questions/4042905/what-is-main-py

Dependencies

We have this in pyproject.toml:

dependencies = ["mutagen==1.47.0", "eyed3==0.9.7"]

Why hard-coding the versions? Can't we just specify the minimum version instead? Or just leave out the version number, letting it auto-update the dependencies?

Minor cleanup: setup.py

setup.py is only needed for legacy build systems or legacy versions. It shouldn't be needed or used anymore. I suggest deleting it.

denilsonsa avatar Feb 01 '24 03:02 denilsonsa