1
# Copyright 2012, Kay Hayen, mailto:kayhayen@gmx.de
3
# Part of "Nuitka", an optimizing Python compiler that is compatible and
4
# integrates with CPython, but also works on its own.
6
# If you submit patches or make the software available to licensors of
7
# this software in either form, you automatically them grant them a
8
# license for your part of the code under "Apache License 2.0" unless you
9
# choose to remove this notice.
11
# Kay Hayen uses the right to license his code under only GPL version 3,
12
# to discourage a fork of Nuitka before it is "finished". He will later
13
# make a new "Nuitka" release fully under "Apache License 2.0".
15
# This program is free software: you can redistribute it and/or modify
16
# it under the terms of the GNU General Public License as published by
17
# the Free Software Foundation, version 3 of the License.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program. If not, see <http://www.gnu.org/licenses/>.
27
# Please leave the whole of this copyright notice intact.
31
Here the small things for file/dir names, Python version, CPU counting, etc. that
32
fit nowhere else and don't deserve their own names.
38
def getPythonVersion():
39
big, major, minor = sys.version_info[0:3]
41
return big * 100 + major * 10 + minor
44
return os.path.relpath( path )
47
return os.path.abspath( path )
49
def joinpath( *parts ):
50
return os.path.join( *parts )
53
return os.path.basename( path )
56
return os.path.dirname( path )
58
def getExtension( path ):
59
return os.path.splitext( path )[1]
62
return os.path.isfile( path )
65
return os.path.isdir( path )
70
# Try to sum up the CPU cores, if the kernel shows them, pylint: disable=W0702
72
# Try to get the number of logical processors
73
cpu_count = open( "/proc/cpuinfo" ).read().count( "processor\t:" )
78
# false alarm, no re-import, just a function level import to avoid it unless it is
79
# absolutely necessary, pylint: disable=W0404
81
import multiprocessing
82
cpu_count = multiprocessing.cpu_count()