-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Package project #714
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
Package project #714
Conversation
Is it possible to maintain the current directory structure (or with slight renaming of current directories) while having tests? Or is that logical to do so? The main concern is really the accessibility. |
It should definitely be possible, but comes with two primary problems:
Also, we realized we must merge the directories that differ only by capitalization (e.g. I would say that, in general, having that many separate packages would be bad practice. However, since this is educational, I am inclined to agree with you that accessibility may come before engineering best practices here. We will try to make it happen! |
@poyea So, we have reverted back to the original directory structure and managed to get it to work well with Travis. TL;DR: We can do either approach, both work. With multiple top-level directories, you essentially get multiple projects from a Pythonic point of view. I can't really judge if this is better or worse for beginners. But the unified test suite will work for either approach, and with the work I just put in, neither is more difficult for us.
So point 1. I was worried about above is essentially a non-issue, as e.g. a virtual environment will not be a Python package. If you add a new package (top level directory), that will be discovered automatically as long as it has an The real hit to accessibility is that scripts that import stuff from other parts of the project must be run as modules. For example, if Any standalone script will still be runnable by just That's the price to pay for being able to test everything with one test suite! |
Oh, I can mention that we have almost finished work on making every module importable by the test suite (with Python 3). It essentially just consisted of:
But we thought that'd be better for a different PR. |
Hello! This turned into a bit of an essay, sorry :)
This PR fixes #708, and is mostly meant to give the maintainers of this project an idea of what we are doing on our end. We realize that this may prove too disruptive to the project as a whole, especially in such a short time, but think that this is the right direction to take it in the long run.
The intention of this PR is to move the project toward a proper Python package, which was the only way my group and I could find to make #309 possible. It does the following:
thealgorithms
(529dc79)__init__.py
files to all directories (some already had them), making them Python packages/subpackagesthealgorithms
and tries to import them (5fb67c2)setup.py
currently requires Python 2.7 or 3.6+ to install. This is easily tuned by changingpython_requires
insetup.py
..travis.yml
file to run every test in thetests
directory.Gathering everything in a package like this sacrifices some accessibility for absolute beginners, but has many benefits in our eyes. It allows for unified testing of the whole project in CI, making it much easier for maintainers to quickly check the quality of pull requests. Given that the project is well over 10000 lines of code by now, maintainability is important. It also makes the more complicated and dependency-heavy parts of the library easier to use, as the
setup.py
file allows one to install the whole package with dependencies using pip. Instructions for how to install should reasonably be added toREADME.md
, but we kept it insetup.py
for now.Note that, as a package, this is currently broken. Some parts support Python 3 only, some parts Python 2 only, and a few parts successfully support both. Only about 2/3 of the modules can be imported "properly" from the root of the project (and thus, from the package) at this time. For the reasons mentioned in #710, my group and I will primarily work on getting Python 3 support up and running, and migrating any existing tests into the
tests
directory. Our goal is to have every module be importable on a package, and having at least some functional tests running on Travis, by Tuesday next week.