-
Notifications
You must be signed in to change notification settings - Fork 49
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
Python3 compatibility #1673
Python3 compatibility #1673
Conversation
35eb00d
to
5626853
Compare
8310bd9
to
3871db9
Compare
Codecov Report
@@ Coverage Diff @@
## master #1673 +/- ##
==========================================
- Coverage 79.3% 79.28% -0.03%
==========================================
Files 186 186
Lines 35059 35063 +4
==========================================
- Hits 27804 27798 -6
- Misses 7255 7265 +10
|
Finally all green! Ready for review once you are back, @trws. Sorry about the order in which the commits show up in GitHub. I guess it orders them by the commit date rather than their order in the git history. Unfortunately, that might make this PR a little confusing to review, if you prefer to go through PRs commit-by-commit. |
Cool! I'm really wondering now what is going in Travis. The builds on master keep failing with some kind of output truncation error, but your PR on top of current master worked. 😕 |
This looks great to me. The only thing that occurs to me, are the flake tests back to running? I don't see anything that should tickle it but I remember @grondo mentioning they were partially deactivated at some point. |
@trws: that is a good point. I think pylint tests were running under the old travis config but have been turned off during the switch to Docker. I'll look into turning them back on. I believe they were turned off due to lots of errors from newer pylint versions. |
Yeah, I had to disable pylint because it wasn't passing :-) |
Co-authored-by: Stephen Herbein <herbein1@llnl.gov>
- Uses `six` package for most of the py2 and py3 support - Also uses `from __future__ import print_function` Co-authored-by: Stephen Herbein <herbein1@llnl.gov>
3871db9
to
1d3bc20
Compare
Pylint has been re-enabled, and the resulting errors fixed. Bad first argument given to super classThe biggest change was switching no-else-returnFor this error, in most cases, I obliged the linter, but in one particular case, I think the if/else is sufficiently large that the way it's currently written is easier to read/parse. So I overrode that case. no-value-for-parameterpylint really hates the useless-object-inheritancepylint3 doesn't like |
Wow, nice work. I'm happy, and would say LGTM. |
52d0f22
to
f5e05e5
Compare
It may be possible to fix some of this, but let me lay out the reasoning for the current pattern for context. python file copyingThis was part of the reason for breaking out the built extensions into _flux. The python searchpath only uses the first module that matches, this is what lua does as well actually, which meant that when everything was under so copying out of .libsThis is mainly because libtool deals with library search paths and library generation in general in the most frustrating way conceivable. Since nothing but libtool can actually read .la files, and the .so files are invalid in the build path without explicitly adding library paths to the environment, there's a non-trivial amount of working around that broken behavior. If we used anything else, that would just build the sos as valid in the build tree then re-path them on install, none of that would be necessary. If we can avoid it, I'm all for it, but that was the best way I could think of at the time to build with the same tooling as the rest of flux and still get the job done. |
Following up on a conversation @SteVwonder and I had yesterday about If it isn't used on some platform or OS, I've lost track of which. Never mind? |
I think you're right that there is a case where it doesn't create the .libs directory, but IIRC that's only on systems that don't support shared objects, which means our modules and python's couldn't be built anyway, so I wasn't worrying about it. |
Embarrassingly enough, it was only after I removed the copying that the reason for the split finally "clicked" (thanks for the paving the way on that one). The split worked btw, there is no longer copying of source files over to the build tree (the exception being the Sidenote: the |
I can't tell off-hand, but do any of the commits in here need to be squashed together? (Not trying to make useless work for you though!) Also, a comment on commit messages: commit messages should be written in the imperative for consistency (e.g. You might only want to address the commit message comments if you have to squash and rebase anyway. |
Yeah, I can squash some of the latter changes to the automake files. I did a squashing pass on the python changes earlier this week.
Will do. Thanks!
Let me see if I can tweak my emacs config to enforce this automatically (I think the default is ~80) |
- moves generated shared libraries to a _flux directory - adds *.py and *.c gitignores to _flux directory Done so that ultimately setuptools can be used for building the python bindings. Co-authored-by: Stephen Herbein <herbein1@llnl.gov>
- removes the user-passable flux handle to RPC which has changed from a flux_handle_t to a flux_future_t - removes a use of flux_rpc_multi - improves error checking in KVS API calls
Also includes minor cleanup of several of the tests
- all input strings are checked to determine if they need to be encoded all - returned strings are decoded as 'utf-8', there are a few exceptions where the strings are decoded as 'ascii' (like getting the state of a job from the JSC)
add source tree to PYTHONPATH in AM_TEST_ENVIRONMENT to remove need to copy the source py files into the build tree add BUILT_SOURCES primary and use `nodist_` prefix to prevent distribution of auto-generated c files replace copying of python .so's out of .libs directory with symlinking
- use a LOG_DRIVER rather than direct execution - rename python tests to have .py extension rather than .t - tests now run under the same python interpreter that flux was configured with This commit adds a thin wrapper around the tap-driver.sh to retain test output granularity while still ensuring the python tests are executed with the python interpreter that flux was configured with.
Disable unwanted and address relevant lint warnings. Bad first argument given to super class: The biggest change was switching `super(self.__class__, self)` to actually directly reference the class. `self.__class__` works when the class is at the front of the MRO, but as soon as another class inherits from that class, an infinite recursion happens in the `__init__`. Most of the uses were in a class that was inside another class, so I doubt anyone would actually subclass them, but at least now pylint is happy. no-else-return: For this error, in most cases, I obliged the linter, but in one particular case (src/bindings/python/flux/wrapper.py:224), I think the if/else is sufficiently large that the way it's currently written is easier to read/parse. So I overrode that case. no-value-for-parameter: pylint really hates the `ffi` and `lib` modules being passed in as arguments to `Wrapper.__init__`. I don't see a better way to do it, so I just manually overrode each instance. useless-object-inheritance: pylint3 doesn't like `class WrapperBase(object)`. Disabled universally since this is required for py2 backwards compatibility.
f5e05e5
to
33532ff
Compare
Squashed a few commits and re-wrapped several commit message bodies to be < 72 characters. This PR should be good to go now. |
Awesome!
Yeah, sorry, this isn't too important, but it keeps |
Not a problem at all; it is a pretty easily automated thing. Now that I have my emacs config setup, it shouldn't be a problem in the future. Maybe we should consider adding a check for things like that and coding style to the CI so that maintainers don't have to bother asking for it to be addressed. |
This PR builds off of @trws's PR and updates the python bindings to work for both python 2 & 3.
Major changes include:
char*
s coming out of Flux are assumed to beutf-8
minus a few exceptions (e.g., job states from the JSC).utf-8
. If they are raw bytes, they are passed straight through.t/python
fromsrc/bindings/python/tests
.sideflux
to using thesubflux
moduleChoosing which python to build against
The current automake macro searches automatically for a python interpreter >= 2.7. AFAIK, it searches from the newest, stable python version (3.7) and works its way down (to 2.1). To override this behavior, users can set the
PYTHON
orPYTHON_VERSION
env variables when runningconfigure
(these two vars are documented in the output ofconfigure --help
). After some searching online, I didn't see any pre-built solutions for compiling the bindings with both python2 and python3 simultaneously with autotools. It seems like a lot of projects that do this treat their bindings as separate project or a sub-project housed in-tree. I am starting a discussion on how to handle this in #1448.Closes #1669
Closes #1448
Closes #1046
Closes #805