Hello!
Playing with iocage 1.1 on FreeBSD 11.2, I discovered a conflict between iocage and a port I am working on. Both ports want to manage a(n empty) file, and as far as I can see, none of the ports should install it:
Checking integrity... done (1 conflicting)
- py36-iocage-1.1 conflicts with py36-pynetstring-0.1.dev2 on /usr/local/lib/python3.6/site-packages/tests/__init__.py
romain@zappy ~ % cat /usr/local/lib/python3.6/site-packages/tests/__init__.py
romain@zappy ~ %
By looking at the installed files, unit tests related files seems to be installed directly under lib/python3.6/site-packages/tests and not in an iocage-specific directory:
romain@zappy ~ % pkg info -ql py36-iocage-1.1 | grep site-packages/tests
/usr/local/lib/python3.6/site-packages/tests/__init__.py
/usr/local/lib/python3.6/site-packages/tests/__pycache__/__init__.cpython-36.opt-1.pyc
/usr/local/lib/python3.6/site-packages/tests/__pycache__/__init__.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/tests/__pycache__/conftest.cpython-36.opt-1.pyc
/usr/local/lib/python3.6/site-packages/tests/__pycache__/conftest.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/tests/__pycache__/data_classes.cpython-36.opt-1.pyc
/usr/local/lib/python3.6/site-packages/tests/__pycache__/data_classes.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/tests/conftest.py
/usr/local/lib/python3.6/site-packages/tests/data_classes.py
romain@zappy ~ %
I do not know much about testing with Python, but I guess ports should not install these files?
Thanks!
to quote https://wiki.freebsd.org/Python/PortsPolicy#Tests
Tests
- Python ports SHOULD include a
do-testtarget if the package includes tests.- Python ports SHOULD add
TEST_DEPENDSreferring to the packagetests_requiredependencies.
@araujobsd You're the maintainer for the port, thoughts?
The bug here is in the upstream layout/packaging, and that tests are installed to shared/common locations, ie; they should be package specific like site-packages/iocage/tests/*. Most python ports use standard distutils/setuptools/autoplist to build/install, so upstream packaging issues are translated into and reflected in ports, unless patched/fixed.
Regarding Python packaging policy (and best practice), when we say "packages should include tests / test_data, we mean in the sdist, so they can be run. As an upstream, use MANIFEST.in for this, if find_packages doesn't automatically find them due to non-standard packaging/src layout or other reasons.
Whether or not tests are installed or not is a separate issue, but most packages exclude them from installation (see below).
find_packages has an exclude argument to remove packages from the discovered list, to prevent them from being installed. You can use this to remove tests package. https://packaging.python.org/guides/distributing-packages-using-setuptools/#packages
Please leave tests in as part of the sdist so they can be run, and QA can happen downstream as part of porting/packaging. Remove prune tests from MANIFEST.in
@koobs Whoops, good call. I forgot I nuked it from sdist when I committed
@skarekrow Thanks!