Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools_dso
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
setuptools_dso
Commits
ca30d337
Commit
ca30d337
authored
Jan 05, 2022
by
Michael Davidsaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrap new_compiler()
parent
7f41a51e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
4 deletions
+73
-4
src/setuptools_dso/compiler.py
src/setuptools_dso/compiler.py
+71
-0
src/setuptools_dso/dsocmd.py
src/setuptools_dso/dsocmd.py
+2
-4
No files found.
src/setuptools_dso/compiler.py
0 → 100644
View file @
ca30d337
import
os
from
functools
import
partial
from
distutils.ccompiler
import
(
new_compiler
as
_new_compiler
,
gen_preprocess_options
,
CCompiler
)
from
distutils.dep_util
import
newer
from
distutils.errors
import
DistutilsExecError
,
CompileError
from
distutils.sysconfig
import
customize_compiler
__all__
=
(
'new_compiler'
,
)
def
_default_preprocess
(
self
,
*
args
,
**
kws
):
"""preprocess() is documented to raise PreprocessError but the
default (circa py3.9) impl. is a no-op, and the 'unix' impl.
raises CompileError. Always a pleasure to find accurate
documentation...
"""
raise
CompileError
(
"preprocess() not implemented"
)
def
_msvc_preprocess
(
self
,
source
,
output_file
=
None
,
macros
=
None
,
include_dirs
=
None
,
extra_preargs
=
None
,
extra_postargs
=
None
):
"""Replacement for default (no-op) distutils.msvccompiler.MSVCCompiler.preprocess()
"""
# validate and normalize
ignore
,
macros
,
include_dirs
=
self
.
_fix_compile_args
(
None
,
macros
,
include_dirs
)
# translate macros/include_dirs into -D/-U/-I strings
pp_args
=
[
self
.
preprocessor
]
+
gen_preprocess_options
(
macros
,
include_dirs
)
# output to file or stdout
if
output_file
:
pp_args
.
extend
([
'/P'
,
'/Fi'
+
output_file
])
else
:
pp_args
.
extend
([
'/E'
])
if
extra_preargs
:
pp_args
[:
0
]
=
extra_preargs
if
extra_postargs
:
pp_args
.
extend
(
extra_postargs
)
pp_args
.
append
(
'/TP'
)
# treat as c++
pp_args
.
append
(
source
)
if
self
.
force
or
output_file
is
None
or
newer
(
source
,
output_file
):
if
output_file
:
self
.
mkpath
(
os
.
path
.
dirname
(
output_file
))
try
:
self
.
spawn
(
pp_args
)
except
DistutilsExecError
as
msg
:
raise
CompileError
(
msg
)
def
new_compiler
(
**
kws
):
"""Returns a instance of a sub-class of distutils.ccompiler.CCompiler
"""
compiler
=
_new_compiler
(
**
kws
)
customize_compiler
(
compiler
)
if
compiler
.
compiler_type
==
'msvc'
:
# either msvccompiler or msvc9compiler
if
not
compiler
.
initialized
:
# extra super lazy initialization...
compiler
.
initialize
()
# populates self.cc among others
if
compiler
.
__class__
.
preprocess
is
CCompiler
.
preprocess
:
# default impl. is a no-op...
compiler
.
preprocess
=
partial
(
_msvc_preprocess
,
compiler
)
if
getattr
(
compiler
,
'preprocessor'
,
None
)
is
None
:
compiler
.
preprocessor
=
compiler
.
cc
else
:
if
compiler
.
__class__
.
preprocess
is
CCompiler
.
preprocess
:
compiler
.
preprocess
=
_default_preprocess
return
compiler
src/setuptools_dso/dsocmd.py
View file @
ca30d337
...
...
@@ -16,11 +16,11 @@ from setuptools.command.build_ext import build_ext as _build_ext
from
setuptools.command.install
import
install
from
setuptools.command.bdist_egg
import
bdist_egg
as
_bdist_egg
from
distutils.sysconfig
import
customize_compiler
from
distutils.dep_util
import
newer_group
from
distutils.util
import
get_platform
from
distutils
import
log
from
.compiler
import
new_compiler
__all__
=
(
'DSO'
,
'Extension'
,
...
...
@@ -250,13 +250,11 @@ class build_dso(dso2libmixin, Command):
self.dsos = self.dsos(self)
log.info("Building DSOs")
from distutils.ccompiler import new_compiler
self.compiler = new_compiler(#compiler=self.compiler,
verbose=self.verbose,
dry_run=self.dry_run,
force=self.force)
customize_compiler(self.compiler)
# fixup for MAC to build dylib (MH_DYLIB) instead of bundle (MH_BUNDLE)
if sys.platform == '
darwin
':
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment