-
Notifications
You must be signed in to change notification settings - Fork 148
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
Errors in build output of source distribution #16
Comments
Thank you for the detailed description. I will look into this. In any case, I think that it would be preferable to avoid distributing pybind11 as part of your source distribution, especially if your package exposes headers. Indeed, this may result in conflicts when another package includes both pybind11 and your headers.... Let's try to find a solution instead. This would also make packaging for other package managers (conda, apt-get) easier. |
Quick remark: If you also provide a wheel on pypi aside your sdist, this should fix the issue. |
Is there a branch of pyodbc11 that I can check out to reproduce? |
Hi! Providing a wheel is difficult at the moment because right now I am targetting Linux only, and manylinux builds plague me with a very old (and very buggy) odbc library. I would also prefer not to distribute pybind11 headers together with turbodbc. As for reproducing, checking out turbodbc is not necessary (and not easily possible given the still broken build on the branch), since the very same issue is present with this project, i.e., pybind11/python_example. |
The issue is also visible in the Travis logs for this repo. I guess this comes down to the fact that PyPI (unlike conda) does not differentiate between build-time and run-time requirements (related: pypa/pip#2381). The packages listed under
|
Hi all, |
I don't think it's clear how it could be fixed, the issue is potentially with PIP itself. Naturally you're free to investigate yourself and post a PR. |
There might be a means to fix this by overriding I have had to overload standard distutils commands in the context of jupyter. I will look at this. |
Adding
to |
@lukeolson how did you obtain the include path then? I'm asking because when dragging in pybind11 via setup_requries, it will not be properly installed, eg the headers will not be unpacked. The headers are contained in an temporary unpacked egg, in the .eggs subdirectory next to your setup.py. |
I came up with the following solution to make it work with direct invocation of setup.py and setup_requires=['pybind11'] class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """
def __init__(self, user=False):
self.user = user
def search_pybind11_headers(self):
import pybind11
def recommended():
return pybind11.get_include(self.user)
def setuptools_temp_egg():
# If users of setuptools drag in pybind11 only as a setup_require(ment), the pkg will be placed
# temporarily into .eggs, but we can not use the headers directly. So we have to
# link non-installed header files to correct subdirectory, so they can be used during compilation
found = False
for p in pybind11.__path__:
if '.egg' in p:
found = True
if not found:
return ''
header_src = os.path.abspath(os.path.join(pybind11.__path__[0], '..'))
hdrs = []
for _, _, filenames in os.walk(header_src):
hdrs += [f for f in filenames if f.endswith('.h')]
for h in sorted(hdrs):
if 'detail' in h:
sub = 'detail'
else:
sub = ''
dest = os.path.join(pybind11.__path__[0], sub, os.path.basename(h))
try:
os.link(h, dest)
except OSError:
pass
return header_src
methods = (recommended(),
setuptools_temp_egg(),
)
for m in methods:
if os.path.exists(os.path.join(m, 'pybind11', 'pybind11.h')):
return m
return ''
def __str__(self):
result = self.search_pybind11_headers()
if not result:
raise RuntimeError()
return result |
This should be fixed now |
I just played a little with the test project you kindly provided. I am currently facing the challenge of adapting the
setup.py
file for my project turbodbc to reflect my recent move from Boost.Python to pyodbc11 (thanks for that as well).This example here (as well as my project) features
pybind11
in theinstall_requires
section. This seems to be sufficient when installing from git withpip install /path/to/source
.Now consider the situation where I want to create a source distribution with
python setup.py sdist
for later upload to pypi. Subsequent installation withpip install python-example.0.0.1.tar.gz
yields error messages (output edited for brevity):Apparently, when building from a source distribution,
pip install
tries to build a wheel first. While building the wheel, the install requirements seem to be ignored. Even though this stage fails,pip install
continues with a regularsetup.py install
afterwards that succeeds.I have tried to resolve the issue by adding
setup_requires=['pybind11>=1.7.0']
tosetup.py
. Indeed, the error message changes: Instead of a PythonImportError
while building the wheel, I observe a compiler error instead, also while building the wheel:Again, the overall installation completes afterwards.
It would be great if you had some more ideas or advice. In the interest of a clean build output, I would otherwise consider packing the pybind header files (and License, of course) in my source distribution and remove the dependency to the pybind package.
The text was updated successfully, but these errors were encountered: