-
Notifications
You must be signed in to change notification settings - Fork 128
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
Use setuptools.find_packages() in setup.py (was: Prepend bin/
to PATH in test build runner script)
#527
Conversation
Codecov Report
@@ Coverage Diff @@
## master #527 +/- ##
==========================================
+ Coverage 18.65% 18.68% +0.02%
==========================================
Files 31 31
Lines 5061 5053 -8
Branches 1282 1281 -1
==========================================
Hits 944 944
+ Misses 4090 4082 -8
Partials 27 27
Continue to review full report at Codecov.
|
Could you write a bit more about the general idea here? I don't use the |
Here's an example of the problematic behavior: https://travis-ci.com/github/nextstrain/augur/jobs/315709402. That branch introduces a new package Invoking augur with
I did not realize I'll be the first to admit I lack experience with the "environment" side of Python; I don't really know what the standard approach is here, either. |
There's a difference in how #526 imports augur code compared with how it's imported by current augur commands, which I believe is causing the error. Again, I'm unsure about best practices, but I'm worried if Travis fails with
Our "normal" way of doing it (example)
|
If relative imports are the project's preferred way to do it, then that's an easy fix and this PR can be closed. But PEP 8 does encourage absolute imports (emphasis added because that may be the case here):
Regarding readability: If the new module had required something from from ..utils import myopen which can quickly become difficult to read, especially if augur is refactored to have many more modules (and a deeper hierarchy of modules) than it does now. See, for example, https://github.com/nextstrain/augur/pull/494/files, where from ...utils import ambiguous_date_to_date_range Maybe the change proposed in PR is not the right solution. But IMO the inability to use absolute imports is an opportunity for improvement. |
My 2¢: Both absolute and relative imports should work identically in augur. Sometimes relative imports are nicer to use, sometimes absolute are. If they don't both work, that's a dev/test environment or installation bug that needs fixing. In development and testing, there is often confusion over which copy of the package is loaded/used. This depends on the method of invocation, the cwd, PYTHONPATH, and lots of other variables. Fixing import issues in tests usually means first figuring out exactly what's getting loaded and why. For example, Python automatically adds the current directory to its library path, so (The so-called "src layout" for repos addresses this issue and several related ones. I prefer it, but it's not what Augur uses, so there are lots of nuances.) |
The "src layout" makes a lot of sense. I was unaware of many of its benefits. Here's what I propose to move forward:
How does that sound? |
|
See discussion at nextstrain#527
It seems the relative vs absolute question was a red herring. The Travis build failed even when using a relative import:
https://github.com/nextstrain/augur/pull/526/checks It still passes locally, same as the absolute import. |
5d2890c
to
3bbb315
Compare
Ongoing refactoring efforts have been trying to introduce new packages. All packages must be listed in the packages argument to `setuptools.setup()`. `setuptools.find_packages()` provides a convenient way to list all packages without manually updating a list.
3bbb315
to
c1041b8
Compare
Okay, found the problem. I was way off. It turns out that listing a package in Pushed the change and renamed this PR. #532 includes this commit, cherry-picked, and the build passes correctly. |
bin/
to PATH in test build runner scriptbin/
to PATH in test build runner script)
Description of proposed changes
This causes the command
augur
(invoked by snakemake) to always be the dev helper scriptbin/augur
when running the test builds. No functional changes to the app.Related issue(s)
none
Testing
The test build script should run on systems where augur is not even installed—only the repo needs to be checked out. You can simulate this by making sure
augur
is not in your PATH and trying the test build runner.Edit: cherry-picking this change into #526 allowed that build to pass. Now that I think about it, I'm not sure how the test builds ever worked without this. What
augur
executable is snakemake invoking in the Travis container? Is it a Conda thing?