Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
37352491
Commit
37352491
authored
Nov 28, 2019
by
Isuru Fernando
Committed by
Wenzel Jakob
Nov 28, 2019
Browse files
Install headers using both headers and package_data (#1995)
parent
a6064822
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
59 deletions
+48
-59
pybind11/__init__.py
pybind11/__init__.py
+6
-30
pybind11/__main__.py
pybind11/__main__.py
+1
-2
setup.py
setup.py
+41
-27
No files found.
pybind11/__init__.py
View file @
37352491
...
@@ -2,35 +2,11 @@ from ._version import version_info, __version__ # noqa: F401 imported but unuse
...
@@ -2,35 +2,11 @@ from ._version import version_info, __version__ # noqa: F401 imported but unuse
def
get_include
(
user
=
False
):
def
get_include
(
user
=
False
):
from
distutils.dist
import
Distribution
import
os
import
os
import
sys
d
=
os
.
path
.
dirname
(
__file__
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
d
,
"include"
)):
# Are we running in a virtual environment?
# Package is installed
virtualenv
=
hasattr
(
sys
,
'real_prefix'
)
or
\
return
os
.
path
.
join
(
d
,
"include"
)
sys
.
prefix
!=
getattr
(
sys
,
"base_prefix"
,
sys
.
prefix
)
# Are we running in a conda environment?
conda
=
os
.
path
.
exists
(
os
.
path
.
join
(
sys
.
prefix
,
'conda-meta'
))
if
virtualenv
:
return
os
.
path
.
join
(
sys
.
prefix
,
'include'
,
'site'
,
'python'
+
sys
.
version
[:
3
])
elif
conda
:
if
os
.
name
==
'nt'
:
return
os
.
path
.
join
(
sys
.
prefix
,
'Library'
,
'include'
)
else
:
return
os
.
path
.
join
(
sys
.
prefix
,
'include'
)
else
:
else
:
dist
=
Distribution
({
'name'
:
'pybind11'
})
# Package is from a source directory
dist
.
parse_config_files
()
return
os
.
path
.
join
(
os
.
path
.
dirname
(
d
),
"include"
)
dist_cobj
=
dist
.
get_command_obj
(
'install'
,
create
=
True
)
# Search for packages in user's home directory?
if
user
:
dist_cobj
.
user
=
user
dist_cobj
.
prefix
=
""
dist_cobj
.
finalize_options
()
return
os
.
path
.
dirname
(
dist_cobj
.
install_headers
)
pybind11/__main__.py
View file @
37352491
...
@@ -10,8 +10,7 @@ from . import get_include
...
@@ -10,8 +10,7 @@ from . import get_include
def
print_includes
():
def
print_includes
():
dirs
=
[
sysconfig
.
get_path
(
'include'
),
dirs
=
[
sysconfig
.
get_path
(
'include'
),
sysconfig
.
get_path
(
'platinclude'
),
sysconfig
.
get_path
(
'platinclude'
),
get_include
(),
get_include
()]
get_include
(
True
)]
# Make unique but preserve order
# Make unique but preserve order
unique_dirs
=
[]
unique_dirs
=
[]
...
...
setup.py
View file @
37352491
...
@@ -4,40 +4,43 @@
...
@@ -4,40 +4,43 @@
from
setuptools
import
setup
from
setuptools
import
setup
from
distutils.command.install_headers
import
install_headers
from
distutils.command.install_headers
import
install_headers
from
distutils.command.build_py
import
build_py
from
pybind11
import
__version__
from
pybind11
import
__version__
import
os
import
os
package_data
=
[
'include/pybind11/detail/class.h'
,
'include/pybind11/detail/common.h'
,
'include/pybind11/detail/descr.h'
,
'include/pybind11/detail/init.h'
,
'include/pybind11/detail/internals.h'
,
'include/pybind11/detail/typeid.h'
,
'include/pybind11/attr.h'
,
'include/pybind11/buffer_info.h'
,
'include/pybind11/cast.h'
,
'include/pybind11/chrono.h'
,
'include/pybind11/common.h'
,
'include/pybind11/complex.h'
,
'include/pybind11/eigen.h'
,
'include/pybind11/embed.h'
,
'include/pybind11/eval.h'
,
'include/pybind11/functional.h'
,
'include/pybind11/iostream.h'
,
'include/pybind11/numpy.h'
,
'include/pybind11/operators.h'
,
'include/pybind11/options.h'
,
'include/pybind11/pybind11.h'
,
'include/pybind11/pytypes.h'
,
'include/pybind11/stl.h'
,
'include/pybind11/stl_bind.h'
,
]
# Prevent installation of pybind11 headers by setting
# Prevent installation of pybind11 headers by setting
# PYBIND11_USE_CMAKE.
# PYBIND11_USE_CMAKE.
if
os
.
environ
.
get
(
'PYBIND11_USE_CMAKE'
):
if
os
.
environ
.
get
(
'PYBIND11_USE_CMAKE'
):
headers
=
[]
headers
=
[]
else
:
else
:
headers
=
[
headers
=
package_data
'include/pybind11/detail/class.h'
,
'include/pybind11/detail/common.h'
,
'include/pybind11/detail/descr.h'
,
'include/pybind11/detail/init.h'
,
'include/pybind11/detail/internals.h'
,
'include/pybind11/detail/typeid.h'
,
'include/pybind11/attr.h'
,
'include/pybind11/buffer_info.h'
,
'include/pybind11/cast.h'
,
'include/pybind11/chrono.h'
,
'include/pybind11/common.h'
,
'include/pybind11/complex.h'
,
'include/pybind11/eigen.h'
,
'include/pybind11/embed.h'
,
'include/pybind11/eval.h'
,
'include/pybind11/functional.h'
,
'include/pybind11/iostream.h'
,
'include/pybind11/numpy.h'
,
'include/pybind11/operators.h'
,
'include/pybind11/options.h'
,
'include/pybind11/pybind11.h'
,
'include/pybind11/pytypes.h'
,
'include/pybind11/stl.h'
,
'include/pybind11/stl_bind.h'
,
]
class
InstallHeaders
(
install_headers
):
class
InstallHeaders
(
install_headers
):
...
@@ -55,6 +58,16 @@ class InstallHeaders(install_headers):
...
@@ -55,6 +58,16 @@ class InstallHeaders(install_headers):
self
.
outfiles
.
append
(
out
)
self
.
outfiles
.
append
(
out
)
# Install the headers inside the package as well
class
BuildPy
(
build_py
):
def
build_package_data
(
self
):
build_py
.
build_package_data
(
self
)
for
header
in
package_data
:
target
=
os
.
path
.
join
(
self
.
build_lib
,
'pybind11'
,
header
)
self
.
mkpath
(
os
.
path
.
dirname
(
target
))
self
.
copy_file
(
header
,
target
,
preserve_mode
=
False
)
setup
(
setup
(
name
=
'pybind11'
,
name
=
'pybind11'
,
version
=
__version__
,
version
=
__version__
,
...
@@ -66,7 +79,8 @@ setup(
...
@@ -66,7 +79,8 @@ setup(
packages
=
[
'pybind11'
],
packages
=
[
'pybind11'
],
license
=
'BSD'
,
license
=
'BSD'
,
headers
=
headers
,
headers
=
headers
,
cmdclass
=
dict
(
install_headers
=
InstallHeaders
),
zip_safe
=
False
,
cmdclass
=
dict
(
install_headers
=
InstallHeaders
,
build_py
=
BuildPy
),
classifiers
=
[
classifiers
=
[
'Development Status :: 5 - Production/Stable'
,
'Development Status :: 5 - Production/Stable'
,
'Intended Audience :: Developers'
,
'Intended Audience :: Developers'
,
...
...
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