dabeaz / curio

Good Curio!
Other
4.01k stars 240 forks source link

Re-upload source distribution without tests/__pycache__ #301

Closed jonringer closed 4 years ago

jonringer commented 5 years ago

if you download the source from pypi, and do pytest test/ you will get something similar to

ImportError while loading conftest '/build/curio-0.9/tests/conftest.py'.
py._path.local.LocalPath.ImportMismatchError: ('conftest', '/Users/beazley/Desktop/Projects/junk/curio/tests/conftest.py', local('/build/curio-0.9/tests/conftest.py'))

the tests are picking up the pycache directory and reading invalid information.

dabeaz commented 5 years ago

I have no idea what this would even be. Is this a bug in pytest?

jonringer commented 5 years ago

sorry, the markup is eating some of the formatting

there's a tests/__pycache__/ in the source package on pypi. So when you run pytest, it will default to using the the cache. Specifically in this case, there's a pyc for conftest.py and it has a resolved path from your machine.

jonringer commented 5 years ago

to reproduce:

$ curl -O https://files.pythonhosted.org/packages/e4/61/6e7daab81d17c47296c63c346d794c29e95218a7bceba88bf4a57cf7bb27/curio-0.9.tar.gz
$ tar xf curio-0.9.tar.gz
$ cd curio-0.9
$ virtualenv env
$ source env/bin/activate
$ python -m pip install -e .
$ python -m pytest . # fails

# to fix
$ rm -r tests/__pycache__/
$ python -m pytest . # succeeds

the folder acutally takes up quite a bit of space

# after downloading
$ du -hd0 curio-0.9.tar.gz
472K    curio-0.9.tar.gz

$ tar xf curio-0.9.tar.gz
$ du -hd0 curio-0.9
2.4M    curio-0.9

$ du -hd0 curio-0.9/tests/__pycache__
1.1M    curio-0.9/tests/__pycache__

# after deleting
$ rm -r curio-0.9/tests/__pycache__/
$ tar czf curio-0.9-slim.tar.gz curio-0.9/
$ du -h curio-0.9-slim.tar.gz
280K    curio-0.9-slim.tar.gz
jonringer commented 5 years ago

I actually like that you package the tests, and would like to keep them in the source distribution. I'm not super familiar with doing python packaging, but i think something like recursive-exclude __pycache__ *.pyc *.pyo *.orig in the MANIFEST.in to prevent cache files from appearing in the wheels would be nice.

SOURCES.txt right now:

...
tests/__pycache__/conftest.cpython-35.pyc
tests/__pycache__/conftest.cpython-36-PYTEST.pyc
tests/__pycache__/conftest.cpython-37-PYTEST.pyc
tests/__pycache__/test_activation.cpython-35-PYTEST.pyc
tests/__pycache__/test_activation.cpython-36-PYTEST.pyc
tests/__pycache__/test_activation.cpython-37-PYTEST.pyc
tests/__pycache__/test_asyncgen.cpython-36-PYTEST.pyc
tests/__pycache__/test_asyncgen.cpython-37-PYTEST.pyc
tests/__pycache__/test_asyncio.cpython-35-PYTEST.pyc
tests/__pycache__/test_asyncio.cpython-36-PYTEST.pyc
tests/__pycache__/test_asyncio.cpython-37-PYTEST.pyc
tests/__pycache__/test_channel.cpython-35-PYTEST.pyc
tests/__pycache__/test_channel.cpython-36-PYTEST.pyc
tests/__pycache__/test_channel.cpython-37-PYTEST.pyc
tests/__pycache__/test_file.cpython-35-PYTEST.pyc
tests/__pycache__/test_file.cpython-36-PYTEST.pyc
tests/__pycache__/test_file.cpython-37-PYTEST.pyc
tests/__pycache__/test_io.cpython-35-PYTEST.pyc
tests/__pycache__/test_io.cpython-36-PYTEST.pyc
tests/__pycache__/test_io.cpython-37-PYTEST.pyc
tests/__pycache__/test_kernel.cpython-35-PYTEST.pyc
tests/__pycache__/test_kernel.cpython-36-PYTEST.pyc
tests/__pycache__/test_kernel.cpython-37-PYTEST.pyc
tests/__pycache__/test_meta.cpython-35-PYTEST.pyc
tests/__pycache__/test_meta.cpython-36-PYTEST.pyc
tests/__pycache__/test_meta.cpython-37-PYTEST.pyc
tests/__pycache__/test_network.cpython-35-PYTEST.pyc
tests/__pycache__/test_network.cpython-36-PYTEST.pyc
tests/__pycache__/test_network.cpython-37-PYTEST.pyc
tests/__pycache__/test_promise.cpython-35-PYTEST.pyc
tests/__pycache__/test_promise.cpython-36-PYTEST.pyc
tests/__pycache__/test_promise.cpython-37-PYTEST.pyc
tests/__pycache__/test_queue.cpython-35-PYTEST.pyc
tests/__pycache__/test_queue.cpython-36-PYTEST.pyc
tests/__pycache__/test_queue.cpython-37-PYTEST.pyc
tests/__pycache__/test_signal.cpython-35-PYTEST.pyc
tests/__pycache__/test_signal.cpython-36-PYTEST.pyc
tests/__pycache__/test_signal.cpython-37-PYTEST.pyc
tests/__pycache__/test_socket.cpython-35-PYTEST.pyc
tests/__pycache__/test_socket.cpython-36-PYTEST.pyc
tests/__pycache__/test_socket.cpython-37-PYTEST.pyc
tests/__pycache__/test_subprocess.cpython-35-PYTEST.pyc
tests/__pycache__/test_subprocess.cpython-36-PYTEST.pyc
tests/__pycache__/test_subprocess.cpython-37-PYTEST.pyc
tests/__pycache__/test_sync.cpython-35-PYTEST.pyc
tests/__pycache__/test_sync.cpython-36-PYTEST.pyc
tests/__pycache__/test_sync.cpython-37-PYTEST.pyc
tests/__pycache__/test_task.cpython-35-PYTEST.pyc
tests/__pycache__/test_task.cpython-35.pyc
tests/__pycache__/test_task.cpython-36-PYTEST.pyc
tests/__pycache__/test_task.cpython-36.pyc
tests/__pycache__/test_task.cpython-37-PYTEST.pyc
tests/__pycache__/test_task.cpython-37.pyc
tests/__pycache__/test_thread.cpython-35-PYTEST.pyc
tests/__pycache__/test_thread.cpython-36-PYTEST.pyc
tests/__pycache__/test_thread.cpython-37-PYTEST.pyc
tests/__pycache__/test_workers.cpython-35-PYTEST.pyc
tests/__pycache__/test_workers.cpython-36-PYTEST.pyc
tests/__pycache__/test_workers.cpython-37-PYTEST.pyc
dabeaz commented 5 years ago

Ugh. Sadly, I can't update an already existing release file on PyPi. That said, Curio is probably overdue for a release update anyways. I've had a number of minor cleanup items on my list for awhile so maybe I'll take care of that and do it soon.

jonringer commented 5 years ago

For most people this isn't an issue, it's just that nixpkgs will run tests if available by default, and it's preferred in the nix community.

But thank you for you work in FOSS, it's appreciated :).