dool
dool copied to clipboard
package on pypi
SUMMARY
make dool installable via pip install dool
ISSUE TYPE
- Feature Idea
see also: #4
the structure of the code is a bit... inconducive to python packaging. dool isn't importable, so it's hard to set it up as a console script. I made a symlink dool.py → dool, but the structure is still pretty odd. it relies on some globals to be set, so after moving the __main__ block into a _main() function, I added some globals. I don't really understand what the else block is for (how can __name__ ever not be __main__?) so I deleted it
diff --git c/dool i/dool
index 8c645b7..7910aa4 100755
--- c/dool
+++ i/dool
@@ -51,6 +53,24 @@ pluginpath = [
'/usr/local/share/dool/',
]
+def _main():
+ global op, theme
+ try:
+ initterm()
+ op = Options(os.getenv('DOOL_OPTS','').split() + sys.argv[1:])
+ theme = set_theme()
+ if op.profile:
+ import profile
+ if os.path.exists(op.profile):
+ os.remove(op.profile)
+ profile.run('main()', op.profile)
+ else:
+ main()
+ except KeyboardInterrupt as e:
+ if op.update:
+ sys.stdout.write('\n')
+ exit(0)
+
class Options:
def __init__(self, args):
self.args = args
@@ -2825,23 +2845,6 @@ def kd(obj):
### Main entrance
if __name__ == '__main__':
- try:
- initterm()
- op = Options(os.getenv('DOOL_OPTS','').split() + sys.argv[1:])
- theme = set_theme()
- if op.profile:
- import profile
- if os.path.exists(op.profile):
- os.remove(op.profile)
- profile.run('main()', op.profile)
- else:
- main()
- except KeyboardInterrupt as e:
- if op.update:
- sys.stdout.write('\n')
- exit(0)
-else:
- op = Options('')
- step = 1
+ _main()
# vim: tabstop=4 shiftwidth=4 expandtab autoindent softtabstop=4
with a few other minor tweaks and the pyproject.toml below, flit install works
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
[project]
name = "dool"
authors = [{name = "Scott Baker", email = "[email protected]"}]
readme = "README.md"
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"]
dynamic = ["version", "description"]
[project.urls]
Home = "https://github.com/scottchiefbaker/dool"
[project.scripts]
dool = "dool:_main"
[tool.flit.sdist]
exclude = [".github/*", ".gitignore", "docs/*", "examples/*", "install.py", "packaging/*", "Makefile"]
the main problem, though, is plugins/. it can't find any after installing
I doubt we want the package to be importable after installation as plugins, so we probably want to instead have a src/ or dool/ with a __main__.py and make plugins/ a subdir of that. that'd require a minor change to pluginpath and updating the rpm and snap packaging code
Dool is 100% functional with just the dool script. The plugins are nice, but not required. If it's simpler we could just install dool and leave installing the plugins as an optional thing that can be done later?
Where do we stand on this? I'm not 100% familiar with the startup code (I inherited this code). Your solution above looks clean to me, I would be fine moving towards that. I doubt the else does anything.
If you want to submit a PR to rework that startup code I'll test it.
I re-worked and documented the startup in 5874a3e3. Hopefully it's an improvement, and it's easier to read.
5874a3e3
nice. though I don't think the __main will work since you can't access double underscore prefixed symbols usually
do you wanna package it up for pypi?
Can you elaborate on "you can't access double underscore prefixed symbols"?
I have zero experience packaging for pypi, I was hoping someone in the community would take that project on so we can spread the dool love.
oh, apparently double underscore only applies to class members. it works fine, disregard me
as for how to package, just add my pyproject.toml from the first comment, change "dool:_main" to "dool:__main", and then (pip install flit and) run flit install or flit build to make sure it works the way you want
once you're happy with it, make an account on https://test.pypi.org and publish there (https://flit.pypa.io/en/stable/upload.html). once you're happy with that, make an account on real pypi and publish!
@raylu is that something that I need to do, or is it that something someone in the community is able to do? Are their security restrictions that require me personally to do it? I'm not a Python expert, I inherited this project, and I'm certainly NOT a Python ecosystem expert. I'm not really looking to take on adding a package on PyPi onto my plate.
Other projects I have been involved in (Perl and Javascript) the community was able to take the code I wrote and get it packaged up. That freed up my time to focus on the code and the release team would handle getting it pushed to various repositories.
you can do it yourself. there is no special list of trusted packagers for pypi. anyone can make a new package on pypi
it is... conventional for the package maintainer to claim the package on pypi. I can do it for you if you want, but I'd at least want to add you as a maintainer if I made the package
@raylu if you have experience making packages then please, by all means, make dool a package and add me as a maintainer. I'll gladly give you credit in the readme.
I just remembered that pypi now has a whole fancy trusted publishers thing https://docs.pypi.org/trusted-publishers/ that lets you publish from a GH action https://github.com/marketplace/actions/pypi-publish
so I made https://github.com/scottchiefbaker/dool/compare/next...raylu:dool:next which ran https://github.com/raylu/dool/actions/runs/8842864700 which created https://test.pypi.org/project/dool
you can follow the pip install instructions on that last page to install it and see if it's to your liking. assuming you do, I'll send you a PR that publishes to actual pypi
OMG that is amazing. You are a gentlemen and a scholar.
Yes I am definitely interested, please send a PR.
thanks for this! can a release be created so it is published to pypi rather than test.pypi?
@rbavery done and done!
https://github.com/scottchiefbaker/dool/releases/tag/v1.3.2
oh nice! I was gonna manually publish 1.3.1, but that works too. also glad to see my thing actually worked, heh
now that the package is created, do you want to make a pypi account and I'll add you as a mainatiner?
@raylu I created an account: scottchiefbaker