-
Notifications
You must be signed in to change notification settings - Fork 42
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
Make python3
compatible
#36
Conversation
Hi @IzaakWN , thanks a lot! To me looks good (just never saw this dot when importing classes, like from .TreeProducer import ..., but from google it looks like it should be right).
For now, that's all; I did not try with correctionlib yet. |
Hi @smonig, Thanks a lot for the quick feedback! Yes, the period for relative import was inserted by Adding your suggested instructions to the README is a good idea! It can be added to this PR. I will probably keep the old instructions as well. |
…nyway touching most of these files)
…er.analysis.TreeProducer
…d Summer19UL W+jets samples
After validating mostly the code in The aim was to keep compatibility with python 2.7 as far as possible to not completely break old setups, and avoid code divergences. However, python 2 has already reached its end of life in 2020, so anyone using nanoAOD v10 samples (produced with CMSSW 12) should definitely move to python 3 as soon as possible. As mentioned above, a To summarize the main changes for python 2 and 3 compatibility:
Other unrelated changes I snuck in:
Documentation:
Validation:
Known issues:
I will merge by tomorrow if no further feedback by @cardinia or @smonig. |
Make
.py
files compatible with bothpython2
andpython3
. This includes at least thepython
files that are compiled byscram b
. Note that files in$CMSSW_BASE/src/TauFW/*/python
need to bepython3
compatible forCMSSW_12_X
to compile.This PR addresses Issue #6, so we can more easily use
coffea
andcorrectionlib
, as well as become compatible withCMSSW_12_X
, wherepython3
compatibility is required when compiling withscram b
.Any feedback, @smonig, @cardinia?
Changes
As expected, most changes are related to
print
statements to print functions:print
→print()
;iteritems()
→items()
;xrange
→range
.String type
In some files where
basestring
is used to capture bothstr
and unicode objects inpython2
, one needsas
basestring
is not standard inpython3
, which does not distinguishstr
andunicode
, seehttps://python-future.org/compatible_idioms.html#basestring
http://docs.buildbot.net/0.9.3/developer/py3-compat.html
Piping
For some code in
Plotter/python/corrections/JetToTauFR/
, the followinghad to be changed to
(As a side note @kchrisucy:
JetToTauFR/
should probably be moved toPlotter/
. It's quite a large workspace and will be compiled each time a user usesscram b
. Is your latest setup different from the current version in themaster
branch?)Validation
So far I have only checked that it compiles with
scam b
inCMSSW_10_3_3
CMSSW_12_4_8
I still need to run the basic test scripts to ensure nothing broke.
Bookkeeping
The previous
master
branch version before the changes in this PR is tagged asv1.5_pre-python3
, and copied to thepython2
branch.