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
33987212
Commit
33987212
authored
Jul 08, 2018
by
Michael Davidsaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable DSOs w/o extensions
bdist_egg is a huge ugly hack!
parent
25e42bb7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
2 deletions
+51
-2
src/setuptools_dso/__init__.py
src/setuptools_dso/__init__.py
+5
-1
src/setuptools_dso/dsocmd.py
src/setuptools_dso/dsocmd.py
+46
-1
No files found.
src/setuptools_dso/__init__.py
View file @
33987212
from
setuptools
import
setup
as
_setup
from
.dsocmd
import
DSO
,
Extension
,
build_dso
,
build_ext
from
.dsocmd
import
DSO
,
Extension
,
build_dso
,
build_ext
,
egg_info
from
setuptools.command.install
import
install
__all__
=
(
'DSO'
,
'Extension'
,
'build_dso'
,
'build_ext'
,
'egg_info'
,
'setup'
,
)
def
setup
(
**
kws
):
cmdclass
=
kws
.
get
(
'cmdclass'
,
{})
cmdclass
[
'egg_info'
]
=
egg_info
cmdclass
[
'build_dso'
]
=
build_dso
cmdclass
[
'build_ext'
]
=
build_ext
kws
[
'cmdclass'
]
=
cmdclass
...
...
src/setuptools_dso/dsocmd.py
View file @
33987212
...
...
@@ -8,6 +8,9 @@ from importlib import import_module # say that three times fast...
from
setuptools
import
Command
,
Distribution
,
Extension
as
_Extension
from
setuptools.command.build_ext
import
build_ext
as
_build_ext
from
setuptools.command.install
import
install
from
setuptools.command.egg_info
import
egg_info
as
_egg_info
from
distutils.command.build
import
build
from
distutils.sysconfig
import
customize_compiler
from
distutils.dep_util
import
newer_group
...
...
@@ -133,6 +136,10 @@ class build_dso(dso2libmixin, Command):
boolean_options
=
[
'inplace'
,
'force'
]
# eg. allow injection of extra work (eg. code generation)
# before DSOs are built
sub_commands
=
[]
def
initialize_options
(
self
):
self
.
dsos
=
None
...
...
@@ -154,6 +161,9 @@ class build_dso(dso2libmixin, Command):
self
.
dsos
=
self
.
distribution
.
x_dsos
def
run
(
self
):
for
cmd_name
in
self
.
get_sub_commands
():
self
.
run_command
(
cmd_name
)
if
self
.
dsos
is
None
:
log
.
debug
(
"No DSOs to build"
)
return
...
...
@@ -296,7 +306,6 @@ class build_ext(dso2libmixin, _build_ext):
self
.
library_dirs
=
massage_dir_list
(
self
.
build_lib
,
self
.
library_dirs
or
[])
def
run
(
self
):
self
.
run_command
(
'build_dso'
)
# the Darwin linker errors if given non-existant directories :(
[
self
.
mkpath
(
D
)
for
D
in
self
.
library_dirs
]
_build_ext
.
run
(
self
)
...
...
@@ -315,3 +324,39 @@ class build_ext(dso2libmixin, _build_ext):
_build_ext
.
build_extension
(
self
,
ext
)
self
.
dso2lib_post
(
ext
)
# Rant:
# Arranging for 'build_dso' to be run is seriously annoying!
#
# distutils presents such a simple idea. We just add 'build_dso' to build.sub_commands.
# 'install' will first run 'build', and we're done.
#
# Enter setuptools... setuptools decides to automagically alias 'install' as 'bdist_egg'.
# Seriously 'magic', it's inspecting the strack frames...
#
# 'bdist_egg' is a special little snowflake (aka. total hack) which doesn't run 'build'
# or 'install' (fuck!), but does it's own thing by piecemeal calling
# eg. 'egg_info', 'build_clib' (conditionally), 'install_lib'.
#
# 'bdist_wheel' is better behaved, and actually runs 'build'.
#
# so what to do...
#
# 1. insert 'build_dso' before 'build_clib' in the 'build' sequence.
# This handles everything except 'bdist_egg' (aka. 'setup.py install')...
#
# 2. override 'egg_info' to run 'build_dso' afterwards.
def
has_dsos
(
cmd
):
return
len
(
getattr
(
cmd
.
distribution
,
'x_dsos'
,
[]))
>
0
class
egg_info
(
_egg_info
):
def
run
(
self
):
_egg_info
.
run
(
self
)
if
has_dsos
(
self
):
self
.
run_command
(
'build_dso'
)
for
i
,(
name
,
_test
)
in
enumerate
(
build
.
sub_commands
):
if
name
==
'build_clib'
:
build
.
sub_commands
.
insert
(
i
,
(
'build_dso'
,
has_dsos
))
break
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