Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

It's really a matter of culture.

Things like httpie, jupyter, etc should be provided as pyz and binaries as well, not just pip installable, but python devs don't do that really often.

It's a shame, because cli tools should be black boxes, people should not have to think about the implementation. I regularly see cli python tools that output stack traces on errors, and it should not happen.

Anyway, if you want those tools to be always around, I really encourage you to grap a usb stick, and put them on there as pyz and binaries. It's always nice to have them at hand.

Here is an example procedure for both (run them in a venv).

For pyz files:

    python -m pip install shiv --user # (Yes, I realize how ironic this is).
Then:

    python -m shiv httpie -o http.pyz -c http
(download httpie, and creates a http.pyz file that will contains httpie and all it's dependancies, plus code to trigger the http command when called)

This will let you do "python http.pyz" anywhere you have a modern python and enjoy httpie without the need to pip install it.

For an exe (this is an example on linux, the commands are a bit different for windows and mac):

    python -m pip install nuitka httpie --user
You need to have a C compiler and python headers around as well (gcc on linux will do, E.G: sudo apt install build-essential python3-dev on ubuntu).

Then:

    python -m nuitka $(which http) --onefile --linux-onefile-icon /usr/share/pixmaps/python3.xpm --follow-imports    --assume-yes-for-downloads

Wait quite a bit.

Now you have a nice stand alone AppImage you can call with ./http.bin to be used on any linux system, and not care if Python is installed to play with httpie.

Here are the resulting files (available for 5 days) so you can see what it looks like:

https://drop.chapril.org/download/a335a8e92f98ee02/#fHC1SvOw...


Is this better than using pex?


Pyz works with windows but not pex.

Nuitka produces a standalone exe so no need to install python.


My first attempt, and I get "AttributeError: module 'toml.decoder' has no attribute 'TomlPreserveCommentDecoder'"

So careful, far from stable.

I reported it (https://github.com/frostming/pdm/issues/247) because the project is great and I want it to succeed, but I won't put it in prod any time soon. I prefer my package manager to be stable than fancy.

It's also why I don't use poetry and so on in training. There is always some bug that students will encounter later because there are so many config combinations they can encounter, but recent tools have not been as battle tested as we think: the enterprise world is a wild beast.


> So careful, far from stable.

True, bugs can't be exposed by a few users. People have vastly different environment setup for their Python development. System python, in-venv, pyenv, asdf, homebrew, etc. So I post it here to seek for help testing.

The sematic versioning may be a bit misleading, it is just because there was a big breaking change to support PEP 621, and I marked it as "Alpha" stage.


I have a lot of respect for the way you react to this comment, and how quickly you fixed the bug.

Thank you for working on such a useful project, and so seriously.

I immediately encountered a second different error, and I'll also take the time to craft a good bug report for it.


That's literally what the article is about.


First, so many tutorials give you terrible information. People don't know about "-m", the "py" command, are told to use sudo and not --user.

The current situation is actually not that bad. With my students, the topic is quickly explained and mastered. But it's not a common occurrence.

However, it is true that it's still not as easy as it could be. Some reasons.

- Python is older than java.

- Python is shipped as part of MacOS and Linux, but using the system Python can cause issues, so it's a trap.

- Python deals with a lot of compiled extensions. Scipy embeds C, fortran and assembly. It's a hard problem.

- The Python project has *tremendously* less resources than java.

- Politics. Lots of it.

- Debian et Red Had packagers made a mess by splitting the python setup in many small packages.

- Python 2/3 transition took attention span from the problem during a decade.

- You often install many python versions on the same machine, which makes things harder.

- Python is used by a huge number of non programmers. Much more than java. This shows in the reported difficulties.

- There are way too many ways to install python. So many combinations of failure modes.

- Microsoft screw up with their store not packaging "py" or the core dev by not packaging it on Unix.

- Anaconda brings as many problems as it solves, and is popular because of enterprise limitations.


The “py” command?


I think that is referring to the Python launcher utility for Windows: https://docs.python.org/3/using/windows.html#python-launcher...


Poetry shell doesn't work on windows, and it doesn't have named venv which matters for some users. Also it's very slow, require to be installed and use proprietary fields in pyproject.toml.

It's a great tool but there are reasons you might want something else.

Alternative like raw pip, pip tools, or dephell all have various pros and cons.


>Poetry shell doesn't work on windows

What do you mean it doesn't work? It works fine on Windows here, unless I am missing something.


I'm being overly critical. Let's say it has problems:

- poetry shell didn't start the same shell that you were in: https://github.com/sarugaku/shellingham/issues/42. Looks like they fixed it 3 days ago though.

- It doesn't set the name of the project in the prompt, so you actually don't know you are in the shell. Very annoying if you have many windows.


>doesn't set the name of the project in the prompt

I agree with you there, it's very annoying and I've fallen for it a few times. Having not used Poetry on other platforms yet (still using Pipenv in a few projects), I wasn't even aware that this was a feature.


Not a solution, more a workaround, but on Windows I highly recommend developing using WSL, especially for Python. WSL + pyenv + poetry + VS Code with Remote WSL works amazingly well.


-m is the replacement for console scripts. Well behaved cli should define a _ _ main _ _. Py

Pytest, pylint, black, pip, poetry, mypy all have one.

Jupyter one is buggy.


That's a fair point actually.


Bit of a plug, but if you crave for that, and more, you can use AutoKey on Linux (not AutoHotKey which is Windows only): https://github.com/autokey/autokey

It will let you bind custom Python scripts to any mouse/keyboard sequence, including words on the fly. It can trigger word replacements just like Espanso (I use it to fill in emails, dates, addresses, timestamps et phone numbers), and of course, Python being Python, it lets you do a lot more.

The UI is probably not as good as Espanso's, and it may be harder to use (you need to script). On the other hand, it provides an API for prompting you with UI to select dates, files, input, etc., has timers and the whole Python 3 stdlib.

Some nice stuff I do with it:

- typing $email/$ phone present me with a list of email addresses/phone num (I have a lot of them) to insert one. Prevents typo. By pass web form limitations.

- $now and $date does something similar with dates (listing of various formats for the current date and a calendar). Very handy for documents and file name. Most of them don't have automated fields set up.

- $paste paste the clip board content, by passing any UI preventing me to do so, and screen/tmux limitations.

- I'm a heavy dynalist users (dynalist.io/) I love this software, but it lacks a lot of features, which are easy to add with AutoKey: just make a macro that inputs a serie of actions.


Hey, AutoKey is awesome indeed! I've used it myself for a while before developing espanso. In fact, I went through the code-base multiple times to understand how it could be so fast. I learned plenty of things about how the X server works thanks to you :)


Thanks for making your tool opens ource.

Do you plan to add scripting capabilities to Espanso or do you prefer to focus on the current use case ?


You're welcome! Espanso on Linux wouldn't be possible without other open-source projects, so that's the least I can do to give something back to the community :)

> Do you plan to add scripting capabilities to Espanso or do you prefer to focus on the current use case ?

We might add a "macro" feature to add delays and combine multiple keypresses, but I don't see espanso becoming a general "automation" tool. There are already plenty of great options for that (including AutoKey)!


In France at least. Our forests have been growing faster than we cut them for a few decades.


I took over the maintenance of 0bin.net, and FOSS client encrypted pastebin.

By design it's anonymous, so no account, and no tracking, hence not an obvious money maker.

But I like using it, and I feel no pressure to make it better or fix it, so I can work on it once a year and just be happy.


If it's just a crud app and not, a spa, even with a bit of ajax, sure I can, and so most devs I know.

Bu5 we are professionals, using frameworks. That changes things.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: