Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create entry point (for direct run & pipx installation) #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

goyalyashpal
Copy link

@goyalyashpal goyalyashpal commented Jan 27, 2024

PR template taking from newpipe

Thanks a lot for doing #15 super properly in such a thorough way 😃 🙏 😇
This wouldn't even be remotely possible without that one

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Please don't squash i think?

Description of the changes in your PR

(chronological order):

  • refac(pyweb): Define single-point entry function ...
  • build(pyproject): Add setuptools entry point ...
  • replace python -m pyweb with pyweb
  • hint towards using pipx install py-web-lp in installation instructions

Before/After Screenshots/Screen Record

Before:

(click to collapse/expand)
  • Either of (install) or (upgrade/uninstall) is bound to be hard
  • Usage was a little inconvenient as well
$ ## trying to install via pipx
$ pipx install py-web-lp
No apps associated with package py-web-lp. ...
$ ## If aiming for easy installation, & average use (but possible clashes):
$ pip install py-web-lp

$ ## use and upgrade:
$ python -m pyweb -V
$ pip install -U jinja markupsafe py-web-lp 

$ ## uninstall (have to manually check first for any other dependency on these though:
$ pip uninstall jinja markupsafe py-web-lp
$ ## If aiming for no clashes, and easy uninstallation:
$ python -m venv .venv
$ source .venv/bin/activate
$ pip --require-virtualenv install py-web-lp
$ pip freeze > pyweb_dep.txt

$ ## use and upgrade:
$ source .venv/bin/activate
$ python -m pyweb -V
$ pip --require-virtualenv install -U -r pyweb.txt

$ ## uninstall:
$ source .venv/bin/activate
$ pip --require-virtualenv uninstall -r pyweb_dep.txt -y
$ rm -Ir .venv/ pyweb_dep.txt

After:

$ pipx install py-web-lp        # install
$ pyweb -V                      # run
$ pipx upgrade py-web-lp        # upgrade
$ pipx uninstall py-web-lp      # uninstall

$ # wait, there's (possibility of) even more:
$ pipx reinstall py-web-lp      # reinstall - useful for dev-ing
$ man pyweb                     # if manpage were already existing
$ pipx run --spec py-web-lp pyweb -V            # for temporary trial - is automatically removed after 14d

Fixes the following issue(s)

  • no issues were filled for this

Testing

  • i have not changed the install instructions, i have just hinted at that. also, should docutils too be installed via pipx then? i don't know.

  • i have just done find/replace on python -m pyweb to pyweb, hoping it would work everywhere

  • Please try the following:

$ ## navigate to the *root dir* of this local repo

$ # pipx install --pip-args='-e' .  # -e (editable install) won't work for this test

$ pipx install ./                   # ✅ existing/bootstrapping¹ pyweb.py works
$ pipx list
$ pyweb -V                          # ✅ pyweb works
$ which pyweb

$ ls -l src/{impl.w,pyweb.py}
$ rm src/pyweb.py

$ pyweb -xw src/impl.w -o src/
$ ls -l src/{impl.w,pyweb.py}       # ✅ src is tangled/generated

$ pipx reinstall py-web-lp          # ✅ impl.w works

[1]: Bootstrapping | pyWeb docs https://slott56.github.io/py-web-tool/src/_build/html/pyweb.html#id15

@goyalyashpal goyalyashpal marked this pull request as draft January 27, 2024 06:42
@goyalyashpal goyalyashpal marked this pull request as ready for review January 27, 2024 08:47
@goyalyashpal
Copy link
Author

goyalyashpal commented Jan 28, 2024

update: no, it is not even accepted to change those during devt, let alone requirement to do so.

py-web-tool/README.rst

Lines 103 to 104 in b5b8d24

Note that a previous release, untouched, is saved in the project's ``bootstrap`` directory.
This is **not** changed during development, since **py-web-lp** is written with **py-web-lp**.


i have not changed the bootstrap files bootstrap/pyweb.py, was that required too?

https://github.com/slott56/py-web-tool/blob/main/README.rst#testing

@goyalyashpal goyalyashpal marked this pull request as draft January 29, 2024 03:26
Problem: no single point of invokation is available from outside
        as main()'s aguments are defined inside the globally scoped
        if's body
Solution: Factor out global if-name-main's body as a function, call
        just that function from the if-name-main, as well as from
        outside

This commit body template is inspired by Bram Moolenaar's commit
messages, as highlighted in https://neovim.io/news/2023/08
Problem: `pyweb` can't run directly; requires calling as
        `python -m pyweb`
Solution: Add entry point according to the build backend used
        i.e. setuptools

  This also allows, using command `pipx install pyweb`:
  its installation via pipx as a standalone program isolated
  from system wide py libs, which makes other maintenance
  tasks very easy: (view docs, upgrade, uninstall, reinstall)

  Read more at:
  * https://pipx.pypa.io/stable/
  * https://setuptools.pypa.io/en/stable/userguide/entry_point.html
  * as it's no longer needs `python -m` before it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant