Skip to content

Fix setup.py detail headers and add pip install tests to Travis #1026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ matrix:
# Documentation build:
- os: linux
language: docs
env: DOCS STYLE LINT
env: DOCS STYLE LINT PIP
cache: false
install:
- export PATH="~/.local/bin:$PATH"
- $PY_CMD -m pip install --user --upgrade sphinx sphinx_rtd_theme breathe flake8 pep8-naming
Expand All @@ -76,6 +77,12 @@ matrix:
- $PY_CMD -m sphinx -W -b html docs docs/.build
- tools/check-style.sh
- flake8
- |
# Make sure setup.py distributes and installs all the headers
$PY_CMD setup.py sdist
$PY_CMD -m pip install --user -U ./dist/*
installed=$($PY_CMD -c "import pybind11; print(pybind11.get_include(True) + '/pybind11')")
diff -rq $installed ./include/pybind11
cache:
directories:
- $HOME/.local/bin
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include include/pybind11/*.h
recursive-include include/pybind11 *.h
include LICENSE README.md CONTRIBUTING.md
18 changes: 12 additions & 6 deletions pybind11/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@


def print_includes():
dirs = [sysconfig.get_path('include')]
if sysconfig.get_path('platinclude') not in dirs:
dirs.append(sysconfig.get_path('platinclude'))
if get_include() not in dirs:
dirs.append(get_include())
print(' '.join('-I' + d for d in dirs))
dirs = [sysconfig.get_path('include'),
sysconfig.get_path('platinclude'),
get_include(),
get_include(True)]

# Make unique but preserve order
unique_dirs = []
for d in dirs:
if d not in unique_dirs:
unique_dirs.append(d)

print(' '.join('-I' + d for d in unique_dirs))


def main():
Expand Down
20 changes: 19 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Setup script for PyPI; use CMakeFile.txt to build extension modules

from setuptools import setup
from distutils.command.install_headers import install_headers
from pybind11 import __version__
import os

Expand All @@ -17,7 +18,7 @@
'include/pybind11/detail/descr.h',
'include/pybind11/detail/init.h',
'include/pybind11/detail/internals.h',
'include/pybind11/detail/typeid.h'
'include/pybind11/detail/typeid.h',
'include/pybind11/attr.h',
'include/pybind11/buffer_info.h',
'include/pybind11/cast.h',
Expand All @@ -36,6 +37,22 @@
'include/pybind11/stl_bind.h',
]


class InstallHeaders(install_headers):
"""Use custom header installer because the default one flattens subdirectories"""
def run(self):
if not self.distribution.headers:
return

for header in self.distribution.headers:
subdir = os.path.dirname(os.path.relpath(header, 'include/pybind11'))
install_dir = os.path.join(self.install_dir, subdir)
self.mkpath(install_dir)

(out, _) = self.copy_file(header, install_dir)
self.outfiles.append(out)


setup(
name='pybind11',
version=__version__,
Expand All @@ -47,6 +64,7 @@
packages=['pybind11'],
license='BSD',
headers=headers,
cmdclass=dict(install_headers=InstallHeaders),
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
Expand Down