Bug 1479484 - Part 1: Add make_dafsa.py to the virtualenv's python path, r=froydnj
authorNika Layzell <nika@thelayzells.com>
Tue, 31 Jul 2018 18:20:18 -0400
changeset 429731 20668aaf20ebbef0dad5b18b0db001bee589da3e
parent 429730 2a5aa9de1fd9760a9245ecae815a6e02bb9eef42
child 429732 a509c3520b77d0b2a813b641904fc2e6f03805a3
push id34372
push usernerli@mozilla.com
push dateThu, 02 Aug 2018 08:55:28 +0000
treeherdermozilla-central@bd79b07f57a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1479484
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1479484 - Part 1: Add make_dafsa.py to the virtualenv's python path, r=froydnj Summary: The plan is to also expose perfecthash.py from this module on the python path. This also allows us to stop using explicit module loading to load make_dafsa.py. make_dafsa.py was moved into tools/ to avoid any extra python files from accidentally ending up on the python path. Reviewers: froydnj! Tags: #secure-revision Bug #: 1479484 Differential Revision: https://phabricator.services.mozilla.com/D2614
build/virtualenv_packages.txt
netwerk/dns/prepare_tlds.py
security/manager/ssl/moz.build
xpcom/ds/make_dafsa.py
xpcom/ds/tools/make_dafsa.py
xpcom/tests/gtest/moz.build
--- a/build/virtualenv_packages.txt
+++ b/build/virtualenv_packages.txt
@@ -60,16 +60,17 @@ mozilla.pth:tools
 mozilla.pth:testing/web-platform
 mozilla.pth:testing/web-platform/tests/tools/third_party/html5lib
 mozilla.pth:testing/web-platform/tests/tools/third_party/webencodings
 mozilla.pth:testing/web-platform/tests/tools/wptrunner
 mozilla.pth:testing/web-platform/tests/tools/wptserve
 mozilla.pth:testing/web-platform/tests/tools/six
 mozilla.pth:testing/xpcshell
 mozilla.pth:third_party/python/mock-1.0.0
+mozilla.pth:xpcom/ds/tools
 mozilla.pth:xpcom/typelib/xpt/tools
 mozilla.pth:tools/docs
 mozilla.pth:third_party/python/cbor2
 mozilla.pth:third_party/python/pyasn1
 mozilla.pth:third_party/python/pyasn1-modules
 mozilla.pth:third_party/python/rsa
 mozilla.pth:third_party/python/PyECC
 optional:packages.txt:comm/build/virtualenv_packages.txt
--- a/netwerk/dns/prepare_tlds.py
+++ b/netwerk/dns/prepare_tlds.py
@@ -3,16 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import codecs
 import encodings.idna
 import imp
 import os
 import re
 import sys
+from make_dafsa import words_to_cxx
 
 """
 Processes a file containing effective TLD data.  See the following URL for a
 description of effective TLDs and of the file format that this script
 processes (although for the latter you're better off just reading this file's
 short source code).
 
 http://wiki.mozilla.org/Gecko:Effective_TLD_Service
@@ -99,24 +100,16 @@ class EffectiveTLDEntry:
 
 def main(output, effective_tld_filename):
   """
   effective_tld_filename is the effective TLD file to parse.
   A C++ array of a binary representation of a DAFSA representing the
   eTLD file is then printed to output.
   """
 
-  # Find and load the `make_dafsa.py` script under xpcom/ds.
-  tld_dir = os.path.dirname(effective_tld_filename)
-  make_dafsa_py = os.path.join(tld_dir, '../../xpcom/ds/make_dafsa.py')
-  sys.path.append(os.path.dirname(make_dafsa_py))
-  with open(make_dafsa_py, 'r') as fh:
-    make_dafsa = imp.load_module('script', fh, make_dafsa_py,
-                                 ('.py', 'r', imp.PY_SOURCE))
-
   def typeEnum(etld):
     """
     Maps the flags to the DAFSA's enum types.
     """
     if etld.exception():
       return 1
     elif etld.wild():
       return 2
@@ -125,12 +118,12 @@ def main(output, effective_tld_filename)
 
   def dafsa_words():
     """
     make_dafsa expects lines of the form "<domain_name><enum_value>"
     """
     for etld in getEffectiveTLDs(effective_tld_filename):
       yield "%s%d" % (etld.domain(), typeEnum(etld))
 
-  output.write(make_dafsa.words_to_cxx(dafsa_words()))
+  output.write(words_to_cxx(dafsa_words()))
 
 if __name__ == '__main__':
     main(sys.stdout, sys.argv[1])
--- a/security/manager/ssl/moz.build
+++ b/security/manager/ssl/moz.build
@@ -180,17 +180,17 @@ LOCAL_INCLUDES += [
 LOCAL_INCLUDES += [
     '!/dist/public/nss',
 ]
 
 GENERATED_FILES = [
     'nsSTSPreloadList.h',
 ]
 dafsa_data = GENERATED_FILES['nsSTSPreloadList.h']
-dafsa_data.script = '../../../xpcom/ds/make_dafsa.py'
+dafsa_data.script = '../../../xpcom/ds/tools/make_dafsa.py'
 dafsa_data.inputs = ['nsSTSPreloadList.inc']
 
 if CONFIG['NSS_DISABLE_DBM']:
     DEFINES['NSS_DISABLE_DBM'] = '1'
 
 DEFINES['SSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES'] = 'True'
 DEFINES['NSS_ENABLE_ECC'] = 'True'
 for var in ('DLL_PREFIX', 'DLL_SUFFIX'):
rename from xpcom/ds/make_dafsa.py
rename to xpcom/ds/tools/make_dafsa.py
--- a/xpcom/tests/gtest/moz.build
+++ b/xpcom/tests/gtest/moz.build
@@ -100,17 +100,17 @@ SOURCES += [
 LOCAL_INCLUDES += [
     '../../base',
 ]
 
 GENERATED_FILES = [
     'dafsa_test_1.inc',
 ]
 dafsa_data = GENERATED_FILES['dafsa_test_1.inc']
-dafsa_data.script = '../../ds/make_dafsa.py'
+dafsa_data.script = '../../ds/tools/make_dafsa.py'
 dafsa_data.inputs = ['dafsa_test_1.dat']
 
 TEST_HARNESS_FILES.gtest += [
     'wikipedia/ar.txt',
     'wikipedia/de-edit.txt',
     'wikipedia/de.txt',
     'wikipedia/ja.txt',
     'wikipedia/ko.txt',