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

Directory layout for chap #19

Closed
peterkaminski opened this issue Oct 4, 2023 · 3 comments
Closed

Directory layout for chap #19

peterkaminski opened this issue Oct 4, 2023 · 3 comments

Comments

@peterkaminski
Copy link
Contributor

@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:

  • python -m src.chap or
  • pip install -r ../requirements.txt

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:

  • nothing; everything is fine :)
  • I could rewrite this as an issue (i.e., what to change) rather than as a comment, and either you or I could set up a PR to address
  • optionally, with or without changes, I can write up a short section for the README which documents how to install requirements and run python -m chap for people who are running from the source code

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

@jepler
Copy link
Owner

jepler commented Oct 4, 2023

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
Copy link
Owner

jepler commented Oct 7, 2023

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.

@jepler jepler closed this as completed Oct 7, 2023
@peterkaminski
Copy link
Contributor Author

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.

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

No branches or pull requests

2 participants