libkeepass / pykeepass

Python library to interact with keepass databases (supports KDBX3 and KDBX4)
https://pypi.org/project/pykeepass/
GNU General Public License v3.0
411 stars 96 forks source link

Fix missing pykeepass.kdbx_parsing when built with modern tools #378

Closed musicinmybrain closed 6 months ago

musicinmybrain commented 7 months ago

Before:

$ python3 -m build
$  tar -tzf dist/pykeepass-4.0.7.tar.gz 
pykeepass-4.0.7/
pykeepass-4.0.7/LICENSE
pykeepass-4.0.7/MANIFEST.in
pykeepass-4.0.7/PKG-INFO
pykeepass-4.0.7/README.rst
pykeepass-4.0.7/pykeepass/
pykeepass-4.0.7/pykeepass/__init__.py
pykeepass-4.0.7/pykeepass/attachment.py
pykeepass-4.0.7/pykeepass/baseelement.py
pykeepass-4.0.7/pykeepass/blank_database.kdbx
pykeepass-4.0.7/pykeepass/deprecated.py
pykeepass-4.0.7/pykeepass/entry.py
pykeepass-4.0.7/pykeepass/exceptions.py
pykeepass-4.0.7/pykeepass/group.py
pykeepass-4.0.7/pykeepass/icons.py
pykeepass-4.0.7/pykeepass/pykeepass.py
pykeepass-4.0.7/pykeepass/version.py
pykeepass-4.0.7/pykeepass/xpath.py
pykeepass-4.0.7/pykeepass.egg-info/
pykeepass-4.0.7/pykeepass.egg-info/PKG-INFO
pykeepass-4.0.7/pykeepass.egg-info/SOURCES.txt
pykeepass-4.0.7/pykeepass.egg-info/dependency_links.txt
pykeepass-4.0.7/pykeepass.egg-info/requires.txt
pykeepass-4.0.7/pykeepass.egg-info/top_level.txt
pykeepass-4.0.7/pyproject.toml
pykeepass-4.0.7/setup.cfg
$ cd dist
$ python3 -m wheel unpack pykeepass-4.0.7-py3-none-any.whl 
Unpacking to: pykeepass-4.0.7...OK
$ find pykeepass-4.0.7/
pykeepass-4.0.7/
pykeepass-4.0.7/pykeepass
pykeepass-4.0.7/pykeepass/__init__.py
pykeepass-4.0.7/pykeepass/attachment.py
pykeepass-4.0.7/pykeepass/baseelement.py
pykeepass-4.0.7/pykeepass/blank_database.kdbx
pykeepass-4.0.7/pykeepass/deprecated.py
pykeepass-4.0.7/pykeepass/entry.py
pykeepass-4.0.7/pykeepass/exceptions.py
pykeepass-4.0.7/pykeepass/group.py
pykeepass-4.0.7/pykeepass/icons.py
pykeepass-4.0.7/pykeepass/pykeepass.py
pykeepass-4.0.7/pykeepass/version.py
pykeepass-4.0.7/pykeepass/xpath.py
pykeepass-4.0.7/pykeepass-4.0.7.dist-info
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/LICENSE
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/METADATA
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/WHEEL
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/top_level.txt
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/RECORD

After:


