Skip to content
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 it work both with Python2 and Python3 #488

Merged
merged 3 commits into from
Oct 15, 2019

Conversation

mike-fabian
Copy link
Contributor

With this change (and some changes I did to the python code in https://github.com/googlei18n/noto-emoji.git I was able to build the "NotoColorEmoji.ttf" font using Python3.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

print >> f, '</table>'
print >> f, _HTML_FOOTER
f.write('<td>'.join(cols) + '\n')
f.write('<tr><td colspan=4>&nbsp;')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why no '\n' added in these lines?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meant to make that a review comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right! adding these '\n' ...

Copy link
Contributor

@dougfelt dougfelt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this. Saw a few newlines I wasn't sure about.

@@ -3285,10 +3285,10 @@ def _dump_primaries():
for block in unicode_data.block_names():
block_range = unicode_data.block_range(block)
primary_script = _primary_script_for_block(block)
print '%13s %6s %s' % (
print('%13s %6s %s\n' % (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the '\n' is not wanted here? Print already issues a newline, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! Sorry!

@@ -84,17 +84,17 @@ def noto_checkout(
failed_tags.append('%s: %s' % (r, t))

if failed_tags:
print >> sys.stderr, 'failed to find:\n %s' % '\n '.join(failed_tags)
sys.stderr.write('failed to find:\n %s' % '\n \n'.join(failed_tags))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added newline is in the wrong place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

@@ -784,7 +784,7 @@ def _read_emoji_data(lines):
continue

# discourage lots of redundant copies of seq_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete comment, no longer applies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, no longer applies when the intern() is gone!

print >> f, '</table>'
print >> f, _HTML_FOOTER
f.write('<td>'.join(cols) + '\n')
f.write('<tr><td colspan=4>&nbsp;')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meant to make that a review comment

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@PureTryOut
Copy link

So this will close #472 when merged then.

@mike-fabian
Copy link
Contributor Author

Do I need to do something about the “Need a CLA for one or more commit authors”?

The commits have mfabian@redhat.com as the author e-mail, should I change that to my Google mail maiku.fabian@gmail.com because I used that to sign the CLA? I tried to add mfabian@redhat.com as an additional address to my google account, but that didn’t work because it is used in my work account and apparently one cannot add the same address to another google account.

@dougfelt
Copy link
Contributor

dougfelt commented Jul 18, 2019 via email

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@mike-fabian
Copy link
Contributor Author

Hmmm, I'm not sure about workarounds for this. If you can change the commit address that would likely work.

I have changed the commit address.

@RoelN
Copy link
Contributor

RoelN commented Sep 5, 2019

I can't get pip3 install -r requirements.txt to install properly. I'm on macOS High Sierra. It errors out on:

Building wheels for collected packages: pyclipper
Building wheel for pyclipper (setup.py) ... error
[...]
  2 warnings and 1 error generated.
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyclipper
  Running setup.py clean for pyclipper
  Failed to build pyclipper
[...]

and then:

ERROR: ufo2ft 2.9.1 has requirement booleanOperations>=0.8.2, but you'll have booleanoperations 0.7.0 which is incompatible.
ERROR: ufo2ft 2.9.1 has requirement defcon>=0.6.0, but you'll have defcon 0.3.1 which is incompatible.
ERROR: mutatormath 2.1.2 has requirement defcon>=0.3.5, but you'll have defcon 0.3.1 which is incompatible.
ERROR: fontmake 1.10.1 has requirement booleanOperations>=0.8.2, but you'll have booleanoperations 0.7.0 which is incompatible.
ERROR: fontmake 1.10.1 has requirement defcon[lxml]>=0.6.0, but you'll have defcon 0.3.1 which is incompatible.

I eventually managed to get al requirements in order by manual installs through pip3 and brew. I was able to run:

sudo python3 setup.py develop

So while it's working now (a Noto Emoji build is happily purring in the background), I'm not sure if I'm doing something wrong, the requirements.txt need to be modified or something else is wrong. Any advice?

@RoelN
Copy link
Contributor

RoelN commented Sep 16, 2019

If nobody else is running into problems, bite the bullet and go full python 3? @dougfelt

@RoelN
Copy link
Contributor

RoelN commented Oct 8, 2019

googlefonts/noto-emoji#267 is waiting for this PR. Can we merge this?

Copy link
Contributor

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this! LGTM

@@ -99,7 +99,7 @@ def _collect_script_to_punct(files):
script = cldr_data.get_likely_script(filename)
if script == 'Zzzz':
if filename != 'root':
print >> sys.stderr, 'no script for %s' % filename
sys.stderr.write('no script for %s\n' % filename)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to use print with stderr you can do:

Suggested change
sys.stderr.write('no script for %s\n' % filename)
print('no script for %s' % filename, file=sys.stderr)

but sys.stderr.write works too

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys.stderr.write(foo) works in both python2 and python3, print(foo, file=sys.stderr) only works in python3.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to from __future__ import print_function.
If we haven't done that yet, we should make sure to add this as well as the other two canonical future imports (absolute_import, division) to all modules.

@@ -468,7 +468,7 @@ def _process_data(data):
arg_type = m.group(4)
comment = m.group(5)

while line_indent <= indent[0]:
while len(line_indent) <= indent[0]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. Surprising how py2 would silently let you to compare a string with an int.. I wonder if this was working at all before

@@ -783,8 +783,7 @@ def _read_emoji_data(lines):
if m.group(2):
continue

# discourage lots of redundant copies of seq_type
seq_type = intern(m.group(3).strip().encode('ascii'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW the old intern builtin was moved to sys.intern: https://docs.python.org/3/library/sys.html?highlight=sys.intern#sys.intern

@anthrotype anthrotype merged commit 1a6d1c4 into notofonts:master Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants