Commit Graph

5 Commits

Author SHA1 Message Date
Lionel Dricot 8b97acc5e0 relative import back to offpunk 2023-09-16 10:53:15 +02:00
Lionel Dricot 963ac3d7a3 merging refactor 2023-09-16 10:32:26 +02:00
Austreelis 6e215c0512 Use relative imports when importing offpunk's own modules
This should allow running offpunk locally from any
directory.
2023-09-09 22:43:45 +02:00
Austreelis 370e7e4dc5 Add scripts to run tools locally
This adds a script for each executable, and a __main__.py for offpunk
itself.  This intends to "fix" (albeit unperfectly, see below) how
46f61bf forbade locally running executables without first installing
offpunk in your site packages (or hacking on PYTHONPATH).

Of those, most are "glue script", files in the top-level directory
and outside offpunk's module, which are purely there to allow running
the `netcache`, `ansicat` and `opnk` without any other setup than a
working python and a `git clone`.  Notably, they will not be included in
the source distribution (sdist) archive built by flit.

Sadly the `offpunk` executable doesn't get the same treatment, because
having both an `offpunk.py` script and an `offpunk` python package
is ambiguous, and flit disallows that, avoiding to package anything.
So instead it now has a pretty bare __main__.py, which really works the
same way as the "glue scripts", except this one does get packaged.
This means everything but `offpunk` may be run like `./netcache.py`,
making this setup a bit inconsistent (which may or may not be an issue).
Running `python -m <tool>` works for everything though, so there *is* a
consistent way to run them all, and in the darkness, bind them.
2023-09-08 17:21:11 +02:00
Austreelis bc43e3150b Put everything in a common offpunk package
This moves around and renames a bunch of code, as an effort toward
fixing the flit build process.  Simply put, all source code has been
moved in an `offpunk` directory, and renamed in ways that (hopefully)
make sense.  The `pyproject.toml` file has been updated, too.

This changes how to import code from offpunk modules: old top-level
modules are now under `offpunk` (`import netcache` ->
`from offpunk import netcache`), and "off" prefixes have been stripped
(`from offutils import run` -> `from offpunk.utils import run`).

Note file mode x (execute) was removed on all touched files (if it was
set before), meaning they cannot be executed exactly like before this
change.  Running scripts directly (`./offpunk/netcache.py`) is broken
because python doesn't populate parent modules of top-level modules.
Running `python -m offpunk.netcache` is broken because running inner
python modules as top-level this way *does* populate parent modules
(assuming my understanding is correct, but it may very well not be), but
it can somehow trigger undefined behavior (!?).  Running
`python -m offpunk` still works though.

Signed-off-by: Austreelis <dev@austreelis.net>
2023-09-08 17:21:07 +02:00