Skip to content

Commit

Permalink
Include compiled extension files in setup.py --record
Browse files Browse the repository at this point in the history
Closes #91
  • Loading branch information
otsaloma committed May 27, 2018
1 parent 5c9d0a4 commit 2934997
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions TODO.md
@@ -0,0 +1,4 @@
Gaupol 1.4.1/1.5
================

* [x] Make 'setup.py --record' include compiled extensios as well (#91)
11 changes: 11 additions & 0 deletions setup.py
Expand Up @@ -33,6 +33,7 @@

import distutils
import glob
import importlib
import os
import re
import shutil
Expand Down Expand Up @@ -233,6 +234,16 @@ def __build_extensions(self):
data_dir = os.path.join(data_dir, "share", "gaupol")
files = glob.glob("{}/extensions/*/*.py".format(data_dir))
distutils.util.byte_compile(files, optimize, self.force, self.dry_run)
# Figure out paths of the compiled files and add them to
# self.outfiles so that 'setup.py --record' works correctly.
def get_cache_pattern(path):
dir, file = os.path.split(path)
file = os.path.splitext(file)[0] + ".*"
return os.path.join(dir, "__pycache__", file)
for pattern in map(get_cache_pattern, files):
for file in glob.glob(pattern):
if not file in self.outfiles:
self.outfiles.append(file)

def __generate_linguas(self):
"""Generate LINGUAS file needed by msgfmt."""
Expand Down

0 comments on commit 2934997

Please sign in to comment.