Bug 1601578 - mach - doc environment with python 3 r=ahal,firefox-build-system-reviewers,chmanchester

Differential Revision: https://phabricator.services.mozilla.com/D55937

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Sylvestre Ledru 2019-12-17 01:30:41 +00:00
Родитель a684c2e36e
Коммит e945783c5b
6 изменённых файлов: 61 добавлений и 78 удалений

1
mach
Просмотреть файл

@ -32,7 +32,6 @@ py2commands="
cramtest
crashtest
devtools-css-db
doc
doctor
empty-makefiles
file-info

Просмотреть файл

@ -50,6 +50,7 @@ import mozpack.path as mozpath
from types import FunctionType
import itertools
import six
# The MOZ_HARDENING_CFLAGS and MOZ_HARDENING_LDFLAGS differ depending on whether
@ -313,7 +314,7 @@ class BaseCompileFlags(ContextDerivedValue, dict):
klass_name = self.__class__.__name__
for k, v, build_vars in self.flag_variables:
if not isinstance(k, unicode):
if not isinstance(k, six.text_type):
raise ValueError('Flag %s for %s is not a string'
% (k, klass_name))
if not isinstance(build_vars, tuple):
@ -328,7 +329,7 @@ class BaseCompileFlags(ContextDerivedValue, dict):
# a template were set and which were provided as defaults.
template_name = getattr(context, 'template', None)
if template_name in (None, 'Gyp'):
dict.__init__(self, ((k, v if v is None else TypedList(unicode)(v))
dict.__init__(self, ((k, v if v is None else TypedList(six.text_type)(v))
for k, v, _ in self.flag_variables))
else:
dict.__init__(self)
@ -611,7 +612,7 @@ class WasmFlags(TargetCompileFlags):
TargetCompileFlags.__init__(self, context)
class FinalTargetValue(ContextDerivedValue, unicode):
class FinalTargetValue(ContextDerivedValue, six.text_type):
def __new__(cls, context, value=""):
if not value:
value = 'dist/'
@ -621,7 +622,7 @@ class FinalTargetValue(ContextDerivedValue, unicode):
value += 'bin'
if context['DIST_SUBDIR']:
value += '/' + context['DIST_SUBDIR']
return unicode.__new__(cls, value)
return six.text_type.__new__(cls, value)
def Enum(*values):
@ -670,7 +671,7 @@ class PathMeta(type):
return super(PathMeta, cls).__call__(context, value)
class Path(ContextDerivedValue, unicode):
class Path(ContextDerivedValue, six.text_type):
"""Stores and resolves a source path relative to a given context
This class is used as a backing type for some of the sandbox variables.
@ -701,7 +702,7 @@ class Path(ContextDerivedValue, unicode):
def __cmp__(self, other):
if isinstance(other, Path) and self.srcdir != other.srcdir:
return cmp(self.full_path, other.full_path)
return cmp(unicode(self), other)
return cmp(six.text_type(self), other)
# __cmp__ is not enough because unicode has __eq__, __ne__, etc. defined
# and __cmp__ is only used for those when they don't exist.
@ -1014,18 +1015,18 @@ ReftestManifestList = OrderedPathListWithAction(read_reftest_manifest)
OrderedSourceList = ContextDerivedTypedList(SourcePath, StrictOrderingOnAppendList)
OrderedTestFlavorList = TypedList(Enum(*all_test_flavors()),
StrictOrderingOnAppendList)
OrderedStringList = TypedList(unicode, StrictOrderingOnAppendList)
OrderedStringList = TypedList(six.text_type, StrictOrderingOnAppendList)
DependentTestsEntry = ContextDerivedTypedRecord(('files', OrderedSourceList),
('tags', OrderedStringList),
('flavors', OrderedTestFlavorList))
BugzillaComponent = TypedNamedTuple('BugzillaComponent',
[('product', unicode), ('component', unicode)])
[('product', six.text_type), ('component', six.text_type)])
SchedulingComponents = ContextDerivedTypedRecord(
('inclusive', TypedList(unicode, StrictOrderingOnAppendList)),
('exclusive', TypedList(unicode, StrictOrderingOnAppendList)))
('inclusive', TypedList(six.text_type, StrictOrderingOnAppendList)),
('exclusive', TypedList(six.text_type, StrictOrderingOnAppendList)))
GeneratedFilesList = StrictOrderingOnAppendListWithFlagsFactory({
'script': unicode,
'script': six.text_type,
'inputs': list,
'force': bool,
'flags': list, })
@ -1347,8 +1348,8 @@ VARIABLES = {
),
'RUST_LIBRARY_TARGET_DIR': (
unicode,
unicode,
six.text_type,
six.text_type,
"""Where CARGO_TARGET_DIR should point when compiling this library. If
not set, it defaults to the current objdir. It should be a relative path
to the current objdir; absolute paths should not be used.
@ -1369,13 +1370,13 @@ VARIABLES = {
),
'RUST_TESTS': (
TypedList(unicode),
TypedList(six.text_type),
list,
"""Names of Rust tests to build and run via `cargo test`.
"""),
'RUST_TEST_FEATURES': (
TypedList(unicode),
TypedList(six.text_type),
list,
"""Cargo features to activate for RUST_TESTS.
"""
@ -1632,7 +1633,7 @@ VARIABLES = {
"""Like ``OBJDIR_FILES``, with preprocessing. Use sparingly.
"""),
'FINAL_LIBRARY': (unicode, unicode,
'FINAL_LIBRARY': (six.text_type, six.text_type,
"""Library in which the objects of the current directory will be linked.
This variable contains the name of a library, defined elsewhere with
@ -1677,7 +1678,7 @@ VARIABLES = {
"""Source code files to compile with the wasm compiler.
"""),
'HOST_LIBRARY_NAME': (unicode, unicode,
'HOST_LIBRARY_NAME': (six.text_type, six.text_type,
"""Name of target library generated when cross compiling.
"""),
@ -1688,7 +1689,7 @@ VARIABLES = {
libraries that link into this library via FINAL_LIBRARY.
"""),
'LIBRARY_NAME': (unicode, unicode,
'LIBRARY_NAME': (six.text_type, six.text_type,
"""The code name of the library generated for a directory.
By default STATIC_LIBRARY_NAME and SHARED_LIBRARY_NAME take this name.
@ -1700,7 +1701,7 @@ VARIABLES = {
``example/components/xpcomsample.lib`` on Windows.
"""),
'SHARED_LIBRARY_NAME': (unicode, unicode,
'SHARED_LIBRARY_NAME': (six.text_type, six.text_type,
"""The name of the static library generated for a directory, if it needs to
differ from the library code name.
@ -1708,17 +1709,17 @@ VARIABLES = {
"""),
'SANDBOXED_WASM_LIBRARY_NAME': (
unicode, unicode,
six.text_type, six.text_type,
"""The name of the static sandboxed wasm library generated for a directory.
"""),
'SHARED_LIBRARY_OUTPUT_CATEGORY': (unicode, unicode,
'SHARED_LIBRARY_OUTPUT_CATEGORY': (six.text_type, six.text_type,
"""The output category for this context's shared library. If set this will
correspond to the build command that will build this shared library, and
the library will not be built as part of the default build.
"""),
'RUST_LIBRARY_OUTPUT_CATEGORY': (unicode, unicode,
'RUST_LIBRARY_OUTPUT_CATEGORY': (six.text_type, six.text_type,
"""The output category for this context's rust library. If set this will
correspond to the build command that will build this rust library, and
the library will not be built as part of the default build.
@ -1731,7 +1732,7 @@ VARIABLES = {
Implies FORCE_SHARED_LIB.
"""),
'STATIC_LIBRARY_NAME': (unicode, unicode,
'STATIC_LIBRARY_NAME': (six.text_type, six.text_type,
"""The name of the static library generated for a directory, if it needs to
differ from the library code name.
@ -1763,31 +1764,31 @@ VARIABLES = {
This variable contains a list of system libaries to link against.
"""),
'RCFILE': (Path, unicode,
'RCFILE': (Path, six.text_type,
"""The program .rc file.
This variable can only be used on Windows.
"""),
'RESFILE': (unicode, unicode,
'RESFILE': (six.text_type, six.text_type,
"""The program .res file.
This variable can only be used on Windows.
"""),
'RCINCLUDE': (Path, unicode,
'RCINCLUDE': (Path, six.text_type,
"""The resource script file to be included in the default .res file.
This variable can only be used on Windows.
"""),
'DEFFILE': (Path, unicode,
'DEFFILE': (Path, six.text_type,
"""The program .def (module definition) file.
This variable can only be used on Windows.
"""),
'SYMBOLS_FILE': (Path, unicode,
'SYMBOLS_FILE': (Path, six.text_type,
"""A file containing a list of symbols to export from a shared library.
The given file contains a list of symbols to be exported, and is
@ -1808,7 +1809,7 @@ VARIABLES = {
``BIN_SUFFIX``, the name will remain unchanged.
"""),
'SONAME': (unicode, unicode,
'SONAME': (six.text_type, six.text_type,
"""The soname of the shared object currently being linked
soname is the "logical name" of a shared object, often used to provide
@ -1890,7 +1891,7 @@ VARIABLES = {
``GENERATED_FILES``.
"""),
'PROGRAM': (unicode, unicode,
'PROGRAM': (six.text_type, six.text_type,
"""Compiled executable name.
If the configuration token ``BIN_SUFFIX`` is set, its value will be
@ -1898,7 +1899,7 @@ VARIABLES = {
``BIN_SUFFIX``, ``PROGRAM`` will remain unchanged.
"""),
'HOST_PROGRAM': (unicode, unicode,
'HOST_PROGRAM': (six.text_type, six.text_type,
"""Compiled host executable name.
If the configuration token ``HOST_BIN_SUFFIX`` is set, its value will be
@ -1936,7 +1937,7 @@ VARIABLES = {
files.
"""),
'XPIDL_MODULE': (unicode, unicode,
'XPIDL_MODULE': (six.text_type, six.text_type,
"""XPCOM Interface Definition Module Name.
This is the name of the ``.xpt`` file that is created by linking
@ -2089,14 +2090,14 @@ VARIABLES = {
"""),
# The following variables are used to control the target of installed files.
'XPI_NAME': (unicode, unicode,
'XPI_NAME': (six.text_type, six.text_type,
"""The name of an extension XPI to generate.
When this variable is present, the results of this directory will end up
being packaged into an extension instead of the main dist/bin results.
"""),
'DIST_SUBDIR': (unicode, unicode,
'DIST_SUBDIR': (six.text_type, six.text_type,
"""The name of an alternate directory to install files to.
When this variable is present, the results of this directory will end up
@ -2104,7 +2105,7 @@ VARIABLES = {
otherwise be placed.
"""),
'FINAL_TARGET': (FinalTargetValue, unicode,
'FINAL_TARGET': (FinalTargetValue, six.text_type,
"""The name of the directory to install targets to.
The directory is relative to the top of the object directory. The
@ -2124,7 +2125,7 @@ VARIABLES = {
'GYP_DIRS': (StrictOrderingOnAppendListWithFlagsFactory({
'variables': dict,
'input': unicode,
'input': six.text_type,
'sandbox_vars': dict,
'no_chromium': bool,
'no_unified': bool,
@ -2169,7 +2170,7 @@ VARIABLES = {
'sandbox_vars': dict,
'non_unified_sources': StrictOrderingOnAppendList,
'mozilla_flags': list,
'gn_target': unicode,
'gn_target': six.text_type,
}), list,
"""List of dirs containing gn files describing targets to build. Attributes:
- variables, a dictionary containing variables and values to pass

Просмотреть файл

@ -19,4 +19,4 @@ sphinx = "~=1.8.5"
tornado = "~=5.1.1"
[requires]
python_version = "2.7"
python_version = "3"

51
tools/docs/Pipfile.lock сгенерированный
Просмотреть файл

@ -1,11 +1,11 @@
{
"_meta": {
"hash": {
"sha256": "b2ceda63df0d0688997816fab3f7d43ba3611f6a2a4352de2af14aa9a5305e4a"
"sha256": "0d78f0e6f293c9b18601f45dd8cf67d2a1b32aee95e083658a413141b69f94f1"
},
"pipfile-spec": 6,
"requires": {
"python_version": "2.7"
"python_version": "3"
},
"sources": [
{
@ -97,21 +97,6 @@
],
"version": "==0.17.0"
},
"future": {
"hashes": [
"sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"
],
"markers": "python_version < '3'",
"version": "==0.18.2"
},
"futures": {
"hashes": [
"sha256:49b3f5b064b6e3afc3316421a3f25f66c137ae88f068abbf72830170033c5e16",
"sha256:7e033af76a5e35f58e56da7a91e687706faf4e7bdfb2cbc3f2cca6b9bcda9794"
],
"markers": "python_version == '2.6' or python_version == '2.7'",
"version": "==3.3.0"
},
"idna": {
"hashes": [
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
@ -196,10 +181,10 @@
},
"pygments": {
"hashes": [
"sha256:83ec6c6133ca6b529b7ff5aa826328fd14b5bb02a58c37f4f06384e96a0f94ab",
"sha256:b7949de3d396836085fea596998b135a22610bbcc4f2abfe9e448e44cbc58388"
"sha256:2a3fe295e54a20164a9df49c75fa58526d3be48e14aceba6d6b1e8ac0bfd6f1b",
"sha256:98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe"
],
"version": "==2.5.1"
"version": "==2.5.2"
},
"pyparsing": {
"hashes": [
@ -233,21 +218,19 @@
},
"pyyaml": {
"hashes": [
"sha256:0113bc0ec2ad727182326b61326afa3d1d8280ae1122493553fd6f4397f33df9",
"sha256:01adf0b6c6f61bd11af6e10ca52b7d4057dd0be0343eb9283c878cf3af56aee4",
"sha256:5124373960b0b3f4aa7df1707e63e9f109b5263eca5976c66e08b1c552d4eaf8",
"sha256:5ca4f10adbddae56d824b2c09668e91219bb178a1eee1faa56af6f99f11bf696",
"sha256:7907be34ffa3c5a32b60b95f4d95ea25361c951383a894fec31be7252b2b6f34",
"sha256:7ec9b2a4ed5cad025c2278a1e6a19c011c80a3caaac804fd2d329e9cc2c287c9",
"sha256:87ae4c829bb25b9fe99cf71fbb2140c448f534e24c998cc60f39ae4f94396a73",
"sha256:9de9919becc9cc2ff03637872a440195ac4241c80536632fffeb6a1e25a74299",
"sha256:a5a85b10e450c66b49f98846937e8cfca1db3127a9d5d1e31ca45c3d0bef4c5b",
"sha256:b0997827b4f6a7c286c01c5f60384d218dca4ed7d9efa945c3e1aa623d5709ae",
"sha256:b631ef96d3222e62861443cc89d6563ba3eeb816eeb96b2629345ab795e53681",
"sha256:bf47c0607522fdbca6c9e817a6e81b08491de50f3766a7a0e6a5be7905961b41",
"sha256:f81025eddd0327c7d4cfe9b62cf33190e1e736cc6e97502b3ec425f574b3e7a8"
"sha256:0e7f69397d53155e55d10ff68fdfb2cf630a35e6daf65cf0bdeaf04f127c09dc",
"sha256:2e9f0b7c5914367b0916c3c104a024bb68f269a486b9d04a2e8ac6f6597b7803",
"sha256:35ace9b4147848cafac3db142795ee42deebe9d0dad885ce643928e88daebdcc",
"sha256:38a4f0d114101c58c0f3a88aeaa44d63efd588845c5a2df5290b73db8f246d15",
"sha256:483eb6a33b671408c8529106df3707270bfacb2447bf8ad856a4b4f57f6e3075",
"sha256:4b6be5edb9f6bb73680f5bf4ee08ff25416d1400fbd4535fe0069b2994da07cd",
"sha256:7f38e35c00e160db592091751d385cd7b3046d6d51f578b29943225178257b31",
"sha256:8100c896ecb361794d8bfdb9c11fce618c7cf83d624d73d5ab38aef3bc82d43f",
"sha256:c0ee8eca2c582d29c3c2ec6e2c4f703d1b7f1fb10bc72317355a746057e7346c",
"sha256:e4c015484ff0ff197564917b4b4246ca03f411b9bd7f16e02a2f586eb48b6d04",
"sha256:ebc4ed52dcc93eeebeae5cf5deb2ae4347b3a81c3fa12b0b8c976544829396a4"
],
"version": "==5.1.2"
"version": "==5.2"
},
"recommonmark": {
"hashes": [

Просмотреть файл

@ -234,7 +234,7 @@ class Documentation(MachCommandBase):
except subprocess.CalledProcessError:
version = None
if not version or not version.startswith('3.5'):
if not version or not version.startswith(b'3.5'):
return 1

Просмотреть файл

@ -122,12 +122,12 @@ class _SphinxManager(object):
If this is the case, we read the information, create a temporary file,
reuse the front matter info into the md file
"""
with open(markdown_file) as f:
with open(markdown_file, "r") as f:
# Load the front matter header
post = frontmatter.load(f)
if len(post.keys()) > 0:
# Has a front matter, use it
with tempfile.NamedTemporaryFile(delete=False) as fh:
with tempfile.NamedTemporaryFile("w", delete=False) as fh:
# Use the frontmatter title
fh.write(post["title"] + "\n")
# Add the md syntax for the title
@ -169,7 +169,7 @@ class _SphinxManager(object):
m.populate_registry(copier)
copier.copy(self.staging_dir, remove_empty_directories=False)
with open(self.index_path, 'rb') as fh:
with open(self.index_path, 'r') as fh:
data = fh.read()
def is_toplevel(key):
@ -207,7 +207,7 @@ class _SphinxManager(object):
data = data.format(**CATEGORIES)
with open(os.path.join(self.staging_dir, 'index.rst'), 'wb') as fh:
with open(os.path.join(self.staging_dir, 'index.rst'), 'w') as fh:
fh.write(data)