tox-dev / platformdirs

A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir".
https://platformdirs.readthedocs.io
MIT License
568 stars 49 forks source link

BLD: pyproject.toml, versions.py: lack of an actual versions.py prevents from-source installation by site-packages symlink or .pth from working #312

Closed westurner closed 22 minutes ago

westurner commented 3 hours ago

Having changed __init__.py:__version__ with sed in a makefile, and then with e.g. pypi:bumpversion prior to tagging a release (with git-flow/hub-flow), this is a good bug.

Sources:

Workarounds:

gaborbernat commented 3 hours ago

The only two supported installation methods are source redistribution and the wheels. If you want to build something from the source, you should use the source distribution. Any other method to install this project is simply put not supported and out of scope.

On Fri, Sep 27, 2024, 16:31 Wes Turner @.***> wrote:

  • Presenting case: When I try to rename a variable with python-mode/vim-python-mode, it fails on platformdirs import. vim-python-mode vendors a number of submodules and then modifies sys.path when the editor loads or when a virtualenv is openend iirc; so it's not necessary to pip install vim-python-mode and libs in every virtualenv. So I added a vim-python-mode/submodules/platformdirs and a symlink to it from vim-python-mode/lib/platformdirs, but then the import platformdirs (in rope) fails because there's not a src/platformdirs/versions.py until it's automagically created by hatch vcs fwics.

Having changed init.py:version with sed in a makefile, and then with e.g. pypi:bumpversion prior to tagging a release (with git-flow/hub-flow), this is a good bug.

Sources:

- https://github.com/tox-dev/platformdirs/blob/bc0405cb9c9439e6923b2dc090f91ad5daaf7dec/pyproject.toml#L45-L47

https://github.com/tox-dev/platformdirs/blob/bc0405cb9c9439e6923b2dc090f91ad5daaf7dec/pyproject.toml#L71-L78

Workarounds:

  • Could hatch or the release workflow overwrite a default versions.py, so that install by symlinking still works?
    • Or, could it be specified that install by symlinking a git clone should work?

— Reply to this email directly, view it on GitHub https://github.com/tox-dev/platformdirs/issues/312, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFIQPTLO4ZHK34RPJMPPM3ZYXTG3AVCNFSM6AAAAABPABHNIGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2TGOBYGA2TMOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

westurner commented 2 hours ago

Would you accept a PR to update version.py in the source prior to tagging the release?

FWIW:

Because the code must check which path the .toml build file is in: https://github.com/bagel897/pytoolconfig/blob/bee6db49636ed4806942a1b7549dc5b2fc9611e7/src/pytoolconfig/sources/pytool.py#L34C32-L37C78 :

"""
        Mac OS X:               ~/Library/Application Support/pytool.toml
        Unix:                   ~/.config/pytool.toml     # or in $XDG_CONFIG_HOME,
                                if defined
        Win *:                  C:\Users\<username>\AppData\Local\pytool.toml
"""
gaborbernat commented 1 hour ago

Would you accept a PR to update version.py in the source prior to tagging the release?

FWIW:

Because the code must check which path the .toml build file is in: https://github.com/bagel897/pytoolconfig/blob/bee6db49636ed4806942a1b7549dc5b2fc9611e7/src/pytoolconfig/sources/pytool.py#L34C32-L37C78 :

"""
        Mac OS X:               ~/Library/Application Support/pytool.toml
        Unix:                   ~/.config/pytool.toml     # or in $XDG_CONFIG_HOME,
                                if defined
        Win *:                  C:\Users\<username>\AppData\Local\pytool.toml
"""

I do not want the version file to be part of the source repository, so no. I prefer to have a single location of truth and that is the version controlling system. I am not interested in duplicating that through multiple locations and introduce a manual step to update the version file whenever I need to release.

westurner commented 45 minutes ago

So this doesn't work:

$ git clone platformdirs platformdirs $ ln -s platformdirs/src/platformdirs/ $pymode/libs/platformdirs

Though it does with all of these plain Python packages from source for grepping through: https://github.com/python-mode/python-mode/tree/develop/submodules

It requires multiple Python packages to install the version.py file.

Workaround:

On Fri, Sep 27, 2024, 9:17 PM Bernát Gábor @.***> wrote:

Would you accept a PR to update version.py in the source prior to tagging the release?

FWIW:

Because the code must check which path the .toml build file is in: https://github.com/bagel897/pytoolconfig/blob/bee6db49636ed4806942a1b7549dc5b2fc9611e7/src/pytoolconfig/sources/pytool.py#L34C32-L37C78 :

""" Mac OS X: ~/Library/Application Support/pytool.toml Unix: ~/.config/pytool.toml # or in $XDG_CONFIG_HOME, if defined Win *: C:\Users\\AppData\Local\pytool.toml"""

I do not want the version file to be part of the source repository, so no. I prefer to have a single location of truth and that is the version controlling system. I am not interested in duplicating that through multiple locations and introduce a manual step to update the version file whenever I need to release.

— Reply to this email directly, view it on GitHub https://github.com/tox-dev/platformdirs/issues/312#issuecomment-2380335884, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMNS5TIF5VJHIDKGEF7YTZYX7UNAVCNFSM6AAAAABPABHNIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBQGMZTKOBYGQ . You are receiving this because you authored the thread.Message ID: @.***>

gaborbernat commented 22 minutes ago

That's just how the Python build system (PEP-517) works. If you are planning to use python, you also need to use their standards to be leather.