$ python3 -m build
$  tar -tzf dist/pykeepass-4.0.7.tar.gz 
pykeepass-4.0.7/
pykeepass-4.0.7/LICENSE
pykeepass-4.0.7/MANIFEST.in
pykeepass-4.0.7/PKG-INFO
pykeepass-4.0.7/README.rst
pykeepass-4.0.7/pykeepass/
pykeepass-4.0.7/pykeepass/__init__.py
pykeepass-4.0.7/pykeepass/attachment.py
pykeepass-4.0.7/pykeepass/baseelement.py
pykeepass-4.0.7/pykeepass/blank_database.kdbx
pykeepass-4.0.7/pykeepass/deprecated.py
pykeepass-4.0.7/pykeepass/entry.py
pykeepass-4.0.7/pykeepass/exceptions.py
pykeepass-4.0.7/pykeepass/group.py
pykeepass-4.0.7/pykeepass/icons.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/
pykeepass-4.0.7/pykeepass/kdbx_parsing/__init__.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/common.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx3.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx4.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/pytwofish.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/twofish.py
pykeepass-4.0.7/pykeepass/pykeepass.py
pykeepass-4.0.7/pykeepass/version.py
pykeepass-4.0.7/pykeepass/xpath.py
pykeepass-4.0.7/pykeepass.egg-info/
pykeepass-4.0.7/pykeepass.egg-info/PKG-INFO
pykeepass-4.0.7/pykeepass.egg-info/SOURCES.txt
pykeepass-4.0.7/pykeepass.egg-info/dependency_links.txt
pykeepass-4.0.7/pykeepass.egg-info/requires.txt
pykeepass-4.0.7/pykeepass.egg-info/top_level.txt
pykeepass-4.0.7/pyproject.toml
pykeepass-4.0.7/setup.cfg
$ cd dist
$ python3 -m wheel unpack pykeepass-4.0.7-py3-none-any.whl 
Unpacking to: pykeepass-4.0.7...OK
$ find pykeepass-4.0.7/
pykeepass-4.0.7/
pykeepass-4.0.7/pykeepass
pykeepass-4.0.7/pykeepass/__init__.py
pykeepass-4.0.7/pykeepass/attachment.py
pykeepass-4.0.7/pykeepass/baseelement.py
pykeepass-4.0.7/pykeepass/blank_database.kdbx
pykeepass-4.0.7/pykeepass/deprecated.py
pykeepass-4.0.7/pykeepass/entry.py
pykeepass-4.0.7/pykeepass/exceptions.py
pykeepass-4.0.7/pykeepass/group.py
pykeepass-4.0.7/pykeepass/icons.py
pykeepass-4.0.7/pykeepass/pykeepass.py
pykeepass-4.0.7/pykeepass/version.py
pykeepass-4.0.7/pykeepass/xpath.py
pykeepass-4.0.7/pykeepass/kdbx_parsing
pykeepass-4.0.7/pykeepass/kdbx_parsing/__init__.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/common.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx3.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx4.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/pytwofish.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/twofish.py
pykeepass-4.0.7/pykeepass-4.0.7.dist-info
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/LICENSE
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/METADATA
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/WHEEL
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/top_level.txt
pykeepass-4.0.7/pykeepass-4.0.7.dist-info/RECORD

If you would rather not explicitly list all (sub)packages like this, see https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#finding-simple-packages (but make sure you don’t accidentally install tests/ directly into site-packages, a common pitfall).

Evidlo commented 7 months ago

I'm not seeing this behavior (setuptools 69.0.3):

[evan@blackbox pykeepass] rm -f dist/pykeepass-4.0.*

[evan@blackbox pykeepass] python -m build
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools>=59.0.0)
* Getting build dependencies for sdist...
running egg_info
writing pykeepass.egg-info/PKG-INFO
writing dependency_links to pykeepass.egg-info/dependency_links.txt
writing requirements to pykeepass.egg-info/requires.txt
writing top-level names to pykeepass.egg-info/top_level.txt
reading manifest file 'pykeepass.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.pyc' found under directory '*'
running install_egg_info
...
Copying pykeepass.egg-info to build/bdist.linux-x86_64/wheel/pykeepass-4.0.7-py3.11.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/pykeepass-4.0.7.dist-info/WHEEL
creating '/home/evan/resources/pykeepass/dist/.tmp-uq3db6d4/pykeepass-4.0.7-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'pykeepass/__init__.py'
adding 'pykeepass/attachment.py'
adding 'pykeepass/baseelement.py'
adding 'pykeepass/blank_database.kdbx'
adding 'pykeepass/deprecated.py'
adding 'pykeepass/entry.py'
adding 'pykeepass/exceptions.py'
adding 'pykeepass/group.py'
adding 'pykeepass/icons.py'
adding 'pykeepass/pykeepass.py'
adding 'pykeepass/setters.py'
adding 'pykeepass/version.py'
adding 'pykeepass/xpath.py'
adding 'pykeepass/kdbx_parsing/__init__.py'
adding 'pykeepass/kdbx_parsing/common.py'
adding 'pykeepass/kdbx_parsing/kdbx.py'
adding 'pykeepass/kdbx_parsing/kdbx3.py'
adding 'pykeepass/kdbx_parsing/kdbx4.py'
adding 'pykeepass/kdbx_parsing/pytwofish.py'
adding 'pykeepass/kdbx_parsing/twofish.py'
adding 'pykeepass-4.0.7.dist-info/LICENSE'
adding 'pykeepass-4.0.7.dist-info/METADATA'
adding 'pykeepass-4.0.7.dist-info/WHEEL'
adding 'pykeepass-4.0.7.dist-info/top_level.txt'
adding 'pykeepass-4.0.7.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
Successfully built pykeepass-4.0.7.tar.gz and pykeepass-4.0.7-py3-none-any.whl

