Giter VIP home page Giter VIP logo

Comments (3)

der-gabe avatar der-gabe commented on July 28, 2024

This might not be necessary, after all.

It certainly wasn't necessary for packaging and publishing this project on PyPI, which already happened! 😄

That leaves this to be decided as to whether it makes sense at all. I need to find out something about why people do this, what problems it solves and what the benefits are...

from django-colorinput.

jugmac00 avatar jugmac00 commented on July 28, 2024

Hi @der-gabe,

there seems to be more than one reason.

A minor reason:
When more and more projects adept a src directory, it is easier to navigate the code base when you have a look at a new project.

It seems to be an emerging standard - just a few projects which follow this new, unwritten convention:

The important reason:
When you develop a package, which is also installed, when you do a from your_project import something - is your_project then the installed package or your project's folder?

This can be problematic both when you start testing, but also already for your application.

There are several well written articles out there which explain the issues in detail - and what to do about it:
https://hynek.me/articles/testing-packaging/
https://web.archive.org/web/20170615032800/https://enotuniq.org/
https://blog.ganssle.io/articles/2019/08/test-as-installed.html

from django-colorinput.

der-gabe avatar der-gabe commented on July 28, 2024

Hi @jugmac00 ,

thanks for your comment and the list of projects that already follow this convention. You're quite right, it does seem to be the new normal.

Thanks for the articles, as well, which I've now read.

I was aware of Hynek's article, as that's the one everyone always references when it comes to this, but I had never actually read it. Now I have and he makes some very good points.

Interestingly, the second article actually argues that you don't need to do the whole src thing just to let your tests run against the code as installed, since tox provides a mechanism to run in another directory. Nice, but Hynek's other points about nicer repo structure and packaging still stand (and indeed, forgetting to include a resource when packaging has happened to me with this very project).

The third article is interesting, as it recommends the src subdir approach, but then goes on to show the way to avoid it - the same changedir trick for tox as presented in article 2. Towards the end, the author does say that they were inspired by the older article and merely wrote theirs to spread the word and preserve the knowledge.

Either way, at this point the src subdirectory is so common that it's even got its own subsection in the official setuptools docs and it does make for a rather cleaner code layout.

Not to mention that fact that it makes packaging easier.

I'll probably bite the bullet and make the switch at some point after merging my testing branch and certainly before the next release (i.e. the next time I need to package this thing).

from django-colorinput.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.