Trying to get Python sbin commands from nbdev

by Mike Levin

Thursday, May 26, 2022

Okay, so to blow up… first get those title tags back in! That’s not a project. It’s just a little thing to do. Start with the site config files generated by the blog slice & dice system. You don’t have to broadcast everything!

Don’t make false dependencies. Don’t make thing A depend on project B. Project B will never get done, so thing A will never get done. Say something intelligent about thing A… Ugh! The _config.yml is coming from… various places. Not good.

Okay, so what’s completely obvious now was that even though I was able to whip together this amazing blog slice & dice system using bash files, .py files and Jupyter Notebooks, it has become too difficult to control. There are too many different technologies dove-tailing together and I have to make it one system unified, clearly under Notebooks & nbdev.

1, 2, 3… 1?

Keep everything in the notebook, even the list of sites.

Hmmm, but I wrote blogslicer as a command-line tool. And that seems logical. This SHOULD be able to be cobbled together from a Linux bash script or from “pure” Python. But the pure python will still be executing the pieces as if a bash script. Yes, that’s exactly it. Start making the framework. Don’t be in such a rush to fix the title tag with a bandaid. That will fall in place. So again, 1, 2, 3… 1?

The Attempt To Make a CLI Command From Python setuptools setup.py via nbdev

Well, blogslicer is already pip installable. Keep that so. So if you were to pip install blogslicer, what should the desired consequences be? How are pip installed things able to be made runnable from the command-line? And is this a rabbit hole? Or necessary growth?

nbdev does this extensively. Go look at it in github… (nbdev settings.ini)[https://github.com/fastai/nbdev/blob/master/settings.ini]

Hmmm… interesting. And on the (main nbdev tutorial)[https://nbdev.fast.ai/tutorial.html] they say:

Set up console scripts

Behind the scenes, nbdev uses that standard package setuptools for handling installation of modules. One very useful feature of setuptools is that it can automatically create cross-platform console scripts. nbdev surfaces this functionality; to use it, use the same format as setuptools, with whitespace between each script definition (if you have more than one).

Wow! How could I not use this approach?

But beware the rabbit hole!

Post like this really belong on MikeLevinSEO.com… but maybe not. Maybe I’m boosting MikeLev.in as much as it can go with all these YouTube videos I’m doing. Those .com sites are so 1990s, after all. A .in site is cool, especially how it matches my name exactly. So go with that for a bit.

Is This a Rabbit Hole? Too Deep?

How to mitigate the rabbit hole? Is this just “bite the bullet” and do it work?

How do we make it not a project and just a thing? What’s the first thing?

Hmmm, I’m building up some fundamental new knowledge here. There is such a thing as an (editable install)[http://codumentary.blogspot.com/2014/11/python-tip-of-year-pip-install-editable.html] Jeez, I should have known that! Okay, make sure I internalize that point… so important! It seems so easy now. Before doing a pip install (so I can pip uninstall anything I have installed) I just cd into the repo and type:

pip install -e .

Hmmm, okay. I’ve got some work to do. Gotta test this…

I did one failed attempt at this during a lunch livestream. I forgot that the new JuputerLabs 3.3.4-2 has the Terminals working now.

python filename.py -f "foo.txt"
filename -f "foo.txt"
nbdev_clean_nbs
nbdev_build_lib

Re-implementing my blog slice & dice system, which is super-awesome for SEO!

Hello? Hello, hello. I said hello. I credited the 1981 movie Arthur with Dudley Moore with what I was quoting with all those hellos. I was wrong. It was the 1990 Dudley Moore movie Crazy People which I saw while I was in college for Graphic Design, just getting involved in the world of Advertising. Ugh! I should have taken that message about the marketing and advertising world to heart and switched back to science and engineering.

I started out in mechanical engineering in college and was shaken out in that first year when they crush anyone with creativity and imagination, but not the ability to do the math. I believe now that I had the ability to do the math, but my parent and pre-college schools let me down.

My homeschooled child is being let down in the same way right now and I’m giving thought how to lead them down a righteous path of math. Good God Math Path. Wolf Woof! And all that onomatopoeia wordplay channeling. There’s something here I need to release.

How in the world did I end up in the field of search engine optimization? Am I clawing my way out of advertising and marketing through the most noble science and data-driven paths I can find? Maybe. And I’m fifty-one effin’ years old.

Not much time!

Remind the folks what I’m trying to accomplish.

KEYWORDS IN (lining up cross-hairs)

Jigsaw puzzle approach / modularity of the Unix & Linux flavor. That means the components will be written in Python, but they’ll be called exactly as Linux CLI-command (ls, cd, pwd, git) are called.

Much Ikigai of Atari and Amiga Computers Came From Unix

It’s good to do worthwhile stuff in life, that is good for your soul, good for other peoples’ souls and good for the world in general. Somehow you could feel the ikigai in the Amiga and Atari computers of the late 1980s and early 1990s. It was a magical time of awakening (for me) which allowed little bits of love-worthy Unix into the operating systems. These days, I’m trying to channel this same spirit through helping people jump on the bandwagon of:

…is the cure to a lot of things… even modern anxiety, depression, existential crisis… because it’s grounding.

Because you can think in vim.

Because vim is like driving and gets into muscle memory.

There’s nothing like vim… except for all the other vims… emacs in eVIl mode.

Get the idea? vi is not gone. Never was. Everyone in the know knows every other approach to text-editing (which lean heavily on graphical desktops) are poor attempts to preserve the powerful old Jedi ways. vi is an elegant weapon for a more civilized time.

Bringing back the old text editors (vi(m) & emacs)? Nah, they were never gone.

I was first introduced to vim in 1991 on Fred Fish (Public Domain Disk) #591 Thank you, Tony Antonuccio.

Be Charlie Brown! Get back up and come back at it again. But talk clearly to Lucy. Make sure she understands your concerns. That’s where I pick up on the next entry.