[evan@blackbox pykeepass] tar -tzf dist/pykeepass-4.0.7.tar.gz 
pykeepass-4.0.7/
pykeepass-4.0.7/.github/
pykeepass-4.0.7/.github/dependabot.yml
pykeepass-4.0.7/.github/workflows/
pykeepass-4.0.7/.github/workflows/ci.yaml
pykeepass-4.0.7/.gitignore
pykeepass-4.0.7/CHANGELOG.rst
pykeepass-4.0.7/LICENSE
pykeepass-4.0.7/MANIFEST.in
pykeepass-4.0.7/Makefile
pykeepass-4.0.7/PKG-INFO
pykeepass-4.0.7/README.rst
pykeepass-4.0.7/pykeepass/
pykeepass-4.0.7/pykeepass/__init__.py
pykeepass-4.0.7/pykeepass/attachment.py
pykeepass-4.0.7/pykeepass/baseelement.py
pykeepass-4.0.7/pykeepass/blank_database.kdbx
pykeepass-4.0.7/pykeepass/deprecated.py
pykeepass-4.0.7/pykeepass/entry.py
pykeepass-4.0.7/pykeepass/exceptions.py
pykeepass-4.0.7/pykeepass/group.py
pykeepass-4.0.7/pykeepass/icons.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/
pykeepass-4.0.7/pykeepass/kdbx_parsing/__init__.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/common.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx3.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/kdbx4.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/pytwofish.py
pykeepass-4.0.7/pykeepass/kdbx_parsing/twofish.py
pykeepass-4.0.7/pykeepass/pykeepass.py
pykeepass-4.0.7/pykeepass/setters.py
pykeepass-4.0.7/pykeepass/version.py
pykeepass-4.0.7/pykeepass/xpath.py
pykeepass-4.0.7/pykeepass.egg-info/
pykeepass-4.0.7/pykeepass.egg-info/PKG-INFO
pykeepass-4.0.7/pykeepass.egg-info/SOURCES.txt
pykeepass-4.0.7/pykeepass.egg-info/dependency_links.txt
pykeepass-4.0.7/pykeepass.egg-info/requires.txt
pykeepass-4.0.7/pykeepass.egg-info/top_level.txt
pykeepass-4.0.7/pyproject.toml
pykeepass-4.0.7/requirements.txt
pykeepass-4.0.7/setup.cfg

[evan@blackbox pykeepass] python3 -m wheel unpack dist/pykeepass-4.0.7-py3-none-any.whl 
Unpacking to: pykeepass-4.0.7...OK

[evan@blackbox pykeepass] tree pykeepass-4.0.7/pykeepass
pykeepass-4.0.7/pykeepass
├── attachment.py
├── baseelement.py
├── blank_database.kdbx
├── deprecated.py
├── entry.py
├── exceptions.py
├── group.py
├── icons.py
├── __init__.py
├── kdbx_parsing
│   ├── common.py
│   ├── __init__.py
│   ├── kdbx3.py
│   ├── kdbx4.py
│   ├── kdbx.py
│   ├── pytwofish.py
│   └── twofish.py
├── pykeepass.py
├── setters.py
├── version.py
└── xpath.py
musicinmybrain commented 7 months ago

That’s really strange. I’m on Fedora Linux 39, and I discovered the problem because the pykeepass/kdbx_parsing directory was absent when I built python-pykeepass 4.0.7 for Fedora Rawhide. I tried installing the same version of setuptools in a virtualenv, but that didn’t make any difference.

musicinmybrain commented 7 months ago

I have tried everything I can think of, and I can’t find any way to reproduce what you are seeing. Would you mind telling me what OS you are using, so I can perhaps try it in a virtual machine and maybe figure out what the difference is?

Evidlo commented 7 months ago

Sure, I'm on Debian 12 with Python 3.11.7

musicinmybrain commented 7 months ago

OK, I installed a VM with basically-default setup choices using https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso. I left Software Selection at defaults (Debian desktop environment, GNOME, standard system utilities). Then, on that clean system, I did:

$ sudo apt install git python3-{build,venv}
$ git clone https://github.com/libkeepass/pykeepass.git
$ cd pykeepass
$ python3 -m build

The result is the same as I originally reported (wheel does not contain pykeepass/kdbx_parsing/).

Is there any possibility that you tested this after checking out the branch corresponding to this PR to investigate, rather than using master? I am not sure how else to explain the discrepancy.

mboquien commented 7 months ago

For what it is worth, Archlinux also appear to be affected: https://archlinux.org/packages/extra/any/python-pykeepass/ ( click on “View the file list for python-pykeepass”). Their packaging script can be seen at https://gitlab.archlinux.org/archlinux/packaging/packages/python-pykeepass/-/blob/main/PKGBUILD?ref_type=heads .