Mercurial > p > roundup > code
annotate roundup/dist/command/bdist_rpm.py @ 7812:ecc34b7917e2
chore(refactor): multiple changes/cleanups
Simplify 'for x in [list val]; alist.append(x)' to 'alist = list([list
val])'. Easier to read as copy of list. Also twice as fast although
speed not an issue.
Remove unneeded list() wrappers. Replace set(list comprehension) with
set comprehension.
Also add trailing ,'s to last element in tuples/lists.
Add some noqa items for acceptable operations in context.
Switch " ... \" ...\" ..." to: ' ... " ... " ...' to remove need to
escape internal '"'.
Change 'not x in y' to 'x not in y'.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 16 Mar 2024 21:08:16 -0400 |
| parents | 551fec9c4cfc |
| children |
| rev | line source |
|---|---|
| 4068 | 1 # |
| 2 # Copyright (C) 2009 Stefan Seefeld | |
| 3 # All rights reserved. | |
| 4 # For license terms see the file COPYING.txt. | |
| 5 # | |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
6 # converted to not use distutils 2021 |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
7 from setuptools.command.bdist_rpm import bdist_rpm as base |
| 4068 | 8 import os |
| 9 | |
| 6907 | 10 |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
11 # cribbed from 2.7 distutils |
| 6907 | 12 def write_file(filename, contents): |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
13 """Create a file with the specified name and write 'contents' (a |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
14 sequence of strings without line terminators) to it. |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
15 """ |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
16 f = open(filename, "w") |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
17 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
18 for line in contents: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
19 f.write(line + "\n") |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
20 finally: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
21 f.close() |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
4068
diff
changeset
|
22 |
| 6907 | 23 |
| 4068 | 24 class bdist_rpm(base): |
| 25 | |
| 26 def finalize_options(self): | |
| 27 base.finalize_options(self) | |
| 28 if self.install_script: | |
| 29 # install script is overridden. skip default | |
| 30 return | |
| 31 # install script option must be file name. | |
| 32 # create the file in rpm build directory. | |
| 33 install_script = os.path.join(self.rpm_base, "install.sh") | |
| 34 self.mkpath(self.rpm_base) | |
| 35 self.execute(write_file, (install_script, [ | |
| 36 ("%s setup.py install --root=$RPM_BUILD_ROOT " | |
| 37 "--record=ROUNDUP_FILES") % self.python, | |
| 38 # allow any additional extension for man pages | |
| 39 # (rpm may compress them to .gz or .bz2) | |
| 40 # man page here is any file | |
| 41 # with single-character extension | |
| 42 # in man directory | |
| 6907 | 43 r"sed -e 's,\(/man/.*\..\)$,\\1*,' " |
| 44 "<ROUNDUP_FILES >INSTALLED_FILES", | |
| 4068 | 45 ]), "writing '%s'" % install_script) |
| 46 self.install_script = install_script |
