guardian icon indicating copy to clipboard operation
guardian copied to clipboard

Proper project structure

Open TheMythologist opened this issue 2 years ago • 2 comments

  • pyproject.toml should be the single source of truth, especially for package versioning
    • Good reference: https://packaging.python.org/en/latest/guides/single-sourcing-package-version/
  • Clear segregation of classes and functions

Currently blocked by the release of cx-freeze==6.14.0 (for customizing configurations in pyproject.toml)

TheMythologist avatar Jan 24 '23 16:01 TheMythologist

Single-sourcing via pyproject.toml is blocked by poetry Reference: https://github.com/python-poetry/poetry/issues/3332

TheMythologist avatar Jan 28 '23 13:01 TheMythologist

Single-sourcing via pyproject.toml is blocked by poetry Reference: https://github.com/python-poetry/poetry/issues/3332

The poetry itself uses a work around to versioning single source of truth while managing metadata using poetry implementation See:

https://github.com/python-poetry/poetry/blob/master/src/poetry/version.py#L5

from poetry.utils._compat import metadata

https://github.com/python-poetry/poetry/blob/master/src/poetry/version.py#L12-L16

# The metadata.version that we import for Python 3.7 is untyped, work around
# that.
version: Callable[[str], str] = metadata.version

__version__ = version("poetry")

https://github.com/python-poetry/poetry/blob/master/src/poetry/utils/_compat.py#L18-L22

if sys.version_info < (3, 10):
    # compatibility for python <3.10
    import importlib_metadata as metadata
else:
    from importlib import metadata

This approach is also showed in the source link you've mentioned:

https://packaging.python.org/en/latest/guides/single-sourcing-package-version/

import sys

if sys.version_info >= (3, 8):
    from importlib import metadata
else:
    import importlib_metadata as metadata

assert metadata.version('pip') == '1.2.0'

PabloEmidio avatar Feb 11 '23 02:02 PabloEmidio