jepler / chap

chap - A Python interface to chatgpt, including a terminal user interface (tui)
15 stars 2 forks source link

Directory layout for `chap` #19

Closed peterkaminski closed 1 year ago

peterkaminski commented 1 year ago

@jepler, this is more of a question or a comment than an issue.

When I work on the chap code in the checked-out repo, I end up running the code with python -m chap. (Hence the desire to have a requirements.txt file, as noted in #5 and #15.)

You've got the chap directory in the /src directory, which makes sense, because it's source code.

However, for python -m chap to work, I need to change directory to be within the src directory. Which in itself is fine, no big deal.

However^2, the new requirements.txt file from #15 is at the root. So for pip install -r requirements.txt to work, I need to be at the root.

Again, none of this is a big deal, but it's a little detail that I would smooth out, probably by moving the chap directory to the root (or requirements.txt to src, but that seems less aesthetically pleasing).

It's not a problem to prepend src or .. in the right places, either:

Or to just change directory at the right times.

But it seems like extra and unexpected cognitive overhead, just for having chap inside src.

Possible next steps:

Let me know if I can help on any of those!

jepler commented 1 year ago

I'm happy to adjust this for "best practices" but figuring out what that is, is hard. Changing the readme is easiest in some sense.

I'm not against removing the mostly useless "src" level of the hierarchy, but only after seeing if I can reconstruct the reason I added it in the first place.

jepler commented 1 year ago

Having a "src/" directory is recommended by pypa documentation as is using "pip install -e" to work in 'development mode' (more on development mode)

Given these two pieces of advice from the official python packaging documentation, I don't plan to remove the src/ directory level at this time.

However, in #15 I have added a script "chap.py" in the top level that does allow pip install -r requirements.txt; python chap.py to work.

peterkaminski commented 1 year ago

Thank you for the accommodation!

Following the pypa advice is obviously a good thing, and I generally like the top-level script to run chap -- I think it makes the repo more usable, if also a little more messy.