yboetz / pyznap

ZFS snapshot tool written in python
GNU General Public License v3.0
199 stars 36 forks source link

pyznap in a venv on macOS Sonoma has dependencies #109

Open LnxGnome opened 1 month ago

LnxGnome commented 1 month ago

Just a note for the Docs...

pyznap in a venv on macOS Sonoma has dependencies (setuptools)

superuser@mac ~ % which python3   
/opt/homebrew/bin/python3

superuser@mac ~ % python3 -V   
Python 3.12.7

superuser@mac ~ % python3 -m venv venv/pyznap

superuser@mac ~ % source venv/pyznap/bin/activate

(pyznap) superuser@mac ~ % which python3
/Users/superuser/venv/pyznap/bin/python3

(pyznap) superuser@mac ~ % pip3 install pyznap
Collecting pyznap
  Downloading pyznap-1.6.0-py3-none-any.whl.metadata (12 kB)
Downloading pyznap-1.6.0-py3-none-any.whl (39 kB)
Installing collected packages: pyznap
Successfully installed pyznap-1.6.0

(pyznap) superuser@mac ~ % pyznap
Traceback (most recent call last):
  File "/Users/superuser/venv/pyznap/bin/pyznap", line 5, in <module>
    from pyznap.main import main
  File "/Users/superuser/venv/pyznap/lib/python3.12/site-packages/pyznap/main.py", line 18, in <module>
    from .utils import read_config, create_config
  File "/Users/superuser/venv/pyznap/lib/python3.12/site-packages/pyznap/utils.py", line 21, in <module>
    from pkg_resources import resource_string
ModuleNotFoundError: No module named 'pkg_resources'

(pyznap) superuser@mac ~ % pyznap setup -p ~/pyznap
Traceback (most recent call last):
  File "/Users/superuser/venv/pyznap/bin/pyznap", line 5, in <module>
    from pyznap.main import main
  File "/Users/superuser/venv/pyznap/lib/python3.12/site-packages/pyznap/main.py", line 18, in <module>
    from .utils import read_config, create_config
  File "/Users/superuser/venv/pyznap/lib/python3.12/site-packages/pyznap/utils.py", line 21, in <module>
    from pkg_resources import resource_string
ModuleNotFoundError: No module named 'pkg_resources'

(pyznap) superuser@mac ~ % pip3 install setuptools
Collecting setuptools
  Downloading setuptools-75.1.0-py3-none-any.whl.metadata (6.9 kB)
Downloading setuptools-75.1.0-py3-none-any.whl (1.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 13.5 MB/s eta 0:00:00
Installing collected packages: setuptools
Successfully installed setuptools-75.1.0

(pyznap) superuser@mac ~ % pyznap setup -p ~/pyznap
Oct 03 19:10:26 INFO: Starting pyznap...
Oct 03 19:10:26 INFO: Initial setup...
Oct 03 19:10:26 INFO: Creating directory /Users/superuser/pyznap...
Oct 03 19:10:26 INFO: Creating sample config /Users/superuser/pyznap/pyznap.conf...
Oct 03 19:10:26 INFO: Finished successfully...

(pyznap) superuser@mac ~ % brew search setuptools
==> Formulae python-setuptools ✔

Looking back, python-setuptools was installed by Brew, but apparently venv doesn't include them automagically.

I also reviewed the virtualenv link from the README.md, and tried venv that way, but the current version of pipenv install pyznap doesn't install setuptools either.

I'd say this is more of a venv issue, but one worth noting in the README.

dalito commented 1 month ago

In earlier Python versions setuptools were installed into every virtual env. This stopped at some point (in 3.8? - I can't remember exactly). It is not a venv issue but a missing dependency specification in pyznap which has not been adapted to modern Python packaging (no pyproject.toml yet).