@ -4,19 +4,16 @@
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html
import os
import os . path as op
from pathlib import Path
import sys
from optparse import OptionParser
import shutil
from setuptools import setup , Extension
from setuptools import sandbox
from hscommon import sphinxgen
from hscommon . build import (
add_to_pythonpath ,
print_and_do ,
move_all ,
fix_qt_resource_file ,
)
from hscommon import loc
@ -63,14 +60,14 @@ def parse_args():
def build_help ( ) :
print ( " Generating Help " )
current_path = op. absp ath( " . " )
help_basepath = op. join ( current_path , " help " , " en " )
help_destpath = op. join ( current_path , " build " , " help " )
changelog_path = op. join ( current_path , " help " , " changelog " )
current_path = P ath( " . " ) . absolute ( )
help_basepath = current_path. joinpath ( " help " , " en " )
help_destpath = current_path. joinpath ( " build " , " help " )
changelog_path = current_path. joinpath ( " help " , " changelog " )
tixurl = " https://github.com/arsenetar/dupeguru/issues/ {} "
confrepl = { " language " : " en " }
changelogtmpl = op. join ( current_path , " help " , " changelog.tmpl " )
conftmpl = op. join ( current_path , " help " , " conf.tmpl " )
changelogtmpl = current_path. joinpath ( " help " , " changelog.tmpl " )
conftmpl = current_path. joinpath ( " help " , " conf.tmpl " )
sphinxgen . gen (
help_basepath ,
help_destpath ,
@ -83,15 +80,15 @@ def build_help():
def build_qt_localizations ( ) :
loc . compile_all_po ( op. join ( " qtlib " , " locale " ) )
loc . merge_locale_dir ( op. join ( " qtlib " , " locale " ) , " locale " )
loc . compile_all_po ( Path ( " qtlib " , " locale " ) )
loc . merge_locale_dir ( Path ( " qtlib " , " locale " ) , " locale " )
def build_localizations ( ) :
loc . compile_all_po ( " locale " )
build_qt_localizations ( )
locale_dest = op. join ( " build " , " locale " )
if op. exists ( locale_dest ) :
locale_dest = Path ( " build " , " locale " )
if locale_dest. exists ( ) :
shutil . rmtree ( locale_dest )
shutil . copytree ( " locale " , locale_dest , ignore = shutil . ignore_patterns ( " *.po " , " *.pot " ) )
@ -99,57 +96,35 @@ def build_localizations():
def build_updatepot ( ) :
print ( " Building .pot files from source files " )
print ( " Building core.pot " )
loc . generate_pot ( [ " core " ] , op. join ( " locale " , " core.pot " ) , [ " tr " ] )
loc . generate_pot ( [ " core " ] , Path ( " locale " , " core.pot " ) , [ " tr " ] )
print ( " Building columns.pot " )
loc . generate_pot ( [ " core " ] , op. join ( " locale " , " columns.pot " ) , [ " coltr " ] )
loc . generate_pot ( [ " core " ] , Path ( " locale " , " columns.pot " ) , [ " coltr " ] )
print ( " Building ui.pot " )
# When we're not under OS X, we don't want to overwrite ui.pot because it contains Cocoa locs
# We want to merge the generated pot with the old pot in the most preserving way possible.
ui_packages = [ " qt " , op. join ( " cocoa " , " inter " ) ]
loc . generate_pot ( ui_packages , op. join ( " locale " , " ui.pot " ) , [ " tr " ] , merge = True )
ui_packages = [ " qt " , Path ( " cocoa " , " inter " ) ]
loc . generate_pot ( ui_packages , Path ( " locale " , " ui.pot " ) , [ " tr " ] , merge = True )
print ( " Building qtlib.pot " )
loc . generate_pot ( [ " qtlib " ] , op. join ( " qtlib " , " locale " , " qtlib.pot " ) , [ " tr " ] )
loc . generate_pot ( [ " qtlib " ] , Path ( " qtlib " , " locale " , " qtlib.pot " ) , [ " tr " ] )
def build_mergepot ( ) :
print ( " Updating .po files using .pot files " )
loc . merge_pots_into_pos ( " locale " )
loc . merge_pots_into_pos ( op. join ( " qtlib " , " locale " ) )
# loc.merge_pots_into_pos( op.join ("cocoalib", "locale"))
loc . merge_pots_into_pos ( Path ( " qtlib " , " locale " ) )
# loc.merge_pots_into_pos( Path ("cocoalib", "locale"))
def build_normpo ( ) :
loc . normalize_all_pos ( " locale " )
loc . normalize_all_pos ( op. join ( " qtlib " , " locale " ) )
# loc.normalize_all_pos( op.join ("cocoalib", "locale"))
loc . normalize_all_pos ( Path ( " qtlib " , " locale " ) )
# loc.normalize_all_pos( Path ("cocoalib", "locale"))
def build_pe_modules ( ) :
print ( " Building PE Modules " )
exts = [
Extension (
" _block " ,
[
op . join ( " core " , " pe " , " modules " , " block.c " ) ,
op . join ( " core " , " pe " , " modules " , " common.c " ) ,
] ,
) ,
Extension (
" _cache " ,
[
op . join ( " core " , " pe " , " modules " , " cache.c " ) ,
op . join ( " core " , " pe " , " modules " , " common.c " ) ,
] ,
) ,
]
exts . append ( Extension ( " _block_qt " , [ op . join ( " qt " , " pe " , " modules " , " block.c " ) ] ) )
setup (
script_args = [ " build_ext " , " --inplace " ] ,
ext_modules = exts ,
)
move_all ( " _block_qt* " , op . join ( " qt " , " pe " ) )
move_all ( " _block* " , op . join ( " core " , " pe " ) )
move_all ( " _cache* " , op . join ( " core " , " pe " ) )
# Leverage setup.py to build modules
sandbox . run_setup ( " setup.py " , [ " build_ext " , " --inplace " ] )
def build_normal ( ) :
@ -160,8 +135,8 @@ def build_normal():
print ( " Building localizations " )
build_localizations ( )
print ( " Building Qt stuff " )
print_and_do ( " pyrcc5 {0} > {1} " . format ( op. join ( " qt " , " dg.qrc " ) , op. join ( " qt " , " dg_rc.py " ) ) )
fix_qt_resource_file ( op. join ( " qt " , " dg_rc.py " ) )
print_and_do ( " pyrcc5 {0} > {1} " . format ( Path ( " qt " , " dg.qrc " ) , Path ( " qt " , " dg_rc.py " ) ) )
fix_qt_resource_file ( Path ( " qt " , " dg_rc.py " ) )
build_help ( )
@ -169,10 +144,10 @@ def main():
if sys . version_info < ( 3 , 6 ) :
sys . exit ( " Python < 3.6 is unsupported. " )
options = parse_args ( )
if options . clean and op. exists ( " build " ) :
if options . clean and Path ( " build " ) . exists ( ) :
shutil . rmtree ( " build " )
if not op. exists ( " build " ) :
os. mkdir ( " build " )
if not Path ( " build " ) . exists ( ) :
Path ( " build " ) . mkdir ( )
if options . doc :
build_help ( )
elif options . loc :