hauntsaninja / pyp

Easily run Python at the shell! Magical, but never mysterious.
MIT License
1.41k stars 39 forks source link

What is the relationship between pypyp and pyp (by thepyedpiper / Sony)? #35

Open nealmcb opened 7 months ago

nealmcb commented 7 months ago

Over time, I've run across and used both this and pyp from https://github.com/thepyedpiper/pyp, and am now very confused.

History? Compatibility? Feature comparison? Can both be installed at the same time (outside a virtualenv)?

nealmcb commented 7 months ago

Now I see that you do note the original pyp from thepyedpiper in your Readme - sorry to have missed it. But the confusion has increased recently. While you say that one is "unmaintained", a new version came out in December 2023: "Pyed Piper Celebrates its 10 Year Anniversary with an Epic Update!" ... retooled to Python 3 ...

So it might help to e.g. allow this one to be run as pypyp, so both can run at the same time, and discuss some of the similarities and differences.

hauntsaninja commented 7 months ago

Thanks for the issue!

Wow, surprised to see Pyed Piper back from the dead after ten years :-) I'd emailed Toby Rosen at some point too, but never heard back.

I just added pypyp as an entrypoint in https://github.com/hauntsaninja/pyp/commit/4999c07a3e397c850486319978d47d35781067d6. This means (once I make a release (edit: 1.2 is now released)) that you should be able to use them both in the same environment provided you install pypyp first.

I also updated the README with some more description: https://github.com/hauntsaninja/pyp/commit/ab80ed9dc8202c244bff102945bcf16606e0ab74

I talk about tools in general here: https://github.com/hauntsaninja/pyp#piep--spy--pyfil--pythonpy--oneliner

I think Pyed Piper matches the following two bullet points

  • Some of them have custom syntax for in-process command chaining, which can be convenient.
  • Some of them expose the input in interesting ways with custom line / file / stream objects.

Hopefully that's of any use, and do let me know if you have more questions :-)

nealmcb commented 2 months ago

Excellent - I finally got back to trying to figure this out again. I need to keep better notes....

My one suggestion for now would be to refer to the command using the name used to run it. E.g. I get this with 1.2 now, which would be confusing to those running the other version of pyp.

$ pypyp
usage: pyp [-h] [--explain] [-b CODE] [-a CODE] [--define-pypprint] [--version] code [code ...]
nealmcb commented 2 months ago

It seems to me that in order to have both running at the same time, it needs a bit more smarts. E.g. this works when the original pyp is not installed. But when both are installed, I get:

$ seq 1 5 | pypyp 'sum(map(int, lines))'
Traceback (most recent call last):
  File "/home/neal/.local/bin/pypyp", line 5, in <module>
    from pyp import main
ImportError: cannot import name 'main' from 'pyp' (/home/neal/.local/lib/python3.10/site-packages/pyp/__init__.py)

Note also that if, on top of pypyp, you pip install pyp and then pip uninstall pyp (to fix the errors above), that will first overwrite and then delete pyp from ~/.local/bin//pyp. So I had to unistall and reinstall pypyp to get the original command back.