mirror of
https://github.com/ansible/awx.git
synced 2024-10-28 10:55:30 +03:00
Include byte-compiled pyc files in sdist tarball
Debian doesn't byte-compile .py files during the build process. Packagers are expected to byte-compile in the postinst [1]. The following change adds byte-compiled .pyc files into the sdist tarball. During RPM packaging, the rpm macros will regenerate/replace these files against the appropriate python version. [1] https://wiki.debian.org/Python/Packaging
This commit is contained in:
parent
aaaef7de71
commit
ff867df640
9
setup.py
9
setup.py
@ -79,8 +79,9 @@ class sdist_awx(_sdist, object):
|
||||
new_sources = file(new_sources_path, 'w')
|
||||
for line in file(sources_txt_path, 'r'):
|
||||
line = line.strip()
|
||||
# Include both .py and .pyc files to SOURCES.txt
|
||||
if line in self.pyc_only_files:
|
||||
line = line + 'c'
|
||||
line = line + '\n' + line + 'c'
|
||||
new_sources.write(line + '\n')
|
||||
|
||||
def make_distribution(self):
|
||||
@ -99,9 +100,13 @@ class sdist_awx(_sdist, object):
|
||||
continue
|
||||
if f.endswith('.py'):
|
||||
log.info('using pyc for: %s', f)
|
||||
# Byte compile to create .pyc file
|
||||
py_compile.compile(f, doraise=True)
|
||||
# Replace .py with .pyc file
|
||||
self.filelist.files[n] = f + 'c'
|
||||
self.pyc_only_files.append(f)
|
||||
# Add .py files back to the filelist
|
||||
self.filelist.files.extend(self.pyc_only_files)
|
||||
super(sdist_awx, self).make_distribution()
|
||||
|
||||
#####################################################################
|
||||
@ -206,7 +211,7 @@ setup(
|
||||
},
|
||||
},
|
||||
cmdclass = {
|
||||
'sdist_awx': _sdist,
|
||||
'sdist_awx': sdist_awx,
|
||||
'install_lib': install_lib,
|
||||
},
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user