public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: <libc-alpha@sourceware.org>
Subject: Re: Add script to build many glibc configurations
Date: Mon, 14 Nov 2016 23:57:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.20.1611142349250.32454@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20161114150603.GT21655@vapier.lan>

On Mon, 14 Nov 2016, Mike Frysinger wrote:

> On 11 Nov 2016 15:20, Joseph Myers wrote:
> > +import os.path
> 
> this import is unnecessary

Removed in this patch.

> > +class Context:
> 
> please no old style classes.  all of them should inherit object.
> 	class Context(object):

Changed in this patch, though I've only ever seen this mentioned as a 
Python 2 compatibility issue not as something relevant to Python 3 code 
(otherwise I'd have expected Python 3 to remove the option not to specify 
a class to inherit from).

> > +    """The global state associated with builds in a given directory."""
> 
> don't put a blank line between the class and its docstring.

Changed in this patch.

> > +        os.chmod(self.wrapper,
> > +                 (stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|
> > +                  stat.S_IROTH|stat.S_IXOTH))
> 
> the stat constants are unreadable imo.  better to never use them and
> stick to sane octals like 0644 and such.

This patch puts the mode in a variable with a comment giving the 0o755 
value (being Python 3, 0o is the notation for octal constants).  While I 
agree on the unreadability, hardcoding such values rather than using the 
provided os interface seems inappropriate in Python code (in the absence 
of Python defining the conventional values of those constants as being an 
OS-independent interface).

Committed.

2016-11-14  Joseph Myers  <joseph@codesourcery.com>

	* scripts/build-many-glibcs.py (os.path): Do not import.
	(Context): Inherit explicitly from object.  Remove blank line
	between class and docstring.
	(Config): Likewise.
	(Glibc): Likewise.
	(Command): Likewise.
	(CommandList): Likewise.
	(Context.write_files): Store chmod mode in a variable.

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 4b4e15c..be561c3 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -33,7 +33,6 @@ configurations for which compilers or glibc are to be built.
 
 import argparse
 import os
-import os.path
 import re
 import shutil
 import stat
@@ -42,8 +41,7 @@ import sys
 import urllib.request
 
 
-class Context:
-
+class Context(object):
     """The global state associated with builds in a given directory."""
 
     def __init__(self, topdir, parallelism, keep, action):
@@ -460,9 +458,10 @@ class Context:
             'record_status PASS\n')
         with open(self.wrapper, 'w') as f:
             f.write(wrapper_text)
-        os.chmod(self.wrapper,
-                 (stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|
-                  stat.S_IROTH|stat.S_IXOTH))
+        # Mode 0o755.
+        mode_exec = (stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|
+                     stat.S_IROTH|stat.S_IXOTH)
+        os.chmod(self.wrapper, mode_exec)
         save_logs_text = (
             '#!/bin/sh\n'
             'if ! [ -f tests.sum ]; then\n'
@@ -487,9 +486,7 @@ class Context:
             'done\n')
         with open(self.save_logs, 'w') as f:
             f.write(save_logs_text)
-        os.chmod(self.save_logs,
-                 (stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|
-                  stat.S_IROTH|stat.S_IXOTH))
+        os.chmod(self.save_logs, mode_exec)
 
     def do_build(self):
         """Do the actual build."""
@@ -678,8 +675,7 @@ class Context:
         os.remove(filename)
 
 
-class Config:
-
+class Config(object):
     """A configuration for building a compiler and associated libraries."""
 
     def __init__(self, ctx, arch, os_name, variant=None, gcc_cfg=None,
@@ -846,8 +842,7 @@ class Config:
         self.build_cross_tool(cmdlist, 'gcc', tool_build, cfg_opts)
 
 
-class Glibc:
-
+class Glibc(object):
     """A configuration for building glibc."""
 
     def __init__(self, compiler, arch=None, os_name=None, variant=None,
@@ -958,8 +953,7 @@ class Glibc:
         cmdlist.cleanup_dir()
 
 
-class Command:
-
+class Command(object):
     """A command run in the build process."""
 
     def __init__(self, desc, num, dir, path, command, always_run=False):
@@ -999,8 +993,7 @@ class Command:
         return self.shell_make_quote_list(self.command, True)
 
 
-class CommandList:
-
+class CommandList(object):
     """A list of commands run in the build process."""
 
     def __init__(self, desc, keep):

-- 
Joseph S. Myers
joseph@codesourcery.com

  parent reply	other threads:[~2016-11-14 23:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09 16:27 Joseph Myers
2016-11-10 14:27 ` Joseph Myers
2016-11-10 16:44   ` Joseph Myers
2016-11-23 17:36   ` Chris Metcalf
2016-11-10 17:09 ` Steve Ellcey
2016-11-10 17:22   ` Joseph Myers
2016-11-10 17:39     ` Steve Ellcey
2016-11-11 15:20 ` Joseph Myers
2016-11-11 19:37   ` Carlos O'Donell
2016-11-14 15:06   ` Mike Frysinger
2016-11-14 15:23     ` Joseph Myers
2016-11-14 19:27       ` Mike Frysinger
2016-11-14 23:28         ` Joseph Myers
2016-11-14 23:57     ` Joseph Myers [this message]
2016-11-17 16:52 ` Zack Weinberg
2016-11-17 17:26   ` Zack Weinberg
2016-11-17 17:47     ` Joseph Myers
2016-11-17 17:54     ` Andreas Schwab
2016-11-17 17:51   ` Joseph Myers
2016-11-18 16:28     ` Zack Weinberg
2016-11-18 18:27       ` Joseph Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1611142349250.32454@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).