9
9
import subprocess
10
10
import shutil
11
11
12
+ import distutils
12
13
from distutils .errors import DistutilsError
13
14
14
15
try :
@@ -583,6 +584,35 @@ def get_lib_source_files(lib):
583
584
filenames .append (d )
584
585
return filenames
585
586
587
+ def get_shared_lib_extension (is_python_ext = False ):
588
+ """Return the correct file extension for shared libraries.
589
+
590
+ Parameters
591
+ ----------
592
+ is_python_ext : bool, optional
593
+ Whether the shared library is a Python extension. Default is False.
594
+
595
+ Returns
596
+ -------
597
+ so_ext : str
598
+ The shared library extension.
599
+
600
+ Notes
601
+ -----
602
+ For Python shared libs, `so_ext` will typically be '.so' on Linux and OS X,
603
+ and '.pyd' on Windows. For Python >= 3.2 `so_ext` has a tag prepended on
604
+ POSIX systems according to PEP 3149. For Python 3.2 this is implemented on
605
+ Linux, but not on OS X.
606
+
607
+ """
608
+ so_ext = distutils .sysconfig .get_config_var ('SO' ) or ''
609
+ # fix long extension for Python >=3.2, see PEP 3149.
610
+ if (not is_python_ext ) and 'SOABI' in distutils .sysconfig .get_config_vars ():
611
+ # Does nothing unless SOABI config var exists
612
+ so_ext = so_ext .replace ('.' + distutils .sysconfig .get_config_var ('SOABI' ), '' , 1 )
613
+
614
+ return so_ext
615
+
586
616
def get_data_files (data ):
587
617
if is_string (data ):
588
618
return [data ]
@@ -772,7 +802,7 @@ def __init__(self,
772
802
def todict (self ):
773
803
"""
774
804
Return a dictionary compatible with the keyword arguments of distutils
775
- setup function.
805
+ setup function.
776
806
777
807
Examples
778
808
--------
@@ -947,8 +977,8 @@ def get_subpackage(self,subpackage_name,
947
977
def add_subpackage (self ,subpackage_name ,
948
978
subpackage_path = None ,
949
979
standalone = False ):
950
- """Add a sub-package to the current Configuration instance.
951
-
980
+ """Add a sub-package to the current Configuration instance.
981
+
952
982
This is useful in a setup.py script for adding sub-packages to a
953
983
package.
954
984
@@ -994,7 +1024,7 @@ def add_data_dir(self,data_path):
994
1024
installed (and distributed). The data_path can be either a relative
995
1025
path-name, or an absolute path-name, or a 2-tuple where the first
996
1026
argument shows where in the install directory the data directory
997
- should be installed to.
1027
+ should be installed to.
998
1028
999
1029
Parameters
1000
1030
----------
@@ -1389,7 +1419,7 @@ def add_extension(self,name,sources,**kw):
1389
1419
Notes
1390
1420
-----
1391
1421
The self.paths(...) method is applied to all lists that may contain
1392
- paths.
1422
+ paths.
1393
1423
"""
1394
1424
ext_args = copy .copy (kw )
1395
1425
ext_args ['name' ] = dot_join (self .name ,name )
@@ -1863,7 +1893,7 @@ def _get_hg_revision(self,path):
1863
1893
return revision
1864
1894
branch_fn = njoin (path ,'.hg' ,'branch' )
1865
1895
branch_cache_fn = njoin (path ,'.hg' ,'branch.cache' )
1866
-
1896
+
1867
1897
if os .path .isfile (branch_fn ):
1868
1898
branch0 = None
1869
1899
f = open (branch_fn )
@@ -1889,8 +1919,8 @@ def get_version(self, version_file=None, version_variable=None):
1889
1919
"""Try to get version string of a package.
1890
1920
1891
1921
Return a version string of the current package or None if the version
1892
- information could not be detected.
1893
-
1922
+ information could not be detected.
1923
+
1894
1924
Notes
1895
1925
-----
1896
1926
This method scans files named
@@ -1956,8 +1986,8 @@ def get_version(self, version_file=None, version_variable=None):
1956
1986
1957
1987
def make_svn_version_py (self , delete = True ):
1958
1988
"""Appends a data function to the data_files list that will generate
1959
- __svn_version__.py file to the current package directory.
1960
-
1989
+ __svn_version__.py file to the current package directory.
1990
+
1961
1991
Generate package __svn_version__.py file from SVN revision number,
1962
1992
it will be removed after python exits but will be available
1963
1993
when sdist, etc commands are executed.
@@ -1999,8 +2029,8 @@ def rm_file(f=target,p=self.info):
1999
2029
2000
2030
def make_hg_version_py (self , delete = True ):
2001
2031
"""Appends a data function to the data_files list that will generate
2002
- __hg_version__.py file to the current package directory.
2003
-
2032
+ __hg_version__.py file to the current package directory.
2033
+
2004
2034
Generate package __hg_version__.py file from Mercurial revision,
2005
2035
it will be removed after python exits but will be available
2006
2036
when sdist, etc commands are executed.
0 commit comments