На 14.05.20 г. в 9:25 ч., Juan BC написа:
Hi guys, I have a question here (sorry if my lack of practice in English).
I currently working in one of the many projects about covid-19, and I
just deployed a new version for a group of epidemiologists.
To be fair I deployed not once but three times because of two
miss-configuration of setuptools.

- First, I forget to add the internal package arcoviv19.web to include
the web app of the project
(https://github.com/ivco19/libs/blob/master/setup.py#L89)


Why are you not using `find_packages()` with possible excludes for the test 
dirs?

- Second, forget to add a line into my MANIFEST.in, so the project
WebClient doesn't work properly.
(https://github.com/ivco19/libs/blob/master/MANIFEST.in)

So, after the fixes, I starting to mock tests to check this kind of
mistake. The idea was quick and dirty but works: I give a path to my
entire source-tree and the
the file generated with "setup.py sdist" must contain the exact same files.


"exact same files" doesn't quite work for the majority of the cases. Your Python package includes a subset of all the files which are in the git repository and you can indeed try to verify that this is the case. A simple extract & diff will do the trick.

However your package doesn't seem to include the databases/ directory for example. You see how this starts having exceptions very quickly hence a generic tool is very tricky and impractical to build.


FTR in one of my projects we have find_packages() in setup.py (which relies on __init__.py being present) so we made a custom pylint plugin to warn about .py files which are inside directories missing __init__.py:
https://github.com/kiwitcms/Kiwi/blob/master/kiwi_lint/empty.py#L30

An added nice bonus is that Django's test runner also relies of the presence of __init__.py and this helped us discover directories where we had had automated tests (test_...py) but they were not automatically picked up by the test runner.

--
Alex
_______________________________________________
code-quality mailing list -- code-quality@python.org
To unsubscribe send an email to code-quality-le...@python.org
https://mail.python.org/mailman3/lists/code-quality.python.org/
Member address: arch...@mail-archive.com

Reply via email to