Comments (3)
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.
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:
- almost all Zope projects
- https://github.com/pallets/flask
- https://github.com/getsentry/sentry
- https://github.com/python-pillow/Pillow
- https://github.com/pypa/pip
- https://github.com/pytest-dev/pytest
- https://github.com/twisted/twisted
- https://github.com/Pylons/pyramid
- https://github.com/pyca/cryptography
- ...
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-colorinput.