Compare commits
212 Commits
pr/unconfi
...
gh-pages
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6b47bc4d3 | ||
|
|
3ef37f9533 | ||
|
|
40ac5991a6 | ||
|
|
a3363bf6d0 | ||
|
|
ef30b2d45b | ||
|
|
c643eddb24 | ||
|
|
efec5cc9c4 | ||
|
|
0208ce68a4 | ||
|
|
54fa4df5eb | ||
|
|
bdac7aa8be | ||
|
|
c56cec0b97 | ||
|
|
8b5029633d | ||
|
|
ec04a29c0d | ||
|
|
00f52d520f | ||
|
|
ceaba1eadf | ||
|
|
d4f16f2f65 | ||
|
|
2c08974a61 | ||
|
|
567100e144 | ||
|
|
2454f4ea39 | ||
|
|
30df4f9cda | ||
|
|
bc8b1c542b | ||
|
|
cbf7d34fac | ||
|
|
23826bb0ad | ||
|
|
d295652ba9 | ||
|
|
14ff14da64 | ||
|
|
0840b1b021 | ||
|
|
4d29d373a4 | ||
|
|
8f6c7500d6 | ||
|
|
44ed212902 | ||
|
|
9fe1b1be11 | ||
|
|
52ee5165d4 | ||
|
|
ed7839e6dd | ||
|
|
e59ba32125 | ||
|
|
d09fe17349 | ||
|
|
73444e313e | ||
|
|
4bf1cbdcc0 | ||
|
|
82312e8288 | ||
|
|
8484c8b791 | ||
|
|
3a73838657 | ||
|
|
a3a174fd7a | ||
|
|
69603ea1ed | ||
|
|
467f2a5f66 | ||
|
|
1ddf4b0f30 | ||
|
|
7fe5ddf515 | ||
|
|
f272be01e4 | ||
|
|
34071ac6ed | ||
|
|
f51d9c6009 | ||
|
|
a0d4cf0b9e | ||
|
|
c1b8341508 | ||
|
|
000dea349c | ||
|
|
37247d7e70 | ||
|
|
15c9c81eb0 | ||
|
|
34683f62f9 | ||
|
|
01b3978e9b | ||
|
|
2937fc969a | ||
|
|
82ba8f9808 | ||
|
|
e55edd5350 | ||
|
|
9d29e5ec91 | ||
|
|
7631ab823a | ||
|
|
a3d3b568cf | ||
|
|
cb4d659494 | ||
|
|
09a4f9fa7c | ||
|
|
840cb8f87f | ||
|
|
b27e38d309 | ||
|
|
3eefe2c89d | ||
|
|
31506d0809 | ||
|
|
7efe95fcb1 | ||
|
|
908dca07c6 | ||
|
|
3f2915dfee | ||
|
|
3e98d6a886 | ||
|
|
0b214f23b6 | ||
|
|
5dd209a7ea | ||
|
|
faa03a3d47 | ||
|
|
808bf449ba | ||
|
|
547c3372c9 | ||
|
|
fedda578aa | ||
|
|
a0d561841a | ||
|
|
8ddea29cf2 | ||
|
|
ee4cdd2fc7 | ||
|
|
e3c9d24880 | ||
|
|
77203a87c6 | ||
|
|
4407285d84 | ||
|
|
29244def82 | ||
|
|
ec7db68823 | ||
|
|
e2fdcbaa31 | ||
|
|
30adb2c683 | ||
|
|
e3ffe96c31 | ||
|
|
a842ad4a2a | ||
|
|
ec06185a54 | ||
|
|
250eb35a4f | ||
|
|
b89a2f3c28 | ||
|
|
17a5547b61 | ||
|
|
040c73b036 | ||
|
|
aee6587d7a | ||
|
|
c23db8a239 | ||
|
|
39feaff0eb | ||
|
|
e6e491ca53 | ||
|
|
89c933ae26 | ||
|
|
5f075f5c39 | ||
|
|
1ec2312c45 | ||
|
|
d5d03ea3e7 | ||
|
|
4af41188a7 | ||
|
|
be612fb0f2 | ||
|
|
08f8ac352a | ||
|
|
d991ecf826 | ||
|
|
7328218580 | ||
|
|
ac5c7ed3e6 | ||
|
|
ad82e33aa3 | ||
|
|
562e9a0f4e | ||
|
|
febe794054 | ||
|
|
6b34c02142 | ||
|
|
2c1cdbf261 | ||
|
|
17ead69aa6 | ||
|
|
9a64d1b608 | ||
|
|
8426679815 | ||
|
|
80948eea39 | ||
|
|
44315a25cb | ||
|
|
45ab1541a6 | ||
|
|
2a6b83cdbb | ||
|
|
80140ff1f1 | ||
|
|
5ea803b542 | ||
|
|
4bbba9e65a | ||
|
|
c0911850af | ||
|
|
d3d39505ce | ||
|
|
9cab109fe7 | ||
|
|
ce91474a86 | ||
|
|
d7d43d1b51 | ||
|
|
0ec4ee8728 | ||
|
|
7a4abbd756 | ||
|
|
5cf8e4b16f | ||
|
|
25751c0e01 | ||
|
|
34384e4425 | ||
|
|
30ea8069ad | ||
|
|
78978167fe | ||
|
|
2835cde53b | ||
|
|
752b9fad2a | ||
|
|
3536d1e448 | ||
|
|
4044a88912 | ||
|
|
64a7437837 | ||
|
|
999646a574 | ||
|
|
15c8ed32c1 | ||
|
|
d3eb283e4a | ||
|
|
67c47e77a5 | ||
|
|
7dcd94b4d7 | ||
|
|
beb549e52e | ||
|
|
63375b8125 | ||
|
|
d772618958 | ||
|
|
64ecd89159 | ||
|
|
a2e5986368 | ||
|
|
cb0091a37a | ||
|
|
dc7fe97c42 | ||
|
|
34c171c94c | ||
|
|
04f04bb673 | ||
|
|
53dd548296 | ||
|
|
1ad9b029ed | ||
|
|
76040eda92 | ||
|
|
abc730d4d7 | ||
|
|
816cc9409d | ||
|
|
1cda96ef0c | ||
|
|
5b6b49f1a6 | ||
|
|
6288a814ce | ||
|
|
56d91f5538 | ||
|
|
6955a4131b | ||
|
|
af72fc08cf | ||
|
|
806766e601 | ||
|
|
093f67e714 | ||
|
|
95987ee891 | ||
|
|
e326d44d1f | ||
|
|
1501bb3cad | ||
|
|
00b2dc4457 | ||
|
|
f91cb27ae8 | ||
|
|
a0ee4f6472 | ||
|
|
5173a07394 | ||
|
|
5ddbe50573 | ||
|
|
a924c855a4 | ||
|
|
e1214ae417 | ||
|
|
00826aa0eb | ||
|
|
d4cbaa247e | ||
|
|
70d99c5fbb | ||
|
|
acf6c95fe3 | ||
|
|
2c1986885e | ||
|
|
9482f54ea3 | ||
|
|
2b63bc72b7 | ||
|
|
0a2e351422 | ||
|
|
497c4df2c9 | ||
|
|
aca45947f1 | ||
|
|
d6d430139e | ||
|
|
9e85df97af | ||
|
|
f7e5c217aa | ||
|
|
473c071577 | ||
|
|
79715f1d55 | ||
|
|
f6474f3914 | ||
|
|
34e61298c9 | ||
|
|
8ee3bf75fd | ||
|
|
dde4c3e057 | ||
|
|
31ef518aa0 | ||
|
|
957a35f829 | ||
|
|
c0d38bd1e2 | ||
|
|
5357af1994 | ||
|
|
98860632d4 | ||
|
|
cc0865cc01 | ||
|
|
2a2fcff426 | ||
|
|
1cddba437e | ||
|
|
d6767777f7 | ||
|
|
e688ef7a46 | ||
|
|
1b3917fb08 | ||
|
|
60a1354df4 | ||
|
|
c2c364fe26 | ||
|
|
1e66e4960c | ||
|
|
986173e731 | ||
|
|
56e41f3bf2 | ||
|
|
83729c63b5 |
103
.appveyor.yml
@@ -1,103 +0,0 @@
|
||||
environment:
|
||||
global:
|
||||
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
|
||||
# /E:ON and /V:ON options are not enabled in the batch script intepreter
|
||||
# See: http://stackoverflow.com/a/13751649/163740
|
||||
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\run_with_env.cmd"
|
||||
BOOST_PREFIX: C:\Libraries\boost_1_66_0
|
||||
|
||||
matrix:
|
||||
|
||||
# Pre-installed Python versions, which Appveyor may upgrade to
|
||||
# a later point release.
|
||||
# See: http://www.appveyor.com/docs/installed-software#python
|
||||
|
||||
- PYTHON: "C:\\Python27"
|
||||
PYTHON_VERSION: "2.7.x" # currently 2.7.9
|
||||
PYTHON_ARCH: "32"
|
||||
MSVC: "14.0"
|
||||
ARCH: x86
|
||||
|
||||
- PYTHON: "C:\\Python36-x64"
|
||||
PYTHON_VERSION: "3.6.x"
|
||||
PYTHON_ARCH: "64"
|
||||
MSVC: "12.0"
|
||||
ARCH: x86_64
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
PYTHON: "C:\\Python36-x64"
|
||||
PYTHON_VERSION: "3.6.x"
|
||||
PYTHON_ARCH: "64"
|
||||
MSVC: "14.13.26128"
|
||||
ARCH: x86_64
|
||||
|
||||
install:
|
||||
# If there is a newer build queued for the same PR, cancel this one.
|
||||
# The AppVeyor 'rollout builds' option is supposed to serve the same
|
||||
# purpose but it is problematic because it tends to cancel builds pushed
|
||||
# directly to master instead of just PR builds (or the converse).
|
||||
# credits: JuliaLang developers.
|
||||
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
|
||||
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
|
||||
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
|
||||
throw "There are newer queued builds for this pull request, failing early." }
|
||||
- ECHO "Filesystem root:"
|
||||
- ps: "ls \"C:/\""
|
||||
- ECHO "Installed libraries:"
|
||||
- ps: "ls \"C:/Libraries/\""
|
||||
## This path doesn't exist with the VS 2017 worker images
|
||||
#- ECHO "Installed SDKs:"
|
||||
#- ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""
|
||||
|
||||
# Install Python (from the official .msi of http://python.org) and pip when
|
||||
# not already installed.
|
||||
- ps: if (-not(Test-Path($env:PYTHON))) { & .ci\install.ps1 }
|
||||
|
||||
# Prepend newly installed Python to the PATH of this build (this cannot be
|
||||
# done from inside the powershell script as it would require to restart
|
||||
# the parent CMD process).
|
||||
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
|
||||
|
||||
# Check that we have the expected version and architecture for Python
|
||||
- "python --version"
|
||||
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
|
||||
|
||||
# Upgrade to the latest version of pip to avoid it displaying warnings
|
||||
# about it being out of date.
|
||||
- "pip install --disable-pip-version-check --user --upgrade pip"
|
||||
|
||||
# Install the build dependencies of the project. If some dependencies contain
|
||||
# compiled extensions and are not provided as pre-built wheel packages,
|
||||
# pip will build them from source using the MSVC compiler matching the
|
||||
# target Python version and architecture
|
||||
- |
|
||||
curl -LfsS -o faber.tar.gz https://github.com/stefanseefeld/faber/archive/snapshot/2018-04-08.tar.gz
|
||||
tar xf faber.tar.gz
|
||||
CD faber-snapshot-2018-04-08
|
||||
python setup.py install
|
||||
CD ..
|
||||
# report the available MSVC compilers
|
||||
- faber --info=tools cxx
|
||||
- easy_install sphinx
|
||||
- pip install numpy
|
||||
|
||||
build_script:
|
||||
- faber --with-boost-include=%BOOST_PREFIX% target.arch=%ARCH% msvc.version=%MSVC%
|
||||
|
||||
test_script:
|
||||
- faber --with-boost-include=%BOOST_PREFIX% test.report target.arch=%ARCH% msvc.version=%MSVC%
|
||||
|
||||
after_test:
|
||||
# If tests are successful, create binary packages for the project.
|
||||
#- "%CMD_IN_ENV% python setup.py bdist_wheel"
|
||||
#- "%CMD_IN_ENV% python setup.py bdist_wininst"
|
||||
#- "%CMD_IN_ENV% python setup.py bdist_msi"
|
||||
#- ps: "ls dist"
|
||||
|
||||
#artifacts:
|
||||
# Archive the generated packages in the ci.appveyor.com build report.
|
||||
#- path: dist\*
|
||||
|
||||
#on_success:
|
||||
# - TODO: upload the content of dist/*.whl to a public wheelhouse
|
||||
#
|
||||
@@ -1,3 +0,0 @@
|
||||
from faber.tools.python import python
|
||||
|
||||
p = python(command='$PYTHON')
|
||||
229
.ci/install.ps1
@@ -1,229 +0,0 @@
|
||||
# Sample script to install Python and pip under Windows
|
||||
# Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer
|
||||
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
|
||||
$BASE_URL = "https://www.python.org/ftp/python/"
|
||||
$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
|
||||
$GET_PIP_PATH = "C:\get-pip.py"
|
||||
|
||||
$PYTHON_PRERELEASE_REGEX = @"
|
||||
(?x)
|
||||
(?<major>\d+)
|
||||
\.
|
||||
(?<minor>\d+)
|
||||
\.
|
||||
(?<micro>\d+)
|
||||
(?<prerelease>[a-z]{1,2}\d+)
|
||||
"@
|
||||
|
||||
|
||||
function Download ($filename, $url) {
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
|
||||
$basedir = $pwd.Path + "\"
|
||||
$filepath = $basedir + $filename
|
||||
if (Test-Path $filename) {
|
||||
Write-Host "Reusing" $filepath
|
||||
return $filepath
|
||||
}
|
||||
|
||||
# Download and retry up to 3 times in case of network transient errors.
|
||||
Write-Host "Downloading" $filename "from" $url
|
||||
$retry_attempts = 2
|
||||
for ($i = 0; $i -lt $retry_attempts; $i++) {
|
||||
try {
|
||||
$webclient.DownloadFile($url, $filepath)
|
||||
break
|
||||
}
|
||||
Catch [Exception]{
|
||||
Start-Sleep 1
|
||||
}
|
||||
}
|
||||
if (Test-Path $filepath) {
|
||||
Write-Host "File saved at" $filepath
|
||||
} else {
|
||||
# Retry once to get the error message if any at the last try
|
||||
$webclient.DownloadFile($url, $filepath)
|
||||
}
|
||||
return $filepath
|
||||
}
|
||||
|
||||
|
||||
function ParsePythonVersion ($python_version) {
|
||||
if ($python_version -match $PYTHON_PRERELEASE_REGEX) {
|
||||
return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro,
|
||||
$matches.prerelease)
|
||||
}
|
||||
$version_obj = [version]$python_version
|
||||
return ($version_obj.major, $version_obj.minor, $version_obj.build, "")
|
||||
}
|
||||
|
||||
|
||||
function DownloadPython ($python_version, $platform_suffix) {
|
||||
$major, $minor, $micro, $prerelease = ParsePythonVersion $python_version
|
||||
|
||||
if (($major -le 2 -and $micro -eq 0) `
|
||||
-or ($major -eq 3 -and $minor -le 2 -and $micro -eq 0) `
|
||||
) {
|
||||
$dir = "$major.$minor"
|
||||
$python_version = "$major.$minor$prerelease"
|
||||
} else {
|
||||
$dir = "$major.$minor.$micro"
|
||||
}
|
||||
|
||||
if ($prerelease) {
|
||||
if (($major -le 2) `
|
||||
-or ($major -eq 3 -and $minor -eq 1) `
|
||||
-or ($major -eq 3 -and $minor -eq 2) `
|
||||
-or ($major -eq 3 -and $minor -eq 3) `
|
||||
) {
|
||||
$dir = "$dir/prev"
|
||||
}
|
||||
}
|
||||
|
||||
if (($major -le 2) -or ($major -le 3 -and $minor -le 4)) {
|
||||
$ext = "msi"
|
||||
if ($platform_suffix) {
|
||||
$platform_suffix = ".$platform_suffix"
|
||||
}
|
||||
} else {
|
||||
$ext = "exe"
|
||||
if ($platform_suffix) {
|
||||
$platform_suffix = "-$platform_suffix"
|
||||
}
|
||||
}
|
||||
|
||||
$filename = "python-$python_version$platform_suffix.$ext"
|
||||
$url = "$BASE_URL$dir/$filename"
|
||||
$filepath = Download $filename $url
|
||||
return $filepath
|
||||
}
|
||||
|
||||
|
||||
function InstallPython ($python_version, $architecture, $python_home) {
|
||||
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
|
||||
if (Test-Path $python_home) {
|
||||
Write-Host $python_home "already exists, skipping."
|
||||
return $false
|
||||
}
|
||||
if ($architecture -eq "32") {
|
||||
$platform_suffix = ""
|
||||
} else {
|
||||
$platform_suffix = "amd64"
|
||||
}
|
||||
$installer_path = DownloadPython $python_version $platform_suffix
|
||||
$installer_ext = [System.IO.Path]::GetExtension($installer_path)
|
||||
Write-Host "Installing $installer_path to $python_home"
|
||||
$install_log = $python_home + ".log"
|
||||
if ($installer_ext -eq '.msi') {
|
||||
InstallPythonMSI $installer_path $python_home $install_log
|
||||
} else {
|
||||
InstallPythonEXE $installer_path $python_home $install_log
|
||||
}
|
||||
if (Test-Path $python_home) {
|
||||
Write-Host "Python $python_version ($architecture) installation complete"
|
||||
} else {
|
||||
Write-Host "Failed to install Python in $python_home"
|
||||
Get-Content -Path $install_log
|
||||
Exit 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function InstallPythonEXE ($exepath, $python_home, $install_log) {
|
||||
$install_args = "/quiet InstallAllUsers=1 TargetDir=$python_home"
|
||||
RunCommand $exepath $install_args
|
||||
}
|
||||
|
||||
|
||||
function InstallPythonMSI ($msipath, $python_home, $install_log) {
|
||||
$install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home"
|
||||
$uninstall_args = "/qn /x $msipath"
|
||||
RunCommand "msiexec.exe" $install_args
|
||||
if (-not(Test-Path $python_home)) {
|
||||
Write-Host "Python seems to be installed else-where, reinstalling."
|
||||
RunCommand "msiexec.exe" $uninstall_args
|
||||
RunCommand "msiexec.exe" $install_args
|
||||
}
|
||||
}
|
||||
|
||||
function RunCommand ($command, $command_args) {
|
||||
Write-Host $command $command_args
|
||||
Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru
|
||||
}
|
||||
|
||||
|
||||
function InstallPip ($python_home) {
|
||||
$pip_path = $python_home + "\Scripts\pip.exe"
|
||||
$python_path = $python_home + "\python.exe"
|
||||
if (-not(Test-Path $pip_path)) {
|
||||
Write-Host "Installing pip..."
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
|
||||
Write-Host "Executing:" $python_path $GET_PIP_PATH
|
||||
& $python_path $GET_PIP_PATH
|
||||
} else {
|
||||
Write-Host "pip already installed."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function DownloadMiniconda ($python_version, $platform_suffix) {
|
||||
if ($python_version -eq "3.4") {
|
||||
$filename = "Miniconda3-3.5.5-Windows-" + $platform_suffix + ".exe"
|
||||
} else {
|
||||
$filename = "Miniconda-3.5.5-Windows-" + $platform_suffix + ".exe"
|
||||
}
|
||||
$url = $MINICONDA_URL + $filename
|
||||
$filepath = Download $filename $url
|
||||
return $filepath
|
||||
}
|
||||
|
||||
|
||||
function InstallMiniconda ($python_version, $architecture, $python_home) {
|
||||
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
|
||||
if (Test-Path $python_home) {
|
||||
Write-Host $python_home "already exists, skipping."
|
||||
return $false
|
||||
}
|
||||
if ($architecture -eq "32") {
|
||||
$platform_suffix = "x86"
|
||||
} else {
|
||||
$platform_suffix = "x86_64"
|
||||
}
|
||||
$filepath = DownloadMiniconda $python_version $platform_suffix
|
||||
Write-Host "Installing" $filepath "to" $python_home
|
||||
$install_log = $python_home + ".log"
|
||||
$args = "/S /D=$python_home"
|
||||
Write-Host $filepath $args
|
||||
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
|
||||
if (Test-Path $python_home) {
|
||||
Write-Host "Python $python_version ($architecture) installation complete"
|
||||
} else {
|
||||
Write-Host "Failed to install Python in $python_home"
|
||||
Get-Content -Path $install_log
|
||||
Exit 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function InstallMinicondaPip ($python_home) {
|
||||
$pip_path = $python_home + "\Scripts\pip.exe"
|
||||
$conda_path = $python_home + "\Scripts\conda.exe"
|
||||
if (-not(Test-Path $pip_path)) {
|
||||
Write-Host "Installing pip..."
|
||||
$args = "install --yes pip"
|
||||
Write-Host $conda_path $args
|
||||
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
|
||||
} else {
|
||||
Write-Host "pip already installed."
|
||||
}
|
||||
}
|
||||
|
||||
function main () {
|
||||
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
|
||||
InstallPip $env:PYTHON
|
||||
}
|
||||
|
||||
main
|
||||
@@ -1,88 +0,0 @@
|
||||
:: To build extensions for 64 bit Python 3, we need to configure environment
|
||||
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
|
||||
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
|
||||
::
|
||||
:: To build extensions for 64 bit Python 2, we need to configure environment
|
||||
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
|
||||
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
|
||||
::
|
||||
:: 32 bit builds, and 64-bit builds for 3.5 and beyond, do not require specific
|
||||
:: environment configurations.
|
||||
::
|
||||
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
|
||||
:: cmd interpreter, at least for (SDK v7.0)
|
||||
::
|
||||
:: More details at:
|
||||
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
|
||||
:: http://stackoverflow.com/a/13751649/163740
|
||||
::
|
||||
:: Author: Olivier Grisel
|
||||
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
::
|
||||
:: Notes about batch files for Python people:
|
||||
::
|
||||
:: Quotes in values are literally part of the values:
|
||||
:: SET FOO="bar"
|
||||
:: FOO is now five characters long: " b a r "
|
||||
:: If you don't want quotes, don't include them on the right-hand side.
|
||||
::
|
||||
:: The CALL lines at the end of this file look redundant, but if you move them
|
||||
:: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y
|
||||
:: case, I don't know why.
|
||||
@ECHO OFF
|
||||
|
||||
SET COMMAND_TO_RUN=%*
|
||||
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
|
||||
SET WIN_WDK=c:\Program Files (x86)\Windows Kits\10\Include\wdf
|
||||
|
||||
:: Extract the major and minor versions, and allow for the minor version to be
|
||||
:: more than 9. This requires the version number to have two dots in it.
|
||||
SET MAJOR_PYTHON_VERSION=%PYTHON_VERSION:~0,1%
|
||||
IF "%PYTHON_VERSION:~3,1%" == "." (
|
||||
SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1%
|
||||
) ELSE (
|
||||
SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,2%
|
||||
)
|
||||
|
||||
:: Based on the Python version, determine what SDK version to use, and whether
|
||||
:: to set the SDK for 64-bit.
|
||||
IF %MAJOR_PYTHON_VERSION% == 2 (
|
||||
SET WINDOWS_SDK_VERSION="v7.0"
|
||||
SET SET_SDK_64=Y
|
||||
) ELSE (
|
||||
IF %MAJOR_PYTHON_VERSION% == 3 (
|
||||
SET WINDOWS_SDK_VERSION="v7.1"
|
||||
IF %MINOR_PYTHON_VERSION% LEQ 4 (
|
||||
SET SET_SDK_64=Y
|
||||
) ELSE (
|
||||
SET SET_SDK_64=N
|
||||
IF EXIST "%WIN_WDK%" (
|
||||
:: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/
|
||||
REN "%WIN_WDK%" 0wdf
|
||||
)
|
||||
)
|
||||
) ELSE (
|
||||
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
|
||||
EXIT 1
|
||||
)
|
||||
)
|
||||
|
||||
IF %PYTHON_ARCH% == 64 (
|
||||
IF %SET_SDK_64% == Y (
|
||||
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
|
||||
SET DISTUTILS_USE_SDK=1
|
||||
SET MSSdk=1
|
||||
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
|
||||
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
|
||||
ECHO Executing: %COMMAND_TO_RUN%
|
||||
call %COMMAND_TO_RUN% || EXIT 1
|
||||
) ELSE (
|
||||
ECHO Using default MSVC build environment for 64 bit architecture
|
||||
ECHO Executing: %COMMAND_TO_RUN%
|
||||
call %COMMAND_TO_RUN% || EXIT 1
|
||||
)
|
||||
) ELSE (
|
||||
ECHO Using default MSVC build environment for 32 bit architecture
|
||||
ECHO Executing: %COMMAND_TO_RUN%
|
||||
call %COMMAND_TO_RUN% || EXIT 1
|
||||
)
|
||||
@@ -1,58 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e # Exit with nonzero exit code if anything fails
|
||||
|
||||
SOURCE_BRANCH="master"
|
||||
TARGET_BRANCH="gh-pages"
|
||||
|
||||
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || \
|
||||
[ "$TRAVIS_BRANCH" != master -a \
|
||||
"$TRAVIS_BRANCH" != develop -a \
|
||||
"$TRAVIS_BRANCH" != travis ]; then
|
||||
echo "No docs to upload."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$GH_TOKEN" ]; then
|
||||
echo "Error: GH_TOKEN is undefined"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Save some useful information
|
||||
REPO=`git config remote.origin.url`
|
||||
SHA=`git rev-parse --verify HEAD`
|
||||
|
||||
# build happens to contain the "doc/html" tree that we want to push
|
||||
# into the gh-pages branch. So we step into that directory, create a new repo,
|
||||
# set the remote appropriately, then commit and push.
|
||||
cd build
|
||||
git init
|
||||
git config user.name "Travis CI"
|
||||
git config user.email "travis-ci"
|
||||
|
||||
# Make sure 'GH_TOKEN' is set (as 'secure' variable) in .travis.yml
|
||||
git remote add upstream "https://$GH_TOKEN@github.com/boostorg/python.git"
|
||||
git fetch upstream
|
||||
git reset upstream/gh-pages
|
||||
|
||||
# Prepare version.
|
||||
if [ "$TRAVIS_BRANCH" = develop -o "$TRAVIS_BRANCH" = travis ]; then
|
||||
mkdir -p develop/doc/
|
||||
cp ../index.html develop/
|
||||
cp ../doc/index.html develop/doc/
|
||||
cp -a doc/html develop/doc/
|
||||
git add develop/index.html
|
||||
git add develop/doc/index.html
|
||||
git add -A develop/doc/html
|
||||
else
|
||||
cp ../index.html .
|
||||
cp ../doc/index.html doc/
|
||||
git add index.html
|
||||
git add doc/index.html
|
||||
git add -A doc/html
|
||||
fi
|
||||
# Commit the new version.
|
||||
git commit -m "Deploy to GitHub Pages: ${SHA}"
|
||||
|
||||
# Now that we're all set up, we can push.
|
||||
git push -q upstream HEAD:gh-pages
|
||||
4
.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
bin.SCons
|
||||
*.pyc
|
||||
*~
|
||||
\#*\#
|
||||
118
.travis.yml
@@ -1,118 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2016 Stefan Seefeld
|
||||
# All rights reserved.
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
language: cpp
|
||||
|
||||
env:
|
||||
global:
|
||||
- secure: BRNUkxN3p8f+uYKWC3Hr0VPqZA0PxbWr1DJlcI4hbiZtzKhMCWjDmd9UW9CzzexqeOxpd+9s0G87qvOur+wMSVxugDxtTesZrh1czXHeSVxgQrYD783XJtQJ9aYypbChkiboRD6Xpmbq7itwMuHBJMFtCuDxMynpU1jWwkyTf2Y=
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: CXX=g++ PYTHON=python CXXFLAGS=-std=c++98
|
||||
- os: linux
|
||||
env: CXX=g++ PYTHON=python CXXFLAGS=-std=c++11
|
||||
- os: linux
|
||||
env: CXX=g++ PYTHON=python3 CXXFLAGS=-std=c++98
|
||||
- os: linux
|
||||
env: CXX=g++ PYTHON=python3 CXXFLAGS=-std=c++11
|
||||
- os: linux
|
||||
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++98
|
||||
- os: linux
|
||||
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++11
|
||||
- os: osx
|
||||
env: CXX=clang++ PYTHON=python CXXFLAGS=-std=c++11
|
||||
- env: PYTHON=python DOC=1
|
||||
allow_failures:
|
||||
- os: osx
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-4.8
|
||||
- g++-4.8
|
||||
- clang
|
||||
- python-numpy
|
||||
- python-sphinx
|
||||
- python3-dev
|
||||
- python3-numpy
|
||||
- libboost-all-dev
|
||||
- xsltproc
|
||||
- docbook-xsl
|
||||
- python-docutils
|
||||
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/Boost
|
||||
|
||||
before_install:
|
||||
# The Trusty image has several Python versions pre-installed compiled with
|
||||
# conflicting UCS2 and UCS4 unicode. Modify the PATH to skip the TravisCI python.
|
||||
# See https://github.com/travis-ci/travis-ci/issues/4948 for details.
|
||||
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
|
||||
|
||||
install:
|
||||
# Install our own version of Boost (the subset we need) as the system version is
|
||||
# too old (for C++11 support).
|
||||
- |
|
||||
if [ ! -d $HOME/Boost/tools/boostbook ]; then
|
||||
echo "rebuilding Boost prerequisites."
|
||||
wget https://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.gz/download
|
||||
tar xf download
|
||||
pushd boost_1_66_0
|
||||
./bootstrap.sh
|
||||
./b2 tools/bcp
|
||||
mkdir -p $HOME/Boost
|
||||
# Install Boost.Python prerequisites, but not Boost.Python itself.
|
||||
dist/bin/bcp python tools/boostbook tools/quickbook $HOME/Boost &> /dev/null
|
||||
rm -rf $HOME/Boost/boost/python*
|
||||
popd
|
||||
else
|
||||
echo "using cached Boost prerequisites."
|
||||
fi
|
||||
# Install Faber, the build tool.
|
||||
date=2018-04-08
|
||||
wget https://github.com/stefanseefeld/faber/archive/snapshot/$date.tar.gz
|
||||
tar xf $date.tar.gz
|
||||
pushd faber-snapshot-$date
|
||||
#wget https://github.com/stefanseefeld/faber/archive/release/0.2.tar.gz
|
||||
#tar xf 0.2.tar.gz
|
||||
#pushd faber-release-0.2
|
||||
sudo python setup.py install
|
||||
popd
|
||||
|
||||
before_script:
|
||||
- sed -e "s/\$PYTHON/$PYTHON/g" .ci/faber > ~/.faber
|
||||
- $PYTHON --version
|
||||
- faber -h
|
||||
- ls -l $HOME/Boost
|
||||
|
||||
script:
|
||||
- |
|
||||
if [ "$DOC" ]; then
|
||||
BOOST_ROOT=$HOME/Boost faber --builddir=build doc.html
|
||||
else
|
||||
faber --with-boost-include=$HOME/Boost --builddir=build test.report cxx.name=$CXX cxxflags=$CXXFLAGS
|
||||
fi
|
||||
|
||||
after_success:
|
||||
# Upload docs only when building upstream.
|
||||
- |
|
||||
if [ "$DOC" -a \
|
||||
"$TRAVIS_REPO_SLUG" = "boostorg/python" -a \
|
||||
"$TRAVIS_PULL_REQUEST" = "false" ]; then
|
||||
export GH_TOKEN
|
||||
.ci/upload_docs.sh
|
||||
fi
|
||||
68
Jamfile
@@ -1,68 +0,0 @@
|
||||
# Copyright (c) 2018 Stefan Seefeld
|
||||
# All rights reserved.
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import option ;
|
||||
import regex ;
|
||||
import python ;
|
||||
|
||||
#
|
||||
# The `version-suffix` rule really belongs into python.jam, and
|
||||
# should be moved there. `split-version` is only duplicated here
|
||||
# as a prerequisite. (See https://github.com/boostorg/build/pull/290)
|
||||
#
|
||||
|
||||
|
||||
# Validate the version string and extract the major/minor part we care about.
|
||||
#
|
||||
local rule split-version ( version )
|
||||
{
|
||||
local major-minor = [ MATCH "^([0-9]+)\.([0-9]+)(.*)$" : $(version) : 1 2 3 ] ;
|
||||
if ! $(major-minor[2]) || $(major-minor[3])
|
||||
{
|
||||
ECHO "Warning: \"using python\" expects a two part (major, minor) version number; got" $(version) instead ;
|
||||
|
||||
# Add a zero to account for the missing digit if necessary.
|
||||
major-minor += 0 ;
|
||||
}
|
||||
|
||||
return $(major-minor[1]) $(major-minor[2]) ;
|
||||
}
|
||||
|
||||
# Define a version suffix for libraries depending on Python.
|
||||
# For example, Boost.Python built for Python 2.7 uses the suffix "27"
|
||||
rule version-suffix ( version )
|
||||
{
|
||||
local major-minor = [ split-version $(version) ] ;
|
||||
local suffix = $(major-minor:J="") ;
|
||||
return $(suffix) ;
|
||||
}
|
||||
|
||||
|
||||
# Python build id (for Python libraries only).
|
||||
python-id = [ option.get "python-buildid" ] ;
|
||||
if $(python-id)
|
||||
{
|
||||
PYTHON_ID = [ regex.replace $(python-id) "[*\\/:.\"\']" _ ] ;
|
||||
}
|
||||
|
||||
rule python-tag ( name : type ? : property-set )
|
||||
{
|
||||
local result = $(name) ;
|
||||
if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
|
||||
{
|
||||
local version = [ $(property-set).get <python> ] ;
|
||||
local lib-suffix = [ version-suffix $(version) ] ;
|
||||
result = $(result)$(lib-suffix) ;
|
||||
}
|
||||
if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB && $(PYTHON_ID)
|
||||
{
|
||||
result = $(result)-$(PYTHON_ID) ;
|
||||
}
|
||||
|
||||
# forward to the boost tagging rule
|
||||
return [ tag $(result) : $(type) : $(property-set) ] ;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
60
README.md
@@ -1,60 +0,0 @@
|
||||

|
||||
|
||||
# Synopsis
|
||||
|
||||
[](https://gitter.im/boostorg/python?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
Welcome to Boost.Python, a C++ library which enables seamless interoperability between C++ and the Python programming language. The library includes support for:
|
||||
|
||||
* References and Pointers
|
||||
* Globally Registered Type Coercions
|
||||
* Automatic Cross-Module Type Conversions
|
||||
* Efficient Function Overloading
|
||||
* C++ to Python Exception Translation
|
||||
* Default Arguments
|
||||
* Keyword Arguments
|
||||
* Manipulating Python objects in C++
|
||||
* Exporting C++ Iterators as Python Iterators
|
||||
* Documentation Strings
|
||||
|
||||
See the [Boost.Python](http://boostorg.github.io/python) documentation for details.
|
||||
|
||||
**Hint :** Check out the [development version](http://boostorg.github.io/python/develop) of the documentation to see work in progress.
|
||||
|
||||
# Building [](https://travis-ci.org/boostorg/python) [](https://ci.appveyor.com/project/stefanseefeld/python/branch/develop)
|
||||
|
||||
|
||||
While Boost.Python is part of the Boost C++ Libraries super-project, and thus can be compiled as part of Boost, it can also be compiled and installed stand-alone, i.e. against a pre-installed Boost package.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* [Python](http://www.python.org)
|
||||
* [Boost](http://www.boost.org)
|
||||
* [Faber](https://stefanseefeld.github.io/faber)
|
||||
|
||||
## Build
|
||||
|
||||
Run
|
||||
|
||||
```
|
||||
faber
|
||||
```
|
||||
to build the library.
|
||||
|
||||
## Test
|
||||
|
||||
Run
|
||||
|
||||
```
|
||||
faber test.report
|
||||
```
|
||||
to run the tests.
|
||||
|
||||
## Build docs
|
||||
|
||||
Run
|
||||
|
||||
```
|
||||
faber doc.html
|
||||
```
|
||||
to build the documentation.
|
||||
161
build/Jamfile
@@ -1,161 +0,0 @@
|
||||
# Copyright David Abrahams 2001-2006. Distributed under the Boost
|
||||
# Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import os ;
|
||||
import indirect ;
|
||||
import modules ;
|
||||
import feature ;
|
||||
import property ;
|
||||
import python ;
|
||||
|
||||
if ! [ python.configured ] && ! ( --without-python in [ modules.peek : ARGV ] )
|
||||
{
|
||||
# Attempt default configuration of python
|
||||
import toolset : using ;
|
||||
using python ;
|
||||
}
|
||||
|
||||
if [ python.configured ] || ( --without-python in [ modules.peek : ARGV ] )
|
||||
{
|
||||
alias config-warning ;
|
||||
}
|
||||
else
|
||||
{
|
||||
message config-warning
|
||||
: "warning: No python installation configured and autoconfiguration"
|
||||
: "note: failed. See http://www.boost.org/libs/python/doc/building.html"
|
||||
: "note: for configuration instructions or pass --without-python to"
|
||||
: "note: suppress this message and silently skip all Boost.Python targets"
|
||||
;
|
||||
}
|
||||
|
||||
if [ python.configured ]
|
||||
{
|
||||
project boost/python
|
||||
: source-location ../src
|
||||
;
|
||||
|
||||
rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
|
||||
rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
|
||||
local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } }
|
||||
|
||||
lib boost_python
|
||||
: # sources
|
||||
list.cpp
|
||||
long.cpp
|
||||
dict.cpp
|
||||
tuple.cpp
|
||||
str.cpp
|
||||
slice.cpp
|
||||
|
||||
converter/from_python.cpp
|
||||
converter/registry.cpp
|
||||
converter/type_id.cpp
|
||||
object/enum.cpp
|
||||
object/class.cpp
|
||||
object/function.cpp
|
||||
object/inheritance.cpp
|
||||
object/life_support.cpp
|
||||
object/pickle_support.cpp
|
||||
errors.cpp
|
||||
module.cpp
|
||||
converter/builtin_converters.cpp
|
||||
converter/arg_to_python_base.cpp
|
||||
object/iterator.cpp
|
||||
object/stl_iterator.cpp
|
||||
object_protocol.cpp
|
||||
object_operators.cpp
|
||||
wrapper.cpp
|
||||
import.cpp
|
||||
exec.cpp
|
||||
object/function_doc_signature.cpp
|
||||
: # requirements
|
||||
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||
<define>BOOST_PYTHON_SOURCE
|
||||
|
||||
# On Windows, all code using Python has to link to the Python
|
||||
# import library.
|
||||
#
|
||||
# On *nix we never link libboost_python to libpython. When
|
||||
# extending Python, all Python symbols are provided by the
|
||||
# Python interpreter executable. When embedding Python, the
|
||||
# client executable is expected to explicitly link to
|
||||
# /python//python (the target representing libpython) itself.
|
||||
#
|
||||
# python_for_extensions is a target defined by Boost.Build to
|
||||
# provide the Python include paths, and on Windows, the Python
|
||||
# import library, as usage requirements.
|
||||
[ cond [ python.configured ] : <library>/python//python_for_extensions ]
|
||||
|
||||
# we prevent building when there is no python available
|
||||
# as it's not possible anyway, and to cause dependents to
|
||||
# fail to build
|
||||
[ unless [ python.configured ] : <build>no ]
|
||||
<dependency>config-warning
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
|
||||
<tag>@$(__name__).python-tag
|
||||
<conditional>@python.require-py
|
||||
|
||||
: # default build
|
||||
<link>shared
|
||||
: # usage requirements
|
||||
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
;
|
||||
|
||||
numpy-include = [ python.numpy-include ] ;
|
||||
lib boost_numpy
|
||||
: # sources
|
||||
numpy/dtype.cpp
|
||||
numpy/matrix.cpp
|
||||
numpy/ndarray.cpp
|
||||
numpy/numpy.cpp
|
||||
numpy/scalars.cpp
|
||||
numpy/ufunc.cpp
|
||||
: # requirements
|
||||
<link>static:<define>BOOST_NUMPY_STATIC_LIB
|
||||
<define>BOOST_NUMPY_SOURCE
|
||||
[ cond [ python.numpy ] : <library>/python//python_for_extensions ]
|
||||
[ unless [ python.numpy ] : <build>no ]
|
||||
<include>$(numpy-include)
|
||||
<library>boost_python
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
|
||||
<tag>@$(__name__).python-tag
|
||||
<conditional>@python.require-py
|
||||
|
||||
: # default build
|
||||
<link>shared
|
||||
: # usage requirements
|
||||
<link>static:<define>BOOST_NUMPY_STATIC_LIB
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
;
|
||||
|
||||
# boost-install creates `stage` and `install` targets
|
||||
#
|
||||
# `stage` stages (builds and copies into `stage/lib`) the given libraries
|
||||
# `boost_python` and `boost_numpy` and their dependencies and is similar
|
||||
# to issuing `b2 --with-python stage` from top level
|
||||
#
|
||||
# `install` installs the two libraries and their dependencies and is similar
|
||||
# to issuing `b2 --with-python install` from top level
|
||||
|
||||
boost-install boost_python boost_numpy ;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
# When Python isn't configured, the above `boost-install` is not executed,
|
||||
# so we create empty `stage` and `install` targets that do nothing but issue
|
||||
# a warning message unless `--without-python` is given
|
||||
|
||||
alias stage : config-warning ;
|
||||
explicit stage ;
|
||||
|
||||
alias install : config-warning ;
|
||||
explicit install ;
|
||||
|
||||
}
|
||||
31
develop/doc/html/HTML.manifest
Normal file
@@ -0,0 +1,31 @@
|
||||
index.html
|
||||
rn.html
|
||||
building.html
|
||||
building/background.html
|
||||
building/no_install_quickstart.html
|
||||
building/installing_boost_python_on_your_.html
|
||||
building/configuring_boost_build.html
|
||||
building/choosing_a_boost_python_library_.html
|
||||
building/include_issues.html
|
||||
building/python_debugging_builds.html
|
||||
building/testing_boost_python.html
|
||||
building/notes_for_mingw_and_cygwin_with_.html
|
||||
configuration.html
|
||||
support.html
|
||||
faq.html
|
||||
faq/i_m_getting_the_attempt_to_retur.html
|
||||
faq/is_return_internal_reference_eff.html
|
||||
faq/how_can_i_wrap_functions_which_t.html
|
||||
faq/fatal_error_c1204_compiler_limit.html
|
||||
faq/how_do_i_debug_my_python_extensi.html
|
||||
faq/why_doesn_t_my_operator_work.html
|
||||
faq/does_boost_python_work_with_mac_.html
|
||||
faq/how_can_i_find_the_existing_pyob.html
|
||||
faq/how_can_i_wrap_a_function_which0.html
|
||||
faq/compilation_takes_too_much_time_.html
|
||||
faq/how_do_i_create_sub_packages_usi.html
|
||||
faq/error_c2064_term_does_not_evalua.html
|
||||
faq/how_can_i_automatically_convert_.html
|
||||
faq/why_is_my_automatic_to_python_co.html
|
||||
faq/is_boost_python_thread_aware_com.html
|
||||
glossary.html
|
||||
1081
develop/doc/html/article.html
Normal file
61
develop/doc/html/building.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 2. Building and Testing</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="up" href="index.html" title="Boost.Python">
|
||||
<link rel="prev" href="rn.html" title="Chapter 1. Release Notes">
|
||||
<link rel="next" href="building/background.html" title="Background">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="rn.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="building/background.html"><img src="images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="chapter">
|
||||
<div class="titlepage"><div>
|
||||
<div><h1 class="title">
|
||||
<a name="building"></a>Chapter 2. Building and Testing</h1></div>
|
||||
<div><div class="authorgroup"><div class="author"><h3 class="author">
|
||||
<span class="firstname">David</span> <span class="surname">Abrahams</span>
|
||||
</h3></div></div></div>
|
||||
<div><p class="copyright">Copyright © 2002-2015 David Abrahams, Stefan Seefeld</p></div>
|
||||
</div></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.requirements"></a><a class="link" href="building.html#building.requirements" title="Requirements">Requirements</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Boost.Python requires <a href="http://www.python.org/2.2" target="_top">Python 2.2</a>
|
||||
<a href="#ftn.building.requirements.f0" class="footnote" name="building.requirements.f0"><sup class="footnote">[1]</sup></a> <span class="bold"><strong>or</strong></span> <a href="http://www.python.org" target="_top">newer</a>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="footnotes">
|
||||
<br><hr style="width:100; text-align:left;margin-left: 0">
|
||||
<div id="ftn.building.requirements.f0" class="footnote"><p><a href="#building.requirements.f0" class="para"><sup class="para">[1] </sup></a>
|
||||
Note that although we tested earlier versions of Boost.Python with Python
|
||||
2.2, and we don't <span class="bold"><strong>think</strong></span> we've done anything
|
||||
to break compatibility, this release of Boost.Python may not have been
|
||||
tested with versions of Python earlier than 2.4, so we're not 100% sure
|
||||
that python 2.2 and 2.3 are supported.
|
||||
</p></div>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="rn.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="building/background.html"><img src="images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
70
develop/doc/html/building/background.html
Normal file
@@ -0,0 +1,70 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Background</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="next" href="no_install_quickstart.html" title="No-Install Quickstart">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../building.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="no_install_quickstart.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.background"></a><a class="link" href="background.html" title="Background">Background</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
There are two basic models for combining C++ and Python:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a href="http://www.python.org/doc/current/ext/intro.html" target="_top">extending</a>,
|
||||
in which the end-user launches the Python interpreter executable and
|
||||
imports Python “extension modules” written in C++. Think of taking
|
||||
a library written in C++ and giving it a Python interface so Python programmers
|
||||
can use it. From Python, these modules look just like regular Python
|
||||
modules.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a href="http://www.python.org/doc/current/ext/embedding.html" target="_top">embedding</a>,
|
||||
in which the end-user launches a program written in C++ that in turn
|
||||
invokes the Python interpreter as a library subroutine. Think of adding
|
||||
scriptability to an existing application.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The key distinction between extending and embedding is the location of the
|
||||
C++ <code class="computeroutput"><span class="identifier">main</span><span class="special">()</span></code>
|
||||
function: in the Python interpreter executable, or in some other program,
|
||||
respectively. Note that even when embedding Python in another program, <a href="http://www.python.org/doc/current/ext/extending-with-embedding.html" target="_top">extension
|
||||
modules are often the best way to make C/C++ functionality accessible to
|
||||
Python code</a>, so the use of extension modules is really at the heart
|
||||
of both models.
|
||||
</p>
|
||||
<p>
|
||||
Except in rare cases, extension modules are built as dynamically-loaded libraries
|
||||
with a single entry point, which means you can change them without rebuilding
|
||||
either the other extension modules or the executable containing <code class="computeroutput"><span class="identifier">main</span><span class="special">()</span></code>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../building.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="no_install_quickstart.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
128
develop/doc/html/building/choosing_a_boost_python_library_.html
Normal file
@@ -0,0 +1,128 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Choosing a Boost.Python Library Binary</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="configuring_boost_build.html" title="Configuring Boost.Build">
|
||||
<link rel="next" href="include_issues.html" title="#include Issues">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="configuring_boost_build.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="include_issues.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.choosing_a_boost_python_library_"></a><a class="link" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">Choosing a
|
||||
Boost.Python Library Binary</a>
|
||||
</h3></div></div></div>
|
||||
<div class="toc"><dl class="toc">
|
||||
<dt><span class="section"><a href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_dynamic_binary">The
|
||||
Dynamic Binary</a></span></dt>
|
||||
<dt><span class="section"><a href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_static_binary">The
|
||||
Static Binary</a></span></dt>
|
||||
</dl></div>
|
||||
<p>
|
||||
If—instead of letting Boost.Build construct and link with the right libraries
|
||||
automatically—you choose to use a pre-built Boost.Python library, you'll
|
||||
need to think about which one to link with. The Boost.Python binary comes
|
||||
in both static and dynamic flavors. Take care to choose the right flavor
|
||||
for your application. <a href="#ftn.building.choosing_a_boost_python_library_.f0" class="footnote" name="building.choosing_a_boost_python_library_.f0"><sup class="footnote">[3]</sup></a>
|
||||
</p>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="building.choosing_a_boost_python_library_.the_dynamic_binary"></a><a class="link" href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_dynamic_binary" title="The Dynamic Binary">The
|
||||
Dynamic Binary</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
The dynamic library is the safest and most-versatile choice:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
A single copy of the library code is used by all extension modules
|
||||
built with a given toolset. <a href="#ftn.building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="footnote" name="building.choosing_a_boost_python_library_.the_dynamic_binary.f0"><sup class="footnote">[4]</sup></a>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The library contains a type conversion registry. Because one registry
|
||||
is shared among all extension modules, instances of a class exposed
|
||||
to Python in one dynamically-loaded extension module can be passed
|
||||
to functions exposed in another such module.
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="building.choosing_a_boost_python_library_.the_static_binary"></a><a class="link" href="choosing_a_boost_python_library_.html#building.choosing_a_boost_python_library_.the_static_binary" title="The Static Binary">The
|
||||
Static Binary</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
It might be appropriate to use the static Boost.Python library in any of
|
||||
the following cases:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
You are <a href="https://docs.python.org/2/extending/extending.html" target="_top">extending</a>
|
||||
python and the types exposed in your dynamically-loaded extension module
|
||||
don't need to be used by any other Boost.Python extension modules,
|
||||
and you don't care if the core library code is duplicated among them.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
You are <a href="https://docs.python.org/2/extending/embedding.html" target="_top">embedding</a>
|
||||
python in your application and either:
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
|
||||
<li class="listitem">
|
||||
You are targeting a Unix variant OS other than MacOS or AIX,
|
||||
where the dynamically-loaded extension modules can “see”
|
||||
the Boost.Python library symbols that are part of the executable.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Or, you have statically linked some Boost.Python extension modules
|
||||
into your application and you don't care if any dynamically-loaded
|
||||
Boost.Python extension modules are able to use the types exposed
|
||||
by your statically-linked extension modules (and vice-versa).
|
||||
</li>
|
||||
</ul></div>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<div class="footnotes">
|
||||
<br><hr style="width:100; text-align:left;margin-left: 0">
|
||||
<div id="ftn.building.choosing_a_boost_python_library_.f0" class="footnote"><p><a href="#building.choosing_a_boost_python_library_.f0" class="para"><sup class="para">[3] </sup></a>
|
||||
Information about how to identify the static and dynamic builds of Boost.Python
|
||||
on <a href="http://boost.org/more/getting_started/windows.html#library-naming" target="_top">Windows</a>
|
||||
/ <a href="http://boost.org/more/getting_started/unix-variants.html#library-naming" target="_top">Unix
|
||||
variants</a>
|
||||
</p></div>
|
||||
<div id="ftn.building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="footnote"><p><a href="#building.choosing_a_boost_python_library_.the_dynamic_binary.f0" class="para"><sup class="para">[4] </sup></a>
|
||||
Because of the way most *nix platforms share symbols among dynamically-loaded
|
||||
objects, I'm not certain that extension modules built with different
|
||||
compiler toolsets will always use different copies of the Boost.Python
|
||||
library when loaded into the same Python instance. Not using different
|
||||
libraries could be a good thing if the compilers have compatible
|
||||
ABIs, because extension modules built with the two libraries would
|
||||
be interoperable. Otherwise, it could spell disaster, since an extension
|
||||
module and the Boost.Python library would have different ideas of
|
||||
such things as class layout. I would appreciate someone doing the
|
||||
experiment to find out what happens.
|
||||
</p></div>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="configuring_boost_build.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="include_issues.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
252
develop/doc/html/building/configuring_boost_build.html
Normal file
@@ -0,0 +1,252 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Configuring Boost.Build</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System">
|
||||
<link rel="next" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="installing_boost_python_on_your_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="choosing_a_boost_python_library_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.configuring_boost_build"></a><a class="link" href="configuring_boost_build.html" title="Configuring Boost.Build">Configuring Boost.Build</a>
|
||||
</h3></div></div></div>
|
||||
<div class="toc"><dl class="toc">
|
||||
<dt><span class="section"><a href="configuring_boost_build.html#building.configuring_boost_build.python_configuration_parameters">Python
|
||||
Configuration Parameters</a></span></dt>
|
||||
<dt><span class="section"><a href="configuring_boost_build.html#building.configuring_boost_build.examples">Examples</a></span></dt>
|
||||
</dl></div>
|
||||
<p>
|
||||
As described in the <a href="http://www.boost.org/build/doc/html/bbv2/overview/configuration.html" target="_top">Boost.Build
|
||||
Reference Manual</a>, a file called <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> in
|
||||
your home directory is used to specify the tools and libraries available
|
||||
to the build system. You may need to create or edit <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> to
|
||||
tell Boost.Build how to invoke Python, <code class="computeroutput"><span class="preprocessor">#include</span></code>
|
||||
its headers, and link with its libraries.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
If you are using a unix-variant OS and you ran Boost's <code class="computeroutput"><span class="identifier">configure</span></code>
|
||||
script, it may have generated a <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code>
|
||||
for you. <a href="#ftn.building.configuring_boost_build.f0" class="footnote" name="building.configuring_boost_build.f0"><sup class="footnote">[2]</sup></a> If your <code class="computeroutput"><span class="identifier">configure</span></code>/<code class="computeroutput"><span class="identifier">make</span></code> sequence was successful and Boost.Python
|
||||
binaries were built, your <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code>
|
||||
file is probably already correct.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
If you have one fairly “standard” python installation for your platform,
|
||||
you might not need to do anything special to describe it. If you haven't
|
||||
configured python in <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> (and
|
||||
you don't specify <code class="computeroutput"><span class="special">--</span><span class="identifier">without</span><span class="special">-</span><span class="identifier">python</span></code>
|
||||
on the Boost.Build command line), Boost.Build will automatically execute
|
||||
the equivalent of
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">import</span> <span class="identifier">toolset</span> <span class="special">:</span> <span class="keyword">using</span> <span class="special">;</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
which automatically looks for Python in the most likely places. However,
|
||||
that only happens when using the Boost.Python project file (e.g. when referred
|
||||
to by another project as in the quickstart method). If instead you are linking
|
||||
against separately-compiled Boost.Python binaries, you should set up a <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> file
|
||||
with at least the minimal incantation above.
|
||||
</p>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="building.configuring_boost_build.python_configuration_parameters"></a><a class="link" href="configuring_boost_build.html#building.configuring_boost_build.python_configuration_parameters" title="Python Configuration Parameters">Python
|
||||
Configuration Parameters</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
If you have several versions of Python installed, or Python is installed
|
||||
in an unusual way, you may want to supply any or all of the following optional
|
||||
parameters to <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">python</span></code>.
|
||||
</p>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">version</span></dt>
|
||||
<dd><p>
|
||||
the version of Python to use. Should be in Major.Minor format, for
|
||||
example, <code class="computeroutput"><span class="number">2.3</span></code>. Do not
|
||||
include the subminor version (i.e. <span class="bold"><strong>not</strong></span>
|
||||
<code class="computeroutput"><span class="number">2.5</span><span class="special">.</span><span class="number">1</span></code>). If you have multiple Python versions
|
||||
installed, the version will usually be the only configuration argument
|
||||
required.
|
||||
</p></dd>
|
||||
<dt><span class="term">cmd-or-prefix</span></dt>
|
||||
<dd><p>
|
||||
preferably, a command that invokes a Python interpreter. Alternatively,
|
||||
the installation prefix for Python libraries and header files. Only
|
||||
use the alternative formulation if there is no appropriate Python
|
||||
executable available.
|
||||
</p></dd>
|
||||
<dt><span class="term"><span class="bold"><strong>includes</strong></span></span></dt>
|
||||
<dd><p>
|
||||
the <code class="computeroutput"><span class="preprocessor">#include</span></code> paths
|
||||
for Python headers. Normally the correct path(s) will be automatically
|
||||
deduced from <code class="computeroutput"><span class="identifier">version</span></code>
|
||||
and/or <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>.
|
||||
</p></dd>
|
||||
<dt><span class="term"><span class="bold"><strong>libraries</strong></span></span></dt>
|
||||
<dd><p>
|
||||
the path to Python library binaries. On MacOS/Darwin, you can also
|
||||
pass the path of the Python framework. Normally the correct path(s)
|
||||
will be automatically deduced from <code class="computeroutput"><span class="identifier">version</span></code>
|
||||
and/or <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>.
|
||||
</p></dd>
|
||||
<dt><span class="term"><span class="bold"><strong>condition</strong></span></span></dt>
|
||||
<dd><p>
|
||||
if specified, should be a set of Boost.Build properties that are
|
||||
matched against the build configuration when Boost.Build selects
|
||||
a Python configuration to use. See examples below for details.
|
||||
</p></dd>
|
||||
<dt><span class="term"><span class="bold"><strong>extension-suffix</strong></span></span></dt>
|
||||
<dd><p>
|
||||
A string to append to the name of extension modules before the true
|
||||
filename extension. You almost certainly don't need to use this.
|
||||
Usually this suffix is only used when targeting a Windows debug build
|
||||
of Python, and will be set automatically for you based on the value
|
||||
of the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds"><python-debugging></a>
|
||||
feature. However, at least one Linux distribution (Ubuntu Feisty
|
||||
Fawn) has a specially configured <a href="https://wiki.ubuntu.com/PyDbgBuilds" target="_top"><python-dbg></a>
|
||||
package that claims to use such a suffix.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="building.configuring_boost_build.examples"></a><a class="link" href="configuring_boost_build.html#building.configuring_boost_build.examples" title="Examples">Examples</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Note that in the examples below, case and <span class="bold"><strong>especially
|
||||
whitespace</strong></span> are significant.
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
If you have both python 2.5 and python 2.4 installed, <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> might contain
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">Make</span> <span class="identifier">both</span> <span class="identifier">versions</span> <span class="identifier">of</span> <span class="identifier">Python</span> <span class="identifier">available</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">To</span> <span class="identifier">build</span> <span class="identifier">with</span> <span class="identifier">python</span> <span class="number">2.4</span><span class="special">,</span> <span class="identifier">add</span> <span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span>
|
||||
<span class="preprocessor"># to</span> <span class="identifier">your</span> <span class="identifier">command</span> <span class="identifier">line</span><span class="special">.</span>
|
||||
</pre>
|
||||
<p>
|
||||
The first version configured (2.5) becomes the default. To build
|
||||
against python 2.4, add <code class="computeroutput"><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span></code>
|
||||
to the <code class="computeroutput"><span class="identifier">bjam</span></code> command
|
||||
line.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
If you have python installed in an unusual location, you might supply
|
||||
the path to the interpreter in the <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>
|
||||
parameter:
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="special">/</span><span class="identifier">usr</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">python</span><span class="special">-</span><span class="number">2.6</span><span class="special">-</span><span class="identifier">beta</span><span class="special">/</span><span class="identifier">bin</span><span class="special">/</span><span class="identifier">python</span> <span class="special">;</span>
|
||||
</pre>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
If you have a separate build of Python for use with a particular toolset,
|
||||
you might supply that toolset in the <code class="computeroutput"><span class="identifier">condition</span></code>
|
||||
parameter:
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">use</span> <span class="keyword">for</span> <span class="identifier">most</span> <span class="identifier">toolsets</span>
|
||||
|
||||
<span class="preprocessor"># Use</span> <span class="identifier">with</span> <span class="identifier">Intel</span> <span class="identifier">C</span><span class="special">++</span> <span class="identifier">toolset</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span>
|
||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">version</span>
|
||||
<span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">Devel</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">-</span><span class="identifier">IntelBuild</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">#</span> <span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span>
|
||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span>
|
||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">libraries</span>
|
||||
<span class="special">:</span> <span class="special"><</span><span class="identifier">toolset</span><span class="special">></span><span class="identifier">intel</span> <span class="special">#</span> <span class="identifier">condition</span>
|
||||
<span class="special">;</span>
|
||||
</pre>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
If you have downloaded the Python sources and built both the normal
|
||||
and the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds">"python
|
||||
debugging"</a> builds from source on Windows, you might see:
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">;</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python_d</span>
|
||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span>
|
||||
<span class="special">:</span> <span class="special">#</span> <span class="identifier">libs</span>
|
||||
<span class="special">:</span> <span class="special"><</span><span class="identifier">python</span><span class="special">-</span><span class="identifier">debugging</span><span class="special">></span><span class="identifier">on</span> <span class="special">;</span>
|
||||
</pre>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
You can set up your user-config.jam so a bjam built under Windows can
|
||||
build/test both Windows and Cygwin_ python extensions. Just pass <code class="computeroutput"><span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span></code>
|
||||
in the <code class="computeroutput"><span class="identifier">condition</span></code> parameter
|
||||
for the cygwin python installation:
|
||||
<pre class="programlisting"><span class="preprocessor"># windows</span> <span class="identifier">installation</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span>
|
||||
|
||||
<span class="preprocessor"># cygwin</span> <span class="identifier">installation</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">cygwin</span><span class="special">\\</span><span class="identifier">bin</span><span class="special">\\</span><span class="identifier">python2</span><span class="special">.</span><span class="number">5</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span> <span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
when you put target-os=cygwin in your build request, it should build
|
||||
with the cygwin version of python: <a name="flavor"></a>_
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span>
|
||||
</pre>
|
||||
<p>
|
||||
This is supposed to work the other way, too (targeting windows python
|
||||
with a <a href="http://cygwin.com" target="_top">Cygwin</a> bjam) but it
|
||||
seems as though the support in Boost.Build's toolsets for building
|
||||
that way is broken at the time of this writing.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Note that because of <a href="http://zigzag.cs.msu.su/boost.build/wiki/AlternativeSelection" target="_top">the
|
||||
way Boost.Build currently selects target alternatives</a>, you
|
||||
might have be very explicit in your build requests. For example, given:
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">a</span> <span class="identifier">regular</span> <span class="identifier">windows</span> <span class="identifier">build</span>
|
||||
<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span> <span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
building with
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span>
|
||||
</pre>
|
||||
<p>
|
||||
will yield an error. Instead, you'll need to write
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span><span class="special">/</span><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span>
|
||||
</pre>
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<div class="footnotes">
|
||||
<br><hr style="width:100; text-align:left;margin-left: 0">
|
||||
<div id="ftn.building.configuring_boost_build.f0" class="footnote"><p><a href="#building.configuring_boost_build.f0" class="para"><sup class="para">[2] </sup></a>
|
||||
<code class="computeroutput"><span class="identifier">configure</span></code> overwrites
|
||||
the existing <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> in your home directory (if any)
|
||||
after making a backup of the old version.
|
||||
</p></div>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="installing_boost_python_on_your_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="choosing_a_boost_python_library_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
53
develop/doc/html/building/include_issues.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>#include Issues</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary">
|
||||
<link rel="next" href="python_debugging_builds.html" title="Python Debugging Builds">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="choosing_a_boost_python_library_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="python_debugging_builds.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.include_issues"></a><a class="link" href="include_issues.html" title="#include Issues"><code class="computeroutput"><span class="preprocessor">#include</span></code>
|
||||
Issues</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
1. If you should ever have occasion to <code class="computeroutput"><span class="preprocessor">#include</span>
|
||||
<span class="string">"python.h"</span></code> directly in a
|
||||
translation unit of a program using Boost.Python, use <code class="computeroutput"><span class="preprocessor">#include</span>
|
||||
<span class="string">"boost/python/detail/wrap_python.hpp"</span></code>
|
||||
instead. It handles several issues necessary for use with Boost.Python, one
|
||||
of which is mentioned in the next section.
|
||||
</p>
|
||||
<p>
|
||||
2. Be sure not to <code class="computeroutput"><span class="preprocessor">#include</span></code>
|
||||
any system headers before <code class="computeroutput"><span class="identifier">wrap_python</span><span class="special">.</span><span class="identifier">hpp</span></code>. This
|
||||
restriction is actually imposed by Python, or more properly, by Python's
|
||||
interaction with your operating system. See <a href="http://docs.python.org/ext/simpleExample.html" target="_top">http://docs.python.org/ext/simpleExample.html</a>
|
||||
for details.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="choosing_a_boost_python_library_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="python_debugging_builds.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Installing Boost.Python on your System</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="no_install_quickstart.html" title="No-Install Quickstart">
|
||||
<link rel="next" href="configuring_boost_build.html" title="Configuring Boost.Build">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="no_install_quickstart.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="configuring_boost_build.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.installing_boost_python_on_your_"></a><a class="link" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System">Installing
|
||||
Boost.Python on your System</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Since Boost.Python is a separately-compiled (as opposed to <code class="computeroutput"><span class="identifier">header</span><span class="special">-</span><span class="identifier">only</span></code>) library, its user relies on the services
|
||||
of a Boost.Python library binary.
|
||||
</p>
|
||||
<p>
|
||||
If you need a regular installation of the Boost.Python library binaries on
|
||||
your system, the Boost <a href="http://www.boost.org/more/getting_started/" target="_top">Getting
|
||||
Started Guide</a> will walk you through the steps of creating one. If
|
||||
building binaries from source, you might want to supply the <code class="computeroutput"><span class="special">--</span><span class="identifier">with</span><span class="special">-</span><span class="identifier">python</span></code>
|
||||
argument to <code class="computeroutput"><span class="identifier">bjam</span></code> (or the
|
||||
<code class="computeroutput"><span class="special">--</span><span class="identifier">with</span><span class="special">-</span><span class="identifier">libraries</span><span class="special">=</span><span class="identifier">python</span></code>
|
||||
argument to <code class="computeroutput"><span class="identifier">configure</span></code>), so
|
||||
only the Boost.Python binary will be built, rather than all the Boost binaries.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="no_install_quickstart.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="configuring_boost_build.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
318
develop/doc/html/building/no_install_quickstart.html
Normal file
@@ -0,0 +1,318 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>No-Install Quickstart</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="background.html" title="Background">
|
||||
<link rel="next" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="background.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="installing_boost_python_on_your_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.no_install_quickstart"></a><a class="link" href="no_install_quickstart.html" title="No-Install Quickstart">No-Install Quickstart</a>
|
||||
</h3></div></div></div>
|
||||
<div class="toc"><dl class="toc">
|
||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.basic_procedure">Basic
|
||||
Procedure</a></span></dt>
|
||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.in_case_of_trouble">In
|
||||
Case of Trouble</a></span></dt>
|
||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.in_case_everything_seemed_to_wor">In
|
||||
Case Everything Seemed to Work</a></span></dt>
|
||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project">Modifying
|
||||
the Example Project</a></span></dt>
|
||||
</dl></div>
|
||||
<p>
|
||||
There is no need to “install Boost” in order to get started using Boost.Python.
|
||||
These instructions use <a href="http://www.boost.org/build" target="_top">Boost.Build</a>
|
||||
projects, which will build those binaries as soon as they're needed. Your
|
||||
first tests may take a little longer while you wait for Boost.Python to build,
|
||||
but doing things this way will save you from worrying about build intricacies
|
||||
like which library binaries to use for a specific compiler configuration
|
||||
and figuring out the right compiler options to use yourself.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
Of course it's possible to use other build systems to build Boost.Python
|
||||
and its extensions, but they are not officially supported by Boost. Moreover
|
||||
<span class="bold"><strong>99% of all “I can't build Boost.Python” problems
|
||||
come from trying to use another build system</strong></span> without first following
|
||||
these instructions.
|
||||
</p>
|
||||
<p>
|
||||
If you want to use another system anyway, we suggest that you follow these
|
||||
instructions, and then invoke <code class="computeroutput"><span class="identifier">bjam</span></code>
|
||||
with the
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">-</span><span class="identifier">a</span>
|
||||
<span class="special">-</span><span class="identifier">o</span></code><span class="emphasis"><em>filename</em></span>
|
||||
</p>
|
||||
<p>
|
||||
options to dump the build commands it executes to a file, so you can see
|
||||
what your alternate build system needs to do.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="building.no_install_quickstart.basic_procedure"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.basic_procedure" title="Basic Procedure">Basic
|
||||
Procedure</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
1. Get Boost; see sections 1 and 2 of the Boost <a href="http://www.boost.org/more/getting_started/" target="_top">Getting
|
||||
Started Guide</a>.
|
||||
</p>
|
||||
<p>
|
||||
2. Get the <code class="computeroutput"><span class="identifier">bjam</span></code> build driver.
|
||||
See section 5 of the Boost <a href="http://www.boost.org/more/getting_started/" target="_top">Getting
|
||||
Started Guide</a>.
|
||||
</p>
|
||||
<p>
|
||||
3. cd into the <code class="computeroutput"><span class="identifier">example</span><span class="special">/</span><span class="identifier">quickstart</span><span class="special">/</span></code> directory of your Boost.Python installation,
|
||||
which contains a small example project.
|
||||
</p>
|
||||
<p>
|
||||
4. Invoke <code class="computeroutput"><span class="identifier">bjam</span></code>. Replace
|
||||
the “<code class="computeroutput"><span class="identifier">stage</span></code>“ argument
|
||||
from the example invocation from section 5 of the Boost <a href="http://www.boost.org/more/getting_started/" target="_top">Getting
|
||||
Started Guide</a> with “<code class="computeroutput"><span class="identifier">test</span></code>,“
|
||||
to build all the test targets. Also add the argument “<code class="computeroutput"><span class="special">--</span><span class="identifier">verbose</span><span class="special">-</span><span class="identifier">test</span></code>” to see the output generated by
|
||||
the tests when they are run. On Windows, your <code class="computeroutput"><span class="identifier">bjam</span></code>
|
||||
invocation might look something like:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">C</span><span class="special">:\\...\\</span><span class="identifier">quickstart</span><span class="special">></span> <span class="identifier">bjam</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">msvc</span> <span class="special">--</span><span class="identifier">verbose</span><span class="special">-</span><span class="identifier">test</span> <span class="identifier">test</span>
|
||||
</pre>
|
||||
<p>
|
||||
and on Unix variants, perhaps,
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">.../</span><span class="identifier">quickstart</span><span class="error">$</span> <span class="identifier">bjam</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span> <span class="special">--</span><span class="identifier">verbose</span><span class="special">-</span><span class="identifier">test</span> <span class="identifier">test</span>
|
||||
</pre>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
For the sake of concision, the rest of this guide will use unix-style
|
||||
forward slashes in pathnames instead of the backslashes with which Windows
|
||||
users may be more familiar. The forward slashes should work everywhere
|
||||
except in <a href="http://www.boost.org/more/getting_started/windows.html#command-prompt" target="_top">Command
|
||||
Prompt</a> windows, where you should use backslashes.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
If you followed this procedure successfully, you will have built an extension
|
||||
module called <code class="computeroutput"><span class="identifier">extending</span></code>
|
||||
and tested it by running a Python script called <code class="computeroutput"><span class="identifier">test_extending</span><span class="special">.</span><span class="identifier">py</span></code>.
|
||||
You will also have built and run a simple application called <code class="computeroutput"><span class="identifier">embedding</span></code> that embeds python.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="building.no_install_quickstart.in_case_of_trouble"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.in_case_of_trouble" title="In Case of Trouble">In
|
||||
Case of Trouble</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
If you're seeing lots of compiler and/or linker error messages, it's probably
|
||||
because Boost.Build is having trouble finding your Python installation.
|
||||
You might want to pass the <code class="computeroutput"><span class="special">--</span><span class="identifier">debug</span><span class="special">-</span><span class="identifier">configuration</span></code> option to <code class="computeroutput"><span class="identifier">bjam</span></code> the first few times you invoke it,
|
||||
to make sure that Boost.Build is correctly locating all the parts of your
|
||||
Python installation. If it isn't, consider <a class="link" href="configuring_boost_build.html" title="Configuring Boost.Build">Configuring
|
||||
Boost.Build</a> as detailed below.
|
||||
</p>
|
||||
<p>
|
||||
If you're still having trouble, Someone on one of the following mailing
|
||||
lists may be able to help:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
The <a href="http://www.boost.org/more/mailing_lists.htm#jamboost" target="_top">Boost.Build
|
||||
mailing list</a> for issues related to Boost.Build
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The <a href="http://www.boost.org/more/mailing_lists.htm#cplussig" target="_top">Boost.Python
|
||||
mailing list</a> for issues specifically related to Boost.Python
|
||||
</li>
|
||||
</ul></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="building.no_install_quickstart.in_case_everything_seemed_to_wor"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.in_case_everything_seemed_to_wor" title="In Case Everything Seemed to Work">In
|
||||
Case Everything Seemed to Work</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Rejoice! If you're new to Boost.Python, at this point it might be a good
|
||||
idea to ignore build issues for a while and concentrate on learning the
|
||||
library by going through the <a href="../tutorial/index.html" target="_top">Tutorial</a>
|
||||
and perhaps some of the <a href="../reference/index.html" target="_top">Reference Manual</a>,
|
||||
trying out what you've learned about the API by modifying the quickstart
|
||||
project.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="building.no_install_quickstart.modifying_the_example_project"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project" title="Modifying the Example Project">Modifying
|
||||
the Example Project</a>
|
||||
</h4></div></div></div>
|
||||
<div class="toc"><dl class="toc">
|
||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.relocate_the_project">Relocate
|
||||
the Project</a></span></dt>
|
||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.add_new_or_change_names_of_exist">Add
|
||||
New or Change Names of Existing Source Files</a></span></dt>
|
||||
<dt><span class="section"><a href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.change_the_name_of_your_extensio">Change
|
||||
the Name of your Extension Module</a></span></dt>
|
||||
</dl></div>
|
||||
<p>
|
||||
If you're content to keep your extension module forever in one source file
|
||||
called <code class="computeroutput"><span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span></code>, inside your Boost.Python distribution,
|
||||
and import it forever as <code class="computeroutput"><span class="identifier">extending</span></code>,
|
||||
then you can stop here. However, it's likely that you will want to make
|
||||
a few changes. There are a few things you can do without having to learn
|
||||
<a href="http://www.boost.org/build" target="_top">Boost.Build</a> in depth.
|
||||
</p>
|
||||
<p>
|
||||
The project you just built is specified in two files in the current directory:
|
||||
<code class="computeroutput"><span class="identifier">boost</span><span class="special">-</span><span class="identifier">build</span><span class="special">.</span><span class="identifier">jam</span></code>, which tells <code class="computeroutput"><span class="identifier">bjam</span></code>
|
||||
where it can find the interpreted code of the Boost build system, and
|
||||
<code class="computeroutput"><span class="identifier">Jamroot</span></code>, which describes
|
||||
the targets you just built. These files are heavily commented, so they
|
||||
should be easy to modify. Take care, however, to preserve whitespace. Punctuation
|
||||
such as <code class="computeroutput"><span class="special">;</span></code> will not be recognized
|
||||
as intended by <code class="computeroutput"><span class="identifier">bjam</span></code> if
|
||||
it is not surrounded by whitespace.
|
||||
</p>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="building.no_install_quickstart.modifying_the_example_project.relocate_the_project"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.relocate_the_project" title="Relocate the Project">Relocate
|
||||
the Project</a>
|
||||
</h5></div></div></div>
|
||||
<p>
|
||||
You'll probably want to copy this project elsewhere so you can change
|
||||
it without modifying your Boost distribution. To do that, simply
|
||||
</p>
|
||||
<p>
|
||||
a. copy the entire <code class="computeroutput"><span class="identifier">example</span><span class="special">/</span><span class="identifier">quickstart</span><span class="special">/</span></code> directory into a new directory.
|
||||
</p>
|
||||
<p>
|
||||
b. In the new copies of <code class="computeroutput"><span class="identifier">boost</span><span class="special">-</span><span class="identifier">build</span><span class="special">.</span><span class="identifier">jam</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">Jamroot</span></code>, locate the
|
||||
relative path near the top of the file that is clearly marked by a comment,
|
||||
and edit that path so that it refers to the same directory your Boost
|
||||
distribution as it referred to when the file was in its original location
|
||||
in the <code class="computeroutput"><span class="identifier">example</span><span class="special">/</span><span class="identifier">quickstart</span><span class="special">/</span></code>
|
||||
directory.
|
||||
</p>
|
||||
<p>
|
||||
For example, if you moved the project from <code class="computeroutput"><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">dave</span><span class="special">/</span><span class="identifier">boost_1_34_0</span><span class="special">/</span><span class="identifier">libs</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">example</span><span class="special">/</span><span class="identifier">quickstart</span></code> to <code class="computeroutput"><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">dave</span><span class="special">/</span><span class="identifier">my</span><span class="special">-</span><span class="identifier">project</span></code>, you could change the first
|
||||
path in <code class="computeroutput"><span class="identifier">boost</span><span class="special">-</span><span class="identifier">build</span><span class="special">.</span><span class="identifier">jam</span></code> from
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">../../../../</span><span class="identifier">tools</span><span class="special">/</span><span class="identifier">build</span><span class="special">/</span><span class="identifier">src</span>
|
||||
</pre>
|
||||
<p>
|
||||
to
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">dave</span><span class="special">/</span><span class="identifier">boost_1_34_0</span><span class="special">/</span><span class="identifier">tools</span><span class="special">/</span><span class="identifier">build</span><span class="special">/</span><span class="identifier">src</span>
|
||||
</pre>
|
||||
<p>
|
||||
and change the first path in <code class="computeroutput"><span class="identifier">Jamroot</span></code>
|
||||
from
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">../../../..</span>
|
||||
</pre>
|
||||
<p>
|
||||
to
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">dave</span><span class="special">/</span><span class="identifier">boost_1_34_0</span>
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="building.no_install_quickstart.modifying_the_example_project.add_new_or_change_names_of_exist"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.add_new_or_change_names_of_exist" title="Add New or Change Names of Existing Source Files">Add
|
||||
New or Change Names of Existing Source Files</a>
|
||||
</h5></div></div></div>
|
||||
<p>
|
||||
The names of additional source files involved in building your extension
|
||||
module or embedding application can be listed in <code class="computeroutput"><span class="identifier">Jamroot</span></code>
|
||||
right alongside <code class="computeroutput"><span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">embedding</span><span class="special">.</span><span class="identifier">cpp</span></code> respectively. Just be sure to leave
|
||||
whitespace around each filename:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="error">…</span> <span class="identifier">file1</span><span class="special">.</span><span class="identifier">cpp</span> <span class="identifier">file2</span><span class="special">.</span><span class="identifier">cpp</span> <span class="identifier">file3</span><span class="special">.</span><span class="identifier">cpp</span> <span class="error">…</span>
|
||||
</pre>
|
||||
<p>
|
||||
Naturally, if you want to change the name of a source file you can tell
|
||||
Boost.Build about it by editing the name in <code class="computeroutput"><span class="identifier">Jamroot</span></code>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="building.no_install_quickstart.modifying_the_example_project.change_the_name_of_your_extensio"></a><a class="link" href="no_install_quickstart.html#building.no_install_quickstart.modifying_the_example_project.change_the_name_of_your_extensio" title="Change the Name of your Extension Module">Change
|
||||
the Name of your Extension Module</a>
|
||||
</h5></div></div></div>
|
||||
<p>
|
||||
The name of the extension module is determined by two things:
|
||||
</p>
|
||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
||||
<li class="listitem">
|
||||
the name in <code class="computeroutput"><span class="identifier">Jamroot</span></code>
|
||||
immediately following <code class="computeroutput"><span class="identifier">python</span><span class="special">-</span><span class="identifier">extension</span></code>,
|
||||
and
|
||||
</li>
|
||||
<li class="listitem">
|
||||
the name passed to <code class="computeroutput"><span class="identifier">BOOST_PYTHON_MODULE</span></code>
|
||||
in <code class="computeroutput"><span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span></code>.
|
||||
</li>
|
||||
</ol></div>
|
||||
<p>
|
||||
To change the name of the extension module from <code class="computeroutput"><span class="identifier">extending</span></code>
|
||||
to <code class="computeroutput"><span class="identifier">hello</span></code>, you'd edit
|
||||
<code class="computeroutput"><span class="identifier">Jamroot</span></code>, changing
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">python</span><span class="special">-</span><span class="identifier">extension</span> <span class="identifier">extending</span> <span class="special">:</span> <span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span> <span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
to
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">python</span><span class="special">-</span><span class="identifier">extension</span> <span class="identifier">hello</span> <span class="special">:</span> <span class="identifier">extending</span><span class="special">.</span><span class="identifier">cpp</span> <span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
and you'd edit extending.cpp, changing
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">extending</span><span class="special">)</span>
|
||||
</pre>
|
||||
<p>
|
||||
to
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">hello</span><span class="special">)</span>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="background.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="installing_boost_python_on_your_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,47 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="testing_boost_python.html" title="Testing Boost.Python">
|
||||
<link rel="next" href="../configuration.html" title="Chapter 3. Configuration">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="testing_boost_python.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../configuration.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.notes_for_mingw_and_cygwin_with_"></a><a class="link" href="notes_for_mingw_and_cygwin_with_.html" title="Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users">Notes for
|
||||
MinGW (and Cygwin with -mno-cygwin) GCC Users</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
If you are using a version of Python prior to 2.4.1 with a MinGW prior to
|
||||
3.0.0 (with binutils-2.13.90-20030111-1), you will need to create a MinGW-compatible
|
||||
version of the Python library; the one shipped with Python will only work
|
||||
with a Microsoft-compatible linker. Follow the instructions in the “Non-Microsoft”
|
||||
section of the “Building Extensions: Tips And Tricks” chapter in <a href="https://docs.python.org/2/install/index.html" target="_top">Installing Python Modules</a>
|
||||
to create <code class="computeroutput"><span class="identifier">libpythonXX</span><span class="special">.</span><span class="identifier">a</span></code>, where <code class="computeroutput"><span class="identifier">XX</span></code>
|
||||
corresponds to the major and minor version numbers of your Python installation.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="testing_boost_python.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../configuration.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
78
develop/doc/html/building/python_debugging_builds.html
Normal file
@@ -0,0 +1,78 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Python Debugging Builds</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="include_issues.html" title="#include Issues">
|
||||
<link rel="next" href="testing_boost_python.html" title="Testing Boost.Python">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="include_issues.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="testing_boost_python.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.python_debugging_builds"></a><a class="link" href="python_debugging_builds.html" title="Python Debugging Builds">Python Debugging Builds</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Python can be built in a special “python debugging” configuration that
|
||||
adds extra checks and instrumentation that can be very useful for developers
|
||||
of extension modules. The data structures used by the debugging configuration
|
||||
contain additional members, so <span class="bold"><strong>a Python executable
|
||||
built with python debugging enabled cannot be used with an extension module
|
||||
or library compiled without it, and vice-versa.</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
Since pre-built “python debugging” versions of the Python executable
|
||||
and libraries are not supplied with most distributions of Python, <a href="#ftn.building.python_debugging_builds.f0" class="footnote" name="building.python_debugging_builds.f0"><sup class="footnote">[5]</sup></a> and we didn't want to force our users to build them, Boost.Build
|
||||
does not automatically enable python debugging in its <code class="computeroutput"><span class="identifier">debug</span></code>
|
||||
build variant (which is the default). Instead there is a special build property
|
||||
called <code class="computeroutput"><span class="identifier">python</span><span class="special">-</span><span class="identifier">debugging</span></code> that, when used as a build property,
|
||||
will define the right preprocessor symbols and select the right libraries
|
||||
to link with.
|
||||
</p>
|
||||
<p>
|
||||
On unix-variant platforms, the debugging versions of Python's data structures
|
||||
will only be used if the symbol <code class="computeroutput"><span class="identifier">Py_DEBUG</span></code>
|
||||
is defined. On many windows compilers, when extension modules are built with
|
||||
the preprocessor symbol <code class="computeroutput"><span class="identifier">_DEBUG</span></code>,
|
||||
Python defaults to force linking with a special debugging version of the
|
||||
Python DLL. Since that symbol is very commonly used even when Python is not
|
||||
present, Boost.Python temporarily undefines <code class="computeroutput"><span class="identifier">_DEBUG</span></code>
|
||||
when <code class="computeroutput"><span class="identifier">Python</span><span class="special">.</span><span class="identifier">h</span></code> is #included from <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">wrap_python</span><span class="special">.</span><span class="identifier">hpp</span></code> -
|
||||
unless <code class="computeroutput"><span class="identifier">BOOST_DEBUG_PYTHON</span></code>
|
||||
is defined. The upshot is that if you want “python debugging”and you
|
||||
aren't using Boost.Build, you should make sure <code class="computeroutput"><span class="identifier">BOOST_DEBUG_PYTHON</span></code>
|
||||
is defined, or python debugging will be suppressed.
|
||||
</p>
|
||||
<div class="footnotes">
|
||||
<br><hr style="width:100; text-align:left;margin-left: 0">
|
||||
<div id="ftn.building.python_debugging_builds.f0" class="footnote"><p><a href="#building.python_debugging_builds.f0" class="para"><sup class="para">[5] </sup></a>
|
||||
On Unix and similar platforms, a debugging python and associated libraries
|
||||
are built by adding --with-pydebug when configuring the Python build. On
|
||||
Windows, the debugging version of Python is generated by the "Win32
|
||||
Debug" target of the Visual Studio project in the PCBuild subdirectory
|
||||
of a full Python source code distribution.
|
||||
</p></div>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="include_issues.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="testing_boost_python.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
42
develop/doc/html/building/testing_boost_python.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Testing Boost.Python</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../building.html" title="Chapter 2. Building and Testing">
|
||||
<link rel="prev" href="python_debugging_builds.html" title="Python Debugging Builds">
|
||||
<link rel="next" href="notes_for_mingw_and_cygwin_with_.html" title="Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="python_debugging_builds.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="notes_for_mingw_and_cygwin_with_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="building.testing_boost_python"></a><a class="link" href="testing_boost_python.html" title="Testing Boost.Python">Testing Boost.Python</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
To run the full test suite for Boost.Python, invoke <code class="computeroutput"><span class="identifier">bjam</span></code>
|
||||
in the <code class="computeroutput"><span class="identifier">test</span></code> subdirectory
|
||||
of your Boost.Python distribution.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="python_debugging_builds.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="notes_for_mingw_and_cygwin_with_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
340
develop/doc/html/configuration.html
Normal file
@@ -0,0 +1,340 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 3. Configuration</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="up" href="index.html" title="Boost.Python">
|
||||
<link rel="prev" href="building/notes_for_mingw_and_cygwin_with_.html" title="Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users">
|
||||
<link rel="next" href="support.html" title="Chapter 4. Support Resources">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="building/notes_for_mingw_and_cygwin_with_.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="support.html"><img src="images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="chapter">
|
||||
<div class="titlepage"><div>
|
||||
<div><h1 class="title">
|
||||
<a name="configuration"></a>Chapter 3. Configuration</h1></div>
|
||||
<div><div class="authorgroup"><div class="author"><h3 class="author">
|
||||
<span class="firstname">David</span> <span class="surname">Abrahams</span>
|
||||
</h3></div></div></div>
|
||||
<div><p class="copyright">Copyright © 2002-2015 David Abrahams, Stefan Seefeld</p></div>
|
||||
</div></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="configuration.configuration"></a><a class="link" href="configuration.html#configuration.configuration" title="Configuration">Configuration</a>
|
||||
</h3></div></div></div>
|
||||
<div class="toc"><dl class="toc">
|
||||
<dt><span class="section"><a href="configuration.html#configuration.configuration.introduction">Introduction</a></span></dt>
|
||||
<dt><span class="section"><a href="configuration.html#configuration.configuration.application_defined_macros">Application
|
||||
Defined Macros</a></span></dt>
|
||||
<dt><span class="section"><a href="configuration.html#configuration.configuration.library_defined_defined_macros">Library
|
||||
Defined Defined Macros</a></span></dt>
|
||||
</dl></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="configuration.configuration.introduction"></a><a class="link" href="configuration.html#configuration.configuration.introduction" title="Introduction">Introduction</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
<span class="bold"><strong>Boost.Python</strong></span> uses several configuration
|
||||
macros in <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>, as well as configuration macros meant
|
||||
to be supplied by the application. These macros are documented here.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="configuration.configuration.application_defined_macros"></a><a class="link" href="configuration.html#configuration.configuration.application_defined_macros" title="Application Defined Macros">Application
|
||||
Defined Macros</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
These are the macros that may be defined by an application using Boost.Python.
|
||||
Note that if you extend a strict interpretation of the C++ standard to
|
||||
cover dynamic libraries, using different values of these macros when compiling
|
||||
different libraries (including extension modules and the Boost.Python library
|
||||
itself) is a violation of the <a class="link" href="glossary.html#odr">ODR</a>. However,
|
||||
we know of no C++ implementations on which this particular violation is
|
||||
detectable or causes any problems.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Macro
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Default
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Meaning
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_MAX_ARITY
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
15
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The maximum arity of any function, member function, or constructor
|
||||
to be wrapped, invocation of a Boost.Python function wich is
|
||||
specified as taking arguments x1, x2,...Xn. This includes, in
|
||||
particular, callback mechanisms such as object::operator()(...)
|
||||
or call_method<R>(... ).
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_MAX_BASES
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
10
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
The maximum number of template arguments to the <code class="computeroutput"><span class="identifier">bases</span><span class="special"><...></span></code>
|
||||
class template, which is used to specify the bases of a wrapped
|
||||
C++ class..
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_STATIC_MODULE
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="emphasis"><em>not defined</em></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
If defined, prevents your module initialization function from
|
||||
being treated as an exported symbol on platforms which support
|
||||
that distinction in-code
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_ENABLE_CDECL
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="emphasis"><em>not defined</em></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
If defined, allows functions using the <code class="computeroutput"><span class="identifier">__cdecl</span></code>
|
||||
calling convention to be wrapped.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_ENABLE_STDCALL
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="emphasis"><em>not defined</em></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
If defined, allows functions using the <code class="computeroutput"><span class="identifier">__stdcall</span></code>
|
||||
calling convention to be wrapped.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_ENABLE_FASTCALL
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="emphasis"><em>not defined</em></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
If defined, allows functions using the <code class="computeroutput"><span class="identifier">__fastcall</span></code>
|
||||
calling convention to be wrapped.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="configuration.configuration.library_defined_defined_macros"></a><a class="link" href="configuration.html#configuration.configuration.library_defined_defined_macros" title="Library Defined Defined Macros">Library
|
||||
Defined Defined Macros</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
These macros are defined by <span class="bold"><strong>Boost.Python</strong></span>
|
||||
and are implementation details of interest only to implementors and those
|
||||
porting to new platforms.
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Macro
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Default
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Meaning
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_TYPE_ID_NAME
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="emphasis"><em>not defined</em></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
If defined, this indicates that the type_info comparison across
|
||||
shared library boundaries does not work on this platform. In
|
||||
other words, if shared-lib-1 passes <code class="computeroutput"><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code> to a function in shared-lib-2
|
||||
which compares it to <code class="computeroutput"><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code>, that comparison may return
|
||||
<code class="computeroutput"><span class="keyword">false</span></code>. If this macro
|
||||
is #defined, Boost.Python uses and compares <code class="computeroutput"><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">).</span><span class="identifier">name</span><span class="special">()</span></code> instead of using and comparing
|
||||
the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">type_info</span></code> objects directly.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="emphasis"><em>not defined</em></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
If defined for a module no pythonic signatures are generated
|
||||
for the docstrings of the module functions, and no python type
|
||||
is associated with any of the converters registered by the module.
|
||||
This also reduces the binary size of the module by about 14%
|
||||
(gcc compiled). If defined for the boost_python runtime library,
|
||||
the default for the <code class="computeroutput"><span class="identifier">docstring_options</span><span class="special">.</span><span class="identifier">enable_py_signatures</span><span class="special">()</span></code> is set to <code class="computeroutput"><span class="keyword">false</span></code>.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_SUPPORTS_PY_SIGNATURES
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="emphasis"><em>defined</em></span> if <code class="computeroutput"><span class="identifier">BOOST_PYTHON_NO_PY_SIGNATURES</span></code>
|
||||
is <span class="emphasis"><em>undefined</em></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
This macro is defined to enable a smooth transition from older
|
||||
Boost.Python versions which do not support pythonic signatures.
|
||||
For example usage see here.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="emphasis"><em>not defined</em></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
If defined the python type of <code class="computeroutput"><span class="identifier">__init__</span></code>
|
||||
method "self" parameters is properly generated, otherwise
|
||||
object is used. It is undefined by default because it increases
|
||||
the binary size of the module by about 14% (gcc compiled).
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="building/notes_for_mingw_and_cygwin_with_.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="support.html"><img src="images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
84
develop/doc/html/faq.html
Normal file
@@ -0,0 +1,84 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 5. Frequently Asked Questions (FAQs)</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="up" href="index.html" title="Boost.Python">
|
||||
<link rel="prev" href="support.html" title="Chapter 4. Support Resources">
|
||||
<link rel="next" href="faq/i_m_getting_the_attempt_to_retur.html" title="I'm getting the "attempt to return dangling reference" error. What am I doing wrong?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="support.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="faq/i_m_getting_the_attempt_to_retur.html"><img src="images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="chapter">
|
||||
<div class="titlepage"><div><div><h1 class="title">
|
||||
<a name="faq"></a>Chapter 5. Frequently Asked Questions (FAQs)</h1></div></div></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.how_can_i_wrap_a_function_which_"></a><a class="link" href="faq.html#faq.how_can_i_wrap_a_function_which_" title="How can I wrap a function which takes a function pointer as an argument?">How can I wrap
|
||||
a function which takes a function pointer as an argument?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
If what you're trying to do is something like this:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</span><span class="keyword">void</span> <span class="special">(</span><span class="identifier">string</span> <span class="identifier">s</span><span class="special">)</span> <span class="special">></span> <span class="identifier">funcptr</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">funcptr</span> <span class="identifier">fp</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">fp</span><span class="special">(</span><span class="string">"hello,world!"</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
|
||||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">test</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span><span class="identifier">foo</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
And then:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">>>></span> <span class="identifier">def</span> <span class="identifier">hello</span><span class="special">(</span><span class="identifier">s</span><span class="special">):</span>
|
||||
<span class="special">...</span> <span class="identifier">print</span> <span class="identifier">s</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">>>></span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">hello</span><span class="special">)</span>
|
||||
<span class="identifier">hello</span><span class="special">,</span> <span class="identifier">world</span><span class="special">!</span>
|
||||
</pre>
|
||||
<p>
|
||||
The short answer is: "you can't". This is not a Boost.Python limitation
|
||||
so much as a limitation of C++. The problem is that a Python function is
|
||||
actually data, and the only way of associating data with a C++ function pointer
|
||||
is to store it in a static variable of the function. The problem with that
|
||||
is that you can only associate one piece of data with every C++ function,
|
||||
and we have no way of compiling a new C++ function on-the-fly for every Python
|
||||
function you decide to pass to <code class="computeroutput"><span class="identifier">foo</span></code>.
|
||||
In other words, this could work if the C++ function is always going to invoke
|
||||
the <span class="emphasis"><em>same</em></span> Python function, but you probably don't want
|
||||
that.
|
||||
</p>
|
||||
<p>
|
||||
If you have the luxury of changing the C++ code you're wrapping, pass it
|
||||
an <code class="computeroutput"><span class="identifier">object</span></code> instead and call
|
||||
that; the overloaded function call operator will invoke the Python function
|
||||
you pass it behind the <code class="computeroutput"><span class="identifier">object</span></code>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="support.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="faq/i_m_getting_the_attempt_to_retur.html"><img src="images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
42
develop/doc/html/faq/compilation_takes_too_much_time_.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Compilation takes too much time and eats too much memory! What can I do to make it faster?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_can_i_wrap_a_function_which0.html" title="How can I wrap a function which needs to take ownership of a raw pointer?">
|
||||
<link rel="next" href="how_do_i_create_sub_packages_usi.html" title="How do I create sub-packages using Boost.Python?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_can_i_wrap_a_function_which0.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_do_i_create_sub_packages_usi.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.compilation_takes_too_much_time_"></a><a class="link" href="compilation_takes_too_much_time_.html" title="Compilation takes too much time and eats too much memory! What can I do to make it faster?">Compilation takes
|
||||
too much time and eats too much memory! What can I do to make it faster?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Please refer to the <code class="computeroutput"><span class="identifier">Reducing</span> <span class="identifier">Compiling</span> <span class="identifier">Time</span></code>
|
||||
section in the <a href="../tutorial/index.html" target="_top">Tutorial</a>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_can_i_wrap_a_function_which0.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_do_i_create_sub_packages_usi.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
93
develop/doc/html/faq/does_boost_python_work_with_mac_.html
Normal file
@@ -0,0 +1,93 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Does Boost.Python work with Mac OS X?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">
|
||||
<link rel="next" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="why_doesn_t_my_operator_work.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_find_the_existing_pyob.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.does_boost_python_work_with_mac_"></a><a class="link" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">Does Boost.Python
|
||||
work with Mac OS X?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
It is known to work under 10.2.8 and 10.3 using Apple's gcc 3.3 compiler:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">gcc</span> <span class="special">(</span><span class="identifier">GCC</span><span class="special">)</span> <span class="number">3.3</span> <span class="number">20030304</span> <span class="special">(</span><span class="identifier">Apple</span> <span class="identifier">Computer</span><span class="special">,</span> <span class="identifier">Inc</span><span class="special">.</span> <span class="identifier">build</span> <span class="number">1493</span><span class="special">)</span></pre>
|
||||
<p>
|
||||
Under 10.2.8 get the August 2003 gcc update (free at <a href="http://connect.apple.com" target="_top">http://connect.apple.com</a>).
|
||||
Under 10.3 get the Xcode Tools v1.0 (also free).
|
||||
</p>
|
||||
<p>
|
||||
Python 2.3 is required. The Python that ships with 10.3 is fine. Under 10.2.8
|
||||
use these commands to install Python as a framework:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">./</span><span class="identifier">configure</span> <span class="special">--</span><span class="identifier">enable</span><span class="special">-</span><span class="identifier">framework</span>
|
||||
<span class="identifier">make</span>
|
||||
<span class="identifier">make</span> <span class="identifier">frameworkinstall</span></pre>
|
||||
<p>
|
||||
The last command requires root privileges because the target directory is
|
||||
<code class="computeroutput"><span class="special">/</span><span class="identifier">Library</span><span class="special">/</span><span class="identifier">Frameworks</span><span class="special">/</span><span class="identifier">Python</span><span class="special">.</span><span class="identifier">framework</span><span class="special">/</span><span class="identifier">Versions</span><span class="special">/</span><span class="number">2.3</span></code>. However,
|
||||
the installation does not interfere with the Python version that ships with
|
||||
10.2.8.
|
||||
</p>
|
||||
<p>
|
||||
It is also crucial to increase the <code class="computeroutput"><span class="identifier">stacksize</span></code>
|
||||
before starting compilations, e.g.:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">limit</span> <span class="identifier">stacksize</span> <span class="number">8192</span><span class="identifier">k</span></pre>
|
||||
<p>
|
||||
If the <code class="computeroutput"><span class="identifier">stacksize</span></code> is too small
|
||||
the build might crash with internal compiler errors.
|
||||
</p>
|
||||
<p>
|
||||
Sometimes Apple's compiler exhibits a bug by printing an error like the following
|
||||
while compiling a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">class_</span><span class="special"><</span><span class="identifier">your_type</span><span class="special">></span></code>
|
||||
template instantiation:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">.../</span><span class="identifier">inheritance</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">:</span><span class="number">44</span><span class="special">:</span> <span class="identifier">error</span><span class="special">:</span> <span class="identifier">cannot</span>
|
||||
<span class="keyword">dynamic_cast</span> <span class="error">`</span><span class="identifier">p</span><span class="char">' (of type `struct cctbx::boost_python::<unnamed>::add_pair*
|
||||
'</span><span class="special">)</span> <span class="identifier">to</span> <span class="identifier">type</span> <span class="error">`</span><span class="keyword">void</span><span class="special">*</span><span class="error">'</span> <span class="special">(</span><span class="identifier">source</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="keyword">not</span> <span class="identifier">polymorphic</span><span class="special">)</span>
|
||||
</pre>
|
||||
<p>
|
||||
We do not know a general workaround, but if the definition of <code class="computeroutput"><span class="identifier">your_type</span></code> can be modified the following
|
||||
was found to work in all cases encountered so far:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">your_type</span>
|
||||
<span class="special">{</span>
|
||||
<span class="comment">// before defining any member data</span>
|
||||
<span class="preprocessor">#if</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">__MACH__</span><span class="special">)</span> <span class="special">&</span><span class="identifier">amp</span><span class="special">;&</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">__APPLE_CC__</span><span class="special">)</span> <span class="special">&</span><span class="identifier">amp</span><span class="special">;&</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">__APPLE_CC__</span> <span class="special">==</span> <span class="number">1493</span>
|
||||
<span class="keyword">bool</span> <span class="identifier">dummy_</span><span class="special">;</span>
|
||||
<span class="preprocessor">#endif</span>
|
||||
<span class="comment">// now your member data, e.g.</span>
|
||||
<span class="keyword">double</span> <span class="identifier">x</span><span class="special">;</span>
|
||||
<span class="keyword">int</span> <span class="identifier">j</span><span class="special">;</span>
|
||||
<span class="comment">// etc.</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="why_doesn_t_my_operator_work.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_find_the_existing_pyob.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
77
develop/doc/html/faq/error_c2064_term_does_not_evalua.html
Normal file
@@ -0,0 +1,77 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>error C2064: term does not evaluate to a function taking 2 arguments</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_do_i_create_sub_packages_usi.html" title="How do I create sub-packages using Boost.Python?">
|
||||
<link rel="next" href="how_can_i_automatically_convert_.html" title="How can I automatically convert my custom string type to and from a Python string?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_do_i_create_sub_packages_usi.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_automatically_convert_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.error_c2064_term_does_not_evalua"></a><a class="link" href="error_c2064_term_does_not_evalua.html" title="error C2064: term does not evaluate to a function taking 2 arguments">error C2064: term
|
||||
does not evaluate to a function taking 2 arguments</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<span class="emphasis"><em>Niall Douglas provides these notes:</em></span>
|
||||
</p>
|
||||
<p>
|
||||
If you see Microsoft Visual C++ 7.1 (MS Visual Studio .NET 2003) issue an
|
||||
error message like the following it is most likely due to a bug in the compiler:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">boost</span><span class="special">\</span><span class="identifier">boost</span><span class="special">\</span><span class="identifier">python</span><span class="special">\</span><span class="identifier">detail</span><span class="special">\</span><span class="identifier">invoke</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">(</span><span class="number">76</span><span class="special">):</span>
|
||||
<span class="identifier">error</span> <span class="identifier">C2064</span><span class="special">:</span> <span class="identifier">term</span> <span class="identifier">does</span> <span class="keyword">not</span> <span class="identifier">evaluate</span> <span class="identifier">to</span> <span class="identifier">a</span> <span class="identifier">function</span> <span class="identifier">taking</span> <span class="number">2</span> <span class="identifier">arguments</span><span class="error">"</span>
|
||||
</pre>
|
||||
<p>
|
||||
This message is triggered by code like the following:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
|
||||
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">class</span> <span class="identifier">FXThread</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">bool</span> <span class="identifier">setAutoDelete</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">doso</span><span class="special">)</span> <span class="keyword">throw</span><span class="special">();</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">void</span> <span class="identifier">Export_FXThread</span><span class="special">()</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">class_</span><span class="special"><</span> <span class="identifier">FXThread</span> <span class="special">>(</span><span class="string">"FXThread"</span><span class="special">)</span>
|
||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"setAutoDelete"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">amp</span><span class="special">;</span><span class="identifier">FXThread</span><span class="special">::</span><span class="identifier">setAutoDelete</span><span class="special">)</span>
|
||||
<span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
The bug is related to the <code class="computeroutput"><span class="keyword">throw</span><span class="special">()</span></code> modifier. As a workaround cast off the
|
||||
modifier. E.g.:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"setAutoDelete"</span><span class="special">,</span> <span class="special">(</span><span class="keyword">bool</span> <span class="special">(</span><span class="identifier">FXThread</span><span class="special">::*)(</span><span class="keyword">bool</span><span class="special">))</span> <span class="special">&</span><span class="identifier">FXThread</span><span class="special">::</span><span class="identifier">setAutoDelete</span><span class="special">)</span>
|
||||
</pre>
|
||||
<p>
|
||||
(The bug has been reported to Microsoft.)
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_do_i_create_sub_packages_usi.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_automatically_convert_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
94
develop/doc/html/faq/fatal_error_c1204_compiler_limit.html
Normal file
@@ -0,0 +1,94 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>fatal error C1204:Compiler limit:internal structure overflow</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_can_i_wrap_functions_which_t.html" title="How can I wrap functions which take C++ containers as arguments?">
|
||||
<link rel="next" href="how_do_i_debug_my_python_extensi.html" title="How do I debug my Python extensions?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_can_i_wrap_functions_which_t.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_do_i_debug_my_python_extensi.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.fatal_error_c1204_compiler_limit"></a><a class="link" href="fatal_error_c1204_compiler_limit.html" title="fatal error C1204:Compiler limit:internal structure overflow">fatal error C1204:Compiler
|
||||
limit:internal structure overflow</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<span class="bold"><strong>Q:</strong></span> <span class="emphasis"><em>I get this error message when
|
||||
compiling a large source file. What can I do?</em></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>A:</strong></span> You have two choices:
|
||||
</p>
|
||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
||||
<li class="listitem">
|
||||
Upgrade your compiler (preferred)
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Break your source file up into multiple translation units.
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">my_module</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">...</span>
|
||||
<span class="keyword">void</span> <span class="identifier">more_of_my_module</span><span class="special">();</span>
|
||||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">my_module</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span> <span class="identifier">foo</span><span class="special">);</span>
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,</span> <span class="identifier">bar</span><span class="special">);</span>
|
||||
<span class="special">...</span>
|
||||
<span class="identifier">more_of_my_module</span><span class="special">();</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">more_of_my_module</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">more_of_my_module</span><span class="special">()</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"baz"</span><span class="special">,</span> <span class="identifier">baz</span><span class="special">);</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
If you find that a <code class="computeroutput"><span class="identifier">class_</span><span class="special"><...></span></code> declaration can't fit in
|
||||
a single source file without triggering the error, you can always pass
|
||||
a reference to the <code class="computeroutput"><span class="identifier">class_</span></code>
|
||||
object to a function in another source file, and call some of its member
|
||||
functions (e.g. <code class="computeroutput"><span class="special">.</span><span class="identifier">def</span><span class="special">(...)</span></code>) in the auxilliary source file:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">more_of_my_class</span><span class="special">.</span><span class="identifier">cpp</span></code>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">more_of_my_class</span><span class="special">(</span><span class="keyword">class</span><span class="special">&</span><span class="identifier">lt</span><span class="special">;</span><span class="identifier">my_class</span><span class="special">&</span><span class="identifier">gt</span><span class="special">;&</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">x</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">x</span>
|
||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"baz"</span><span class="special">,</span> <span class="identifier">baz</span><span class="special">)</span>
|
||||
<span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"xx"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">my_class</span><span class="special">::</span><span class="identifier">get_xx</span><span class="special">,</span> <span class="special">&</span><span class="identifier">my_class</span><span class="special">::</span><span class="identifier">set_xx</span><span class="special">)</span>
|
||||
<span class="special">;</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
</li>
|
||||
</ol></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_can_i_wrap_functions_which_t.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_do_i_debug_my_python_extensi.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
146
develop/doc/html/faq/how_can_i_automatically_convert_.html
Normal file
@@ -0,0 +1,146 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How can I automatically convert my custom string type to and from a Python string?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="error_c2064_term_does_not_evalua.html" title="error C2064: term does not evaluate to a function taking 2 arguments">
|
||||
<link rel="next" href="why_is_my_automatic_to_python_co.html" title="Why is my automatic to-python conversion not being found?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="error_c2064_term_does_not_evalua.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="why_is_my_automatic_to_python_co.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.how_can_i_automatically_convert_"></a><a class="link" href="how_can_i_automatically_convert_.html" title="How can I automatically convert my custom string type to and from a Python string?">How can I automatically
|
||||
convert my custom string type to and from a Python string?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<span class="emphasis"><em>Ralf W. Grosse-Kunstleve provides these notes:</em></span>
|
||||
</p>
|
||||
<p>
|
||||
Below is a small, self-contained demo extension module that shows how to
|
||||
do this. Here is the corresponding trivial test:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">import</span> <span class="identifier">custom_string</span>
|
||||
<span class="identifier">assert</span> <span class="identifier">custom_string</span><span class="special">.</span><span class="identifier">hello</span><span class="special">()</span> <span class="special">==</span> <span class="string">"Hello world."</span>
|
||||
<span class="identifier">assert</span> <span class="identifier">custom_string</span><span class="special">.</span><span class="identifier">size</span><span class="special">(</span><span class="string">"california"</span><span class="special">)</span> <span class="special">==</span> <span class="number">10</span>
|
||||
</pre>
|
||||
<p>
|
||||
If you look at the code you will find:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
A custom <code class="computeroutput"><span class="identifier">to_python</span></code> converter
|
||||
(easy): <code class="computeroutput"><span class="identifier">custom_string_to_python_str</span></code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
A custom lvalue converter (needs more code): <code class="computeroutput"><span class="identifier">custom_string_from_python_str</span></code>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The custom converters are registered in the global Boost.Python registry
|
||||
near the top of the module initialization function. Once flow control has
|
||||
passed through the registration code the automatic conversions from and to
|
||||
Python strings will work in any module imported in the same process.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">def</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">to_python_converter</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
|
||||
<span class="keyword">namespace</span> <span class="identifier">sandbox</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="special">{</span>
|
||||
|
||||
<span class="keyword">class</span> <span class="identifier">custom_string</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="identifier">custom_string</span><span class="special">()</span> <span class="special">{}</span>
|
||||
<span class="identifier">custom_string</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">value_</span><span class="special">(</span><span class="identifier">value</span><span class="special">)</span> <span class="special">{}</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">value_</span><span class="special">;</span> <span class="special">}</span>
|
||||
<span class="keyword">private</span><span class="special">:</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">value_</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">struct</span> <span class="identifier">custom_string_to_python_str</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">static</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">convert</span><span class="special">(</span><span class="identifier">custom_string</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">s</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">incref</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">value</span><span class="special">()).</span><span class="identifier">ptr</span><span class="special">());</span>
|
||||
<span class="special">}</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">struct</span> <span class="identifier">custom_string_from_python_str</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">custom_string_from_python_str</span><span class="special">()</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">converter</span><span class="special">::</span><span class="identifier">registry</span><span class="special">::</span><span class="identifier">push_back</span><span class="special">(</span>
|
||||
<span class="special">&</span><span class="identifier">convertible</span><span class="special">,</span>
|
||||
<span class="special">&</span><span class="identifier">construct</span><span class="special">,</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">type_id</span><span class="special"><</span><span class="identifier">custom_string</span><span class="special">>());</span>
|
||||
<span class="special">}</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">convertible</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">obj_ptr</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">if</span> <span class="special">(!</span><span class="identifier">PyString_Check</span><span class="special">(</span><span class="identifier">obj_ptr</span><span class="special">))</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
|
||||
<span class="keyword">return</span> <span class="identifier">obj_ptr</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">construct</span><span class="special">(</span>
|
||||
<span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">obj_ptr</span><span class="special">,</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">converter</span><span class="special">::</span><span class="identifier">rvalue_from_python_stage1_data</span><span class="special">*</span> <span class="identifier">data</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">value</span> <span class="special">=</span> <span class="identifier">PyString_AsString</span><span class="special">(</span><span class="identifier">obj_ptr</span><span class="special">);</span>
|
||||
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">value</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">throw_error_already_set</span><span class="special">();</span>
|
||||
<span class="keyword">void</span><span class="special">*</span> <span class="identifier">storage</span> <span class="special">=</span> <span class="special">(</span>
|
||||
<span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">converter</span><span class="special">::</span><span class="identifier">rvalue_from_python_storage</span><span class="special"><</span><span class="identifier">custom_string</span><span class="special">>*)</span>
|
||||
<span class="identifier">data</span><span class="special">)-></span><span class="identifier">storage</span><span class="special">.</span><span class="identifier">bytes</span><span class="special">;</span>
|
||||
<span class="keyword">new</span> <span class="special">(</span><span class="identifier">storage</span><span class="special">)</span> <span class="identifier">custom_string</span><span class="special">(</span><span class="identifier">value</span><span class="special">);</span>
|
||||
<span class="identifier">data</span><span class="special">-></span><span class="identifier">convertible</span> <span class="special">=</span> <span class="identifier">storage</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="identifier">custom_string</span> <span class="identifier">hello</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">custom_string</span><span class="special">(</span><span class="string">"Hello world."</span><span class="special">);</span> <span class="special">}</span>
|
||||
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">(</span><span class="identifier">custom_string</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">s</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">value</span><span class="special">().</span><span class="identifier">size</span><span class="special">();</span> <span class="special">}</span>
|
||||
|
||||
<span class="keyword">void</span> <span class="identifier">init_module</span><span class="special">()</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">to_python_converter</span><span class="special"><</span>
|
||||
<span class="identifier">custom_string</span><span class="special">,</span>
|
||||
<span class="identifier">custom_string_to_python_str</span><span class="special">>();</span>
|
||||
|
||||
<span class="identifier">custom_string_from_python_str</span><span class="special">();</span>
|
||||
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"hello"</span><span class="special">,</span> <span class="identifier">hello</span><span class="special">);</span>
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"size"</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespace sandbox::<anonymous></span>
|
||||
|
||||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">custom_string</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">sandbox</span><span class="special">::</span><span class="identifier">init_module</span><span class="special">();</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="error_c2064_term_does_not_evalua.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="why_is_my_automatic_to_python_co.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
103
develop/doc/html/faq/how_can_i_find_the_existing_pyob.html
Normal file
@@ -0,0 +1,103 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How can I find the existing PyObject that holds a C++ object?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">
|
||||
<link rel="next" href="how_can_i_wrap_a_function_which0.html" title="How can I wrap a function which needs to take ownership of a raw pointer?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="does_boost_python_work_with_mac_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_wrap_a_function_which0.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.how_can_i_find_the_existing_pyob"></a><a class="link" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">How can I find
|
||||
the existing PyObject that holds a C++ object?</a>
|
||||
</h3></div></div></div>
|
||||
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||
"I am wrapping a function that always returns a pointer to an already-held
|
||||
C++ object."
|
||||
</p></blockquote></div>
|
||||
<p>
|
||||
One way to do that is to hijack the mechanisms used for wrapping a class
|
||||
with virtual functions. If you make a wrapper class with an initial PyObject*
|
||||
constructor argument and store that PyObject* as "self", you can
|
||||
get back to it by casting down to that wrapper type in a thin wrapper function.
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">X</span> <span class="special">{</span> <span class="identifier">X</span><span class="special">(</span><span class="keyword">int</span><span class="special">);</span> <span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">X</span><span class="special">();</span> <span class="special">...</span> <span class="special">};</span>
|
||||
<span class="identifier">X</span><span class="special">*</span> <span class="identifier">f</span><span class="special">();</span> <span class="comment">// known to return Xs that are managed by Python objects</span>
|
||||
|
||||
|
||||
<span class="comment">// wrapping code</span>
|
||||
|
||||
<span class="keyword">struct</span> <span class="identifier">X_wrap</span> <span class="special">:</span> <span class="identifier">X</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">X_wrap</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">self</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">v</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">self</span><span class="special">(</span><span class="identifier">self</span><span class="special">),</span> <span class="identifier">X</span><span class="special">(</span><span class="identifier">v</span><span class="special">)</span> <span class="special">{}</span>
|
||||
<span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">self</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="identifier">handle</span><span class="special"><></span> <span class="identifier">f_wrap</span><span class="special">()</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">X_wrap</span><span class="special">*</span> <span class="identifier">xw</span> <span class="special">=</span> <span class="keyword">dynamic_cast</span><span class="special"><</span><span class="identifier">X_wrap</span><span class="special">*>(</span><span class="identifier">f</span><span class="special">());</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">xw</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span>
|
||||
<span class="keyword">return</span> <span class="identifier">handle</span><span class="special"><>(</span><span class="identifier">borrowed</span><span class="special">(</span><span class="identifier">xw</span><span class="special">-></span><span class="identifier">self</span><span class="special">));</span>
|
||||
<span class="special">}</span>
|
||||
|
||||
<span class="special">...</span>
|
||||
|
||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"f"</span><span class="special">,</span> <span class="identifier">f_wrap</span><span class="special">());</span>
|
||||
<span class="identifier">class_</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="identifier">X_wrap</span><span class="special">,</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span><span class="special">>(</span><span class="string">"X"</span><span class="special">,</span> <span class="identifier">init</span><span class="special"><</span><span class="keyword">int</span><span class="special">>())</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Of course, if X has no virtual functions you'll have to use <code class="computeroutput"><span class="keyword">static_cast</span></code> instead of <code class="computeroutput"><span class="keyword">dynamic_cast</span></code>
|
||||
with no runtime check that it's valid. This approach also only works if the
|
||||
<code class="computeroutput"><span class="identifier">X</span></code> object was constructed
|
||||
from Python, because <code class="computeroutput"><span class="identifier">X</span></code>s constructed
|
||||
from C++ are of course never <code class="computeroutput"><span class="identifier">X_wrap</span></code>
|
||||
objects.
|
||||
</p>
|
||||
<p>
|
||||
Another approach to this requires you to change your C++ code a bit; if that's
|
||||
an option for you it might be a better way to go. work we've been meaning
|
||||
to get to anyway. When a <code class="computeroutput"><span class="identifier">shared_ptr</span><span class="special"><</span><span class="identifier">X</span><span class="special">></span></code>
|
||||
is converted from Python, the shared_ptr actually manages a reference to
|
||||
the containing Python object. When a shared_ptr<X> is converted back
|
||||
to Python, the library checks to see if it's one of those "Python object
|
||||
managers" and if so just returns the original Python object. So you
|
||||
could just write <code class="computeroutput"><span class="identifier">object</span><span class="special">(</span><span class="identifier">p</span><span class="special">)</span></code> to get
|
||||
the Python object back. To exploit this you'd have to be able to change the
|
||||
C++ code you're wrapping so that it deals with shared_ptr instead of raw
|
||||
pointers.
|
||||
</p>
|
||||
<p>
|
||||
There are other approaches too. The functions that receive the Python object
|
||||
that you eventually want to return could be wrapped with a thin wrapper that
|
||||
records the correspondence between the object address and its containing
|
||||
Python object, and you could have your f_wrap function look in that mapping
|
||||
to get the Python object out.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="does_boost_python_work_with_mac_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_wrap_a_function_which0.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
86
develop/doc/html/faq/how_can_i_wrap_a_function_which0.html
Normal file
@@ -0,0 +1,86 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How can I wrap a function which needs to take ownership of a raw pointer?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">
|
||||
<link rel="next" href="compilation_takes_too_much_time_.html" title="Compilation takes too much time and eats too much memory! What can I do to make it faster?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_can_i_find_the_existing_pyob.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="compilation_takes_too_much_time_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.how_can_i_wrap_a_function_which0"></a><a class="link" href="how_can_i_wrap_a_function_which0.html" title="How can I wrap a function which needs to take ownership of a raw pointer?">How can I wrap
|
||||
a function which needs to take ownership of a raw pointer?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<span class="bold"><strong>Q:</strong></span> Part of an API that I'm wrapping goes
|
||||
something like this:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">A</span> <span class="special">{};</span> <span class="keyword">struct</span> <span class="identifier">B</span> <span class="special">{</span> <span class="keyword">void</span> <span class="identifier">add</span><span class="special">(</span> <span class="identifier">A</span><span class="special">*</span> <span class="special">);</span> <span class="special">}</span>
|
||||
<span class="identifier">where</span> <span class="identifier">B</span><span class="special">::</span><span class="identifier">add</span><span class="special">()</span> <span class="identifier">takes</span> <span class="identifier">ownership</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">pointer</span> <span class="identifier">passed</span> <span class="identifier">to</span> <span class="identifier">it</span><span class="special">.</span>
|
||||
</pre>
|
||||
<p>
|
||||
However:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">a</span> <span class="special">=</span> <span class="identifier">mod</span><span class="special">.</span><span class="identifier">A</span><span class="special">()</span>
|
||||
<span class="identifier">b</span> <span class="special">=</span> <span class="identifier">mod</span><span class="special">.</span><span class="identifier">B</span><span class="special">()</span>
|
||||
<span class="identifier">b</span><span class="special">.</span><span class="identifier">add</span><span class="special">(</span> <span class="identifier">a</span> <span class="special">)</span>
|
||||
<span class="identifier">del</span> <span class="identifier">a</span>
|
||||
<span class="identifier">del</span> <span class="identifier">b</span>
|
||||
<span class="preprocessor"># python</span> <span class="identifier">interpreter</span> <span class="identifier">crashes</span>
|
||||
<span class="preprocessor"># later</span> <span class="identifier">due</span> <span class="identifier">to</span> <span class="identifier">memory</span> <span class="identifier">corruption</span><span class="special">.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Even binding the lifetime of a to b via <code class="computeroutput"><span class="identifier">with_custodian_and_ward</span></code>
|
||||
doesn't prevent the python object a from ultimately trying to delete the
|
||||
object it's pointing to. Is there a way to accomplish a 'transfer-of-ownership'
|
||||
of a wrapped C++ object?
|
||||
</p>
|
||||
<p>
|
||||
--Bruce Lowery
|
||||
</p>
|
||||
<p>
|
||||
Yes: Make sure the C++ object is held by auto_ptr:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">class_</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special"><</span><span class="identifier">A</span><span class="special">></span> <span class="special">>(</span><span class="string">"A"</span><span class="special">)</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Then make a thin wrapper function which takes an auto_ptr parameter:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">b_insert</span><span class="special">(</span><span class="identifier">B</span> <span class="special">&</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special"><</span><span class="identifier">A</span><span class="special">></span> <span class="identifier">a</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">b</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">a</span><span class="special">.</span><span class="identifier">get</span><span class="special">());</span>
|
||||
<span class="identifier">a</span><span class="special">.</span><span class="identifier">release</span><span class="special">();</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
Wrap that as B.add. Note that pointers returned via <code class="computeroutput"><span class="identifier">manage_new_object</span></code>
|
||||
will also be held by <code class="computeroutput"><span class="identifier">auto_ptr</span></code>,
|
||||
so this transfer-of-ownership will also work correctly.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_can_i_find_the_existing_pyob.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="compilation_takes_too_much_time_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
120
develop/doc/html/faq/how_can_i_wrap_functions_which_t.html
Normal file
@@ -0,0 +1,120 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How can I wrap functions which take C++ containers as arguments?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="is_return_internal_reference_eff.html" title="Is return_internal_reference efficient?">
|
||||
<link rel="next" href="fatal_error_c1204_compiler_limit.html" title="fatal error C1204:Compiler limit:internal structure overflow">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="is_return_internal_reference_eff.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="fatal_error_c1204_compiler_limit.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.how_can_i_wrap_functions_which_t"></a><a class="link" href="how_can_i_wrap_functions_which_t.html" title="How can I wrap functions which take C++ containers as arguments?">How can I wrap
|
||||
functions which take C++ containers as arguments?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Ralf W. Grosse-Kunstleve provides these notes:
|
||||
</p>
|
||||
<div class="orderedlist"><ol class="orderedlist" type="1">
|
||||
<li class="listitem">
|
||||
<p>
|
||||
Using the regular <code class="computeroutput"><span class="identifier">class_</span><span class="special"><></span></code> wrapper:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">class_</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">>(</span><span class="string">"std_vector_double"</span><span class="special">)</span>
|
||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(...)</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">;</span>
|
||||
</pre>
|
||||
This can be moved to a template so that several types (<code class="computeroutput"><span class="keyword">double</span></code>, <code class="computeroutput"><span class="keyword">int</span></code>,
|
||||
<code class="computeroutput"><span class="keyword">long</span></code>, etc.) can be wrapped
|
||||
with the same code. This technique is used in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">array_family</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">flex_wrapper</span><span class="special">.</span><span class="identifier">h</span></code> in the "scitbx" package.
|
||||
The file could easily be modified for wrapping <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code> instantiations. This type of
|
||||
C++/Python binding is most suitable for containers that may contain a
|
||||
large number of elements (>10000).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p>
|
||||
Using custom rvalue converters. Boost.Python "rvalue converters"
|
||||
match function signatures such as:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">array</span><span class="special">);</span> <span class="comment">// pass by const-reference</span>
|
||||
<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">array</span><span class="special">);</span> <span class="comment">// pass by value</span>
|
||||
</pre>
|
||||
Some custom rvalue converters are implemented in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">container_conversions</span><span class="special">.</span><span class="identifier">h</span></code> This code can be used to convert
|
||||
from C++ container types such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code> or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><></span></code> to Python tuples and vice versa.
|
||||
A few simple examples can be found in the file <code class="computeroutput"><span class="identifier">scitbx</span><span class="special">/</span><span class="identifier">array_family</span><span class="special">/</span><span class="identifier">boost_python</span><span class="special">/</span><span class="identifier">regression_test_module</span><span class="special">.</span><span class="identifier">cpp</span></code>
|
||||
Automatic C++ container <-> Python tuple conversions are most suitable
|
||||
for containers of moderate size. These converters generate significantly
|
||||
less object code compared to alternative 1 above.
|
||||
</li>
|
||||
</ol></div>
|
||||
<p>
|
||||
A disadvantage of using alternative 2 is that operators such as arithmetic
|
||||
+,-,*,/,% are not available. It would be useful to have custom rvalue converters
|
||||
that convert to a "math_array" type instead of tuples. This is
|
||||
currently not implemented but is possible within the framework of Boost.Python
|
||||
V2 as it will be released in the next couple of weeks. [ed.: this was posted
|
||||
on 2002/03/10]
|
||||
</p>
|
||||
<p>
|
||||
It would also be useful to also have "custom lvalue converters"
|
||||
such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code>
|
||||
<-> Python list. These converters would support the modification of
|
||||
the Python list from C++. For example:
|
||||
</p>
|
||||
<p>
|
||||
C++:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">&</span><span class="identifier">array</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">for</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span><span class="identifier">i</span><span class="special">&</span><span class="identifier">lt</span><span class="special">;</span><span class="identifier">array</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span><span class="identifier">i</span><span class="special">++)</span> <span class="special">{</span>
|
||||
<span class="identifier">array</span><span class="special">[</span><span class="identifier">i</span><span class="special">]</span> <span class="special">*=</span> <span class="number">2</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
Python:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">>>></span> <span class="identifier">l</span> <span class="special">=</span> <span class="special">[</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">]</span>
|
||||
<span class="special">>>></span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">l</span><span class="special">)</span>
|
||||
<span class="special">>>></span> <span class="keyword">print</span> <span class="identifier">l</span>
|
||||
<span class="special">[</span><span class="number">2</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">6</span><span class="special">]</span>
|
||||
</pre>
|
||||
<p>
|
||||
Custom lvalue converters require changes to the Boost.Python core library
|
||||
and are currently not available.
|
||||
</p>
|
||||
<p>
|
||||
P.S.:
|
||||
</p>
|
||||
<p>
|
||||
The "scitbx" files referenced above are available via anonymous
|
||||
CVS:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">cvs</span> <span class="special">-</span><span class="identifier">d</span><span class="special">:</span><span class="identifier">pserver</span><span class="special">:</span><span class="identifier">anonymous</span><span class="error">@</span><span class="identifier">cvs</span><span class="special">.</span><span class="identifier">cctbx</span><span class="special">.</span><span class="identifier">sourceforge</span><span class="special">.</span><span class="identifier">net</span><span class="special">:/</span><span class="identifier">cvsroot</span><span class="special">/</span><span class="identifier">cctbx</span> <span class="identifier">login</span>
|
||||
<span class="identifier">cvs</span> <span class="special">-</span><span class="identifier">d</span><span class="special">:</span><span class="identifier">pserver</span><span class="special">:</span><span class="identifier">anonymous</span><span class="error">@</span><span class="identifier">cvs</span><span class="special">.</span><span class="identifier">cctbx</span><span class="special">.</span><span class="identifier">sourceforge</span><span class="special">.</span><span class="identifier">net</span><span class="special">:/</span><span class="identifier">cvsroot</span><span class="special">/</span><span class="identifier">cctbx</span> <span class="identifier">co</span> <span class="identifier">scitbx</span>
|
||||
</pre>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="is_return_internal_reference_eff.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="fatal_error_c1204_compiler_limit.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
41
develop/doc/html/faq/how_do_i_create_sub_packages_usi.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How do I create sub-packages using Boost.Python?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="compilation_takes_too_much_time_.html" title="Compilation takes too much time and eats too much memory! What can I do to make it faster?">
|
||||
<link rel="next" href="error_c2064_term_does_not_evalua.html" title="error C2064: term does not evaluate to a function taking 2 arguments">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="compilation_takes_too_much_time_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="error_c2064_term_does_not_evalua.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.how_do_i_create_sub_packages_usi"></a><a class="link" href="how_do_i_create_sub_packages_usi.html" title="How do I create sub-packages using Boost.Python?">How do I create
|
||||
sub-packages using Boost.Python?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Please refer to the <code class="computeroutput"><span class="identifier">Creating</span> <span class="identifier">Packages</span></code> section in the <a href="../tutorial/index.html" target="_top">Tutorial</a>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="compilation_takes_too_much_time_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="error_c2064_term_does_not_evalua.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
151
develop/doc/html/faq/how_do_i_debug_my_python_extensi.html
Normal file
@@ -0,0 +1,151 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>How do I debug my Python extensions?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="fatal_error_c1204_compiler_limit.html" title="fatal error C1204:Compiler limit:internal structure overflow">
|
||||
<link rel="next" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="fatal_error_c1204_compiler_limit.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="why_doesn_t_my_operator_work.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.how_do_i_debug_my_python_extensi"></a><a class="link" href="how_do_i_debug_my_python_extensi.html" title="How do I debug my Python extensions?">How do I debug
|
||||
my Python extensions?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Greg Burley gives the following answer for Unix GCC users:
|
||||
</p>
|
||||
<div class="blockquote"><blockquote class="blockquote">
|
||||
<p>
|
||||
Once you have created a boost python extension for your c++ library or
|
||||
class, you may need to debug the code. Afterall this is one of the reasons
|
||||
for wrapping the library in python. An expected side-effect or benefit
|
||||
of using BPL is that debugging should be isolated to the c++ library that
|
||||
is under test, given that python code is minimal and boost::python either
|
||||
works or it doesn't. (ie. While errors can occur when the wrapping method
|
||||
is invalid, most errors are caught by the compiler ;-).
|
||||
</p>
|
||||
<p>
|
||||
The basic steps required to initiate a gdb session to debug a c++ library
|
||||
via python are shown here. Note, however that you should start the gdb
|
||||
session in the directory that contains your BPL my_ext.so module.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">target</span> <span class="identifier">exec</span> <span class="identifier">python</span>
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">run</span>
|
||||
<span class="special">>>></span> <span class="identifier">from</span> <span class="identifier">my_ext</span> <span class="identifier">import</span> <span class="special">*</span>
|
||||
<span class="special">>>></span> <span class="special">[</span><span class="identifier">C</span><span class="special">-</span><span class="identifier">c</span><span class="special">]</span>
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="keyword">break</span> <span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">MyBuggyFunction</span>
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">cont</span>
|
||||
<span class="special">>>></span> <span class="identifier">pyobj</span> <span class="special">=</span> <span class="identifier">MyClass</span><span class="special">()</span>
|
||||
<span class="special">>>></span> <span class="identifier">pyobj</span><span class="special">.</span><span class="identifier">MyBuggyFunction</span><span class="special">()</span>
|
||||
<span class="identifier">Breakpoint</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">MyBuggyFunction</span> <span class="special">...</span>
|
||||
<span class="identifier">Current</span> <span class="identifier">language</span><span class="special">:</span> <span class="keyword">auto</span><span class="special">;</span> <span class="identifier">currently</span> <span class="identifier">c</span><span class="special">++</span>
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="keyword">do</span> <span class="identifier">debugging</span> <span class="identifier">stuff</span>
|
||||
</pre>
|
||||
</blockquote></div>
|
||||
<p>
|
||||
Greg's approach works even better using Emacs' "gdb" command, since
|
||||
it will show you each line of source as you step through it.
|
||||
</p>
|
||||
<p>
|
||||
On <span class="bold"><strong>Windows</strong></span>, my favorite debugging solution
|
||||
is the debugger that comes with Microsoft Visual C++ 7. This debugger seems
|
||||
to work with code generated by all versions of Microsoft and Metrowerks toolsets;
|
||||
it's rock solid and "just works" without requiring any special
|
||||
tricks from the user.
|
||||
</p>
|
||||
<p>
|
||||
Raoul Gough has provided the following for gdb on Windows:
|
||||
</p>
|
||||
<div class="blockquote"><blockquote class="blockquote">
|
||||
<p>
|
||||
gdb support for Windows DLLs has improved lately, so it is now possible
|
||||
to debug Python extensions using a few tricks. Firstly, you will need an
|
||||
up-to-date gdb with support for minimal symbol extraction from a DLL. Any
|
||||
gdb from version 6 onwards, or Cygwin gdb-20030214-1 and onwards should
|
||||
do. A suitable release will have a section in the gdb.info file under Configuration
|
||||
- Native - Cygwin Native - Non-debug DLL symbols. Refer to that info section
|
||||
for more details of the procedures outlined here.
|
||||
</p>
|
||||
<p>
|
||||
Secondly, it seems necessary to set a breakpoint in the Python interpreter,
|
||||
rather than using ^C to break execution. A good place to set this breakpoint
|
||||
is PyOS_Readline, which will stop execution immediately before reading
|
||||
each interactive Python command. You have to let Python start once under
|
||||
the debugger, so that it loads its own DLL, before you can set the breakpoint:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="error">$</span> <span class="identifier">gdb</span> <span class="identifier">python</span>
|
||||
<span class="identifier">GNU</span> <span class="identifier">gdb</span> <span class="number">2003</span><span class="special">-</span><span class="number">09</span><span class="special">-</span><span class="number">02</span><span class="special">-</span><span class="identifier">cvs</span> <span class="special">(</span><span class="identifier">cygwin</span><span class="special">-</span><span class="identifier">special</span><span class="special">)</span>
|
||||
<span class="special">[...]</span>
|
||||
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">run</span>
|
||||
<span class="identifier">Starting</span> <span class="identifier">program</span><span class="special">:</span> <span class="special">/</span><span class="identifier">cygdrive</span><span class="special">/</span><span class="identifier">c</span><span class="special">/</span><span class="identifier">Python22</span><span class="special">/</span><span class="identifier">python</span><span class="special">.</span><span class="identifier">exe</span>
|
||||
<span class="identifier">Python</span> <span class="number">2.2</span><span class="special">.</span><span class="number">2</span> <span class="special">(#</span><span class="number">37</span><span class="special">,</span> <span class="identifier">Oct</span> <span class="number">14</span> <span class="number">2002</span><span class="special">,</span> <span class="number">17</span><span class="special">:</span><span class="number">02</span><span class="special">:</span><span class="number">34</span><span class="special">)</span> <span class="special">[</span><span class="identifier">MSC</span> <span class="number">32</span> <span class="identifier">bit</span> <span class="special">(</span><span class="identifier">Intel</span><span class="special">)]</span> <span class="identifier">on</span> <span class="identifier">win32</span>
|
||||
<span class="identifier">Type</span> <span class="string">"help"</span><span class="special">,</span> <span class="string">"copyright"</span><span class="special">,</span> <span class="string">"credits"</span> <span class="keyword">or</span> <span class="string">"license"</span> <span class="keyword">for</span> <span class="identifier">more</span> <span class="identifier">information</span><span class="special">.</span>
|
||||
<span class="special">>>></span> <span class="special">^</span><span class="identifier">Z</span>
|
||||
|
||||
|
||||
<span class="identifier">Program</span> <span class="identifier">exited</span> <span class="identifier">normally</span><span class="special">.</span>
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="keyword">break</span> <span class="special">*&</span><span class="identifier">PyOS_Readline</span>
|
||||
<span class="identifier">Breakpoint</span> <span class="number">1</span> <span class="identifier">at</span> <span class="number">0x1e04eff0</span>
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">run</span>
|
||||
<span class="identifier">Starting</span> <span class="identifier">program</span><span class="special">:</span> <span class="special">/</span><span class="identifier">cygdrive</span><span class="special">/</span><span class="identifier">c</span><span class="special">/</span><span class="identifier">Python22</span><span class="special">/</span><span class="identifier">python</span><span class="special">.</span><span class="identifier">exe</span>
|
||||
<span class="identifier">Python</span> <span class="number">2.2</span><span class="special">.</span><span class="number">2</span> <span class="special">(#</span><span class="number">37</span><span class="special">,</span> <span class="identifier">Oct</span> <span class="number">14</span> <span class="number">2002</span><span class="special">,</span> <span class="number">17</span><span class="special">:</span><span class="number">02</span><span class="special">:</span><span class="number">34</span><span class="special">)</span> <span class="special">[</span><span class="identifier">MSC</span> <span class="number">32</span> <span class="identifier">bit</span> <span class="special">(</span><span class="identifier">Intel</span><span class="special">)]</span> <span class="identifier">on</span> <span class="identifier">win32</span>
|
||||
<span class="identifier">Type</span> <span class="string">"help"</span><span class="special">,</span> <span class="string">"copyright"</span><span class="special">,</span> <span class="string">"credits"</span> <span class="keyword">or</span> <span class="string">"license"</span> <span class="keyword">for</span> <span class="identifier">more</span> <span class="identifier">information</span><span class="special">.</span>
|
||||
|
||||
<span class="identifier">Breakpoint</span> <span class="number">1</span><span class="special">,</span> <span class="number">0x1e04eff0</span> <span class="identifier">in</span> <span class="identifier">python22</span><span class="special">!</span><span class="identifier">PyOS_Readline</span> <span class="special">()</span>
|
||||
<span class="identifier">from</span> <span class="special">/</span><span class="identifier">cygdrive</span><span class="special">/</span><span class="identifier">c</span><span class="special">/</span><span class="identifier">WINNT</span><span class="special">/</span><span class="identifier">system32</span><span class="special">/</span><span class="identifier">python22</span><span class="special">.</span><span class="identifier">dll</span>
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="identifier">cont</span>
|
||||
<span class="identifier">Continuing</span><span class="special">.</span>
|
||||
<span class="special">>>></span> <span class="identifier">from</span> <span class="identifier">my_ext</span> <span class="identifier">import</span> <span class="special">*</span>
|
||||
|
||||
<span class="identifier">Breakpoint</span> <span class="number">1</span><span class="special">,</span> <span class="number">0x1e04eff0</span> <span class="identifier">in</span> <span class="identifier">python22</span><span class="special">!</span><span class="identifier">PyOS_Readline</span> <span class="special">()</span>
|
||||
<span class="identifier">from</span> <span class="special">/</span><span class="identifier">cygdrive</span><span class="special">/</span><span class="identifier">c</span><span class="special">/</span><span class="identifier">WINNT</span><span class="special">/</span><span class="identifier">system32</span><span class="special">/</span><span class="identifier">python22</span><span class="special">.</span><span class="identifier">dll</span>
|
||||
<span class="special">(</span><span class="identifier">gdb</span><span class="special">)</span> <span class="special">#</span> <span class="identifier">my_ext</span> <span class="identifier">now</span> <span class="identifier">loaded</span> <span class="special">(</span><span class="identifier">with</span> <span class="identifier">any</span> <span class="identifier">debugging</span> <span class="identifier">symbols</span> <span class="identifier">it</span> <span class="identifier">contains</span><span class="special">)</span>
|
||||
</pre>
|
||||
</blockquote></div>
|
||||
<h3>
|
||||
<a name="faq.how_do_i_debug_my_python_extensi.h0"></a>
|
||||
<span class="phrase"><a name="faq.how_do_i_debug_my_python_extensi.debugging_extensions_through_boo"></a></span><a class="link" href="how_do_i_debug_my_python_extensi.html#faq.how_do_i_debug_my_python_extensi.debugging_extensions_through_boo">Debugging
|
||||
extensions through Boost.Build</a>
|
||||
</h3>
|
||||
<p>
|
||||
If you are launching your extension module tests with <a href="http://www.boost.org/build" target="_top">Boost.Build</a>
|
||||
using the <code class="computeroutput"><span class="identifier">boost</span><span class="special">-</span><span class="identifier">python</span><span class="special">-</span><span class="identifier">runtest</span></code> rule, you can ask it to launch
|
||||
your debugger for you by adding "--debugger=<span class="emphasis"><em>debugger</em></span>"
|
||||
to your bjam command-line:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">bjam</span> <span class="special">-</span><span class="identifier">sTOOLS</span><span class="special">=</span><span class="identifier">vc7</span><span class="special">.</span><span class="number">1</span> <span class="string">"--debugger=devenv /debugexe"</span> <span class="identifier">test</span>
|
||||
<span class="identifier">bjam</span> <span class="special">-</span><span class="identifier">sTOOLS</span><span class="special">=</span><span class="identifier">gcc</span> <span class="special">-</span><span class="identifier">sPYTHON_LAUNCH</span><span class="special">=</span><span class="identifier">gdb</span> <span class="identifier">test</span>
|
||||
</pre>
|
||||
<p>
|
||||
It can also be extremely useful to add the <code class="computeroutput"><span class="special">-</span><span class="identifier">d</span><span class="special">+</span><span class="number">2</span></code>
|
||||
option when you run your test, because Boost.Build will then show you the
|
||||
exact commands it uses to invoke it. This will invariably involve setting
|
||||
up PYTHONPATH and other important environment variables such as LD_LIBRARY_PATH
|
||||
which may be needed by your debugger in order to get things to work right.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="fatal_error_c1204_compiler_limit.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="why_doesn_t_my_operator_work.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
67
develop/doc/html/faq/i_m_getting_the_attempt_to_retur.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>I'm getting the "attempt to return dangling reference" error. What am I doing wrong?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="next" href="is_return_internal_reference_eff.html" title="Is return_internal_reference efficient?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../faq.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_return_internal_reference_eff.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.i_m_getting_the_attempt_to_retur"></a><a class="link" href="i_m_getting_the_attempt_to_retur.html" title="I'm getting the "attempt to return dangling reference" error. What am I doing wrong?">I'm getting the
|
||||
"attempt to return dangling reference" error. What am I doing wrong?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
That exception is protecting you from causing a nasty crash. It usually happens
|
||||
in response to some code like this:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">period</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">get_floating_frequency</span><span class="special">()</span> <span class="keyword">const</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">call_method</span><span class="special"><</span><span class="identifier">period</span> <span class="keyword">const</span> <span class="special">&>(</span>
|
||||
<span class="identifier">m_self</span><span class="special">,</span><span class="string">"get_floating_frequency"</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
And you get:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">ReferenceError</span><span class="special">:</span> <span class="identifier">Attempt</span> <span class="identifier">to</span> <span class="keyword">return</span> <span class="identifier">dangling</span> <span class="identifier">reference</span> <span class="identifier">to</span> <span class="identifier">object</span> <span class="identifier">of</span> <span class="identifier">type</span><span class="special">:</span>
|
||||
<span class="keyword">class</span> <span class="identifier">period</span>
|
||||
</pre>
|
||||
<p>
|
||||
In this case, the Python method invoked by <code class="computeroutput"><span class="identifier">call_method</span></code>
|
||||
constructs a new Python object. You're trying to return a reference to a
|
||||
C++ object (an instance of <code class="computeroutput"><span class="keyword">class</span> <span class="identifier">period</span></code>) contained within and owned by that
|
||||
Python object. Because the called method handed back a brand new object,
|
||||
the only reference to it is held for the duration of <code class="computeroutput"><span class="identifier">get_floating_frequency</span><span class="special">()</span></code> above. When the function returns, the Python
|
||||
object will be destroyed, destroying the instance of <code class="computeroutput"><span class="keyword">class</span>
|
||||
<span class="identifier">period</span></code>, and leaving the returned
|
||||
reference dangling. That's already undefined behavior, and if you try to
|
||||
do anything with that reference you're likely to cause a crash. Boost.Python
|
||||
detects this situation at runtime and helpfully throws an exception instead
|
||||
of letting you do that.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../faq.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_return_internal_reference_eff.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
60
develop/doc/html/faq/is_boost_python_thread_aware_com.html
Normal file
@@ -0,0 +1,60 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Is Boost.Python thread-aware/compatible with multiple interpreters?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="why_is_my_automatic_to_python_co.html" title="Why is my automatic to-python conversion not being found?">
|
||||
<link rel="next" href="../glossary.html" title="Chapter 6. Glossary">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="why_is_my_automatic_to_python_co.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../glossary.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.is_boost_python_thread_aware_com"></a><a class="link" href="is_boost_python_thread_aware_com.html" title="Is Boost.Python thread-aware/compatible with multiple interpreters?">Is Boost.Python
|
||||
thread-aware/compatible with multiple interpreters?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<span class="emphasis"><em>Niall Douglas provides these notes:</em></span>
|
||||
</p>
|
||||
<p>
|
||||
The quick answer to this is: no.
|
||||
</p>
|
||||
<p>
|
||||
The longer answer is that it can be patched to be so, but it's complex. You
|
||||
will need to add custom lock/unlock wrapping of every time your code enters
|
||||
Boost.Python (particularly every virtual function override) plus heavily
|
||||
modify <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">invoke</span><span class="special">.</span><span class="identifier">hpp</span></code> with custom unlock/lock wrapping of
|
||||
every time Boost.Python enters your code. You must furthermore take care
|
||||
to <span class="emphasis"><em>not</em></span> unlock/lock when Boost.Python is invoking iterator
|
||||
changes via <code class="computeroutput"><span class="identifier">invoke</span><span class="special">.</span><span class="identifier">hpp</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
There is a patched <code class="computeroutput"><span class="identifier">invoke</span><span class="special">.</span><span class="identifier">hpp</span></code> posted
|
||||
on the C++-SIG mailing list archives and you can find a real implementation
|
||||
of all the machinery necessary to fully implement this in the TnFOX project
|
||||
at <a href="http://sourceforge.net/projects/tnfox/" target="_top">this</a> SourceForge
|
||||
project location.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="why_is_my_automatic_to_python_co.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../glossary.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
62
develop/doc/html/faq/is_return_internal_reference_eff.html
Normal file
@@ -0,0 +1,62 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Is return_internal_reference efficient?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="i_m_getting_the_attempt_to_retur.html" title="I'm getting the "attempt to return dangling reference" error. What am I doing wrong?">
|
||||
<link rel="next" href="how_can_i_wrap_functions_which_t.html" title="How can I wrap functions which take C++ containers as arguments?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="i_m_getting_the_attempt_to_retur.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_wrap_functions_which_t.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.is_return_internal_reference_eff"></a><a class="link" href="is_return_internal_reference_eff.html" title="Is return_internal_reference efficient?">Is <code class="computeroutput"><span class="identifier">return_internal_reference</span></code> efficient?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<span class="bold"><strong>Q:</strong></span> /I have an object composed of 12 doubles.
|
||||
A <code class="computeroutput"><span class="keyword">const</span><span class="special">&</span></code>
|
||||
to this object is returned by a member function of another class. From the
|
||||
viewpoint of using the returned object in Python I do not care if I get a
|
||||
copy or a reference to the returned object. In Boost.Python I have the choice
|
||||
of using <code class="computeroutput"><span class="identifier">copy_const_reference</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">return_internal_reference</span></code>.
|
||||
Are there considerations that would lead me to prefer one over the other,
|
||||
such as size of generated code or memory overhead?/
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>A:</strong></span> <code class="computeroutput"><span class="identifier">copy_const_reference</span></code>
|
||||
will make an instance with storage for one of your objects, <code class="computeroutput"><span class="identifier">size</span> <span class="special">=</span> <span class="identifier">base_size</span> <span class="special">+</span> <span class="number">12</span> <span class="special">*</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">double</span><span class="special">)</span></code>.
|
||||
<code class="computeroutput"><span class="identifier">return_internal_reference</span></code>
|
||||
will make an instance with storage for a pointer to one of your objects,
|
||||
<code class="computeroutput"><span class="identifier">size</span> <span class="special">=</span>
|
||||
<span class="identifier">base_size</span> <span class="special">+</span>
|
||||
<span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">void</span><span class="special">*)</span></code>. However,
|
||||
it will also create a weak reference object which goes in the source object's
|
||||
weakreflist and a special callback object to manage the lifetime of the internally-referenced
|
||||
object. My guess? <code class="computeroutput"><span class="identifier">copy_const_reference</span></code>
|
||||
is your friend here, resulting in less overall memory use and less fragmentation,
|
||||
also probably fewer total cycles.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="i_m_getting_the_attempt_to_retur.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_wrap_functions_which_t.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
63
develop/doc/html/faq/why_doesn_t_my_operator_work.html
Normal file
@@ -0,0 +1,63 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Why doesn't my *= operator work?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_do_i_debug_my_python_extensi.html" title="How do I debug my Python extensions?">
|
||||
<link rel="next" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_do_i_debug_my_python_extensi.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="does_boost_python_work_with_mac_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.why_doesn_t_my_operator_work"></a><a class="link" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">Why doesn't my <code class="computeroutput"><span class="special">*=</span></code> operator work?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<span class="bold"><strong>Q:</strong></span> <span class="emphasis"><em>I have exported my class to
|
||||
python, with many overloaded operators. it works fine for me except the
|
||||
<code class="computeroutput"><span class="special">*=</span></code> operator. It always tells
|
||||
me "can't multiply sequence with non int type". If I use <code class="computeroutput"><span class="identifier">p1</span><span class="special">.</span><span class="identifier">__imul__</span><span class="special">(</span><span class="identifier">p2</span><span class="special">)</span></code>
|
||||
instead of <code class="computeroutput"><span class="identifier">p1</span> <span class="special">*=</span>
|
||||
<span class="identifier">p2</span></code>, it successfully executes my
|
||||
code. What's wrong with me?</em></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>A:</strong></span> There's nothing wrong with you. This
|
||||
is a bug in Python 2.2. You can see the same effect in Pure Python (you can
|
||||
learn a lot about what's happening in Boost.Python by playing with new-style
|
||||
classes in Pure Python).
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">>>></span> <span class="keyword">class</span> <span class="identifier">X</span><span class="special">(</span><span class="identifier">object</span><span class="special">):</span>
|
||||
<span class="special">...</span> <span class="identifier">def</span> <span class="identifier">__imul__</span><span class="special">(</span><span class="identifier">self</span><span class="special">,</span> <span class="identifier">x</span><span class="special">):</span>
|
||||
<span class="special">...</span> <span class="identifier">print</span> <span class="char">'imul'</span>
|
||||
<span class="special">...</span>
|
||||
<span class="special">>>></span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">X</span><span class="special">()</span>
|
||||
<span class="special">>>></span> <span class="identifier">x</span> <span class="special">*=</span> <span class="number">1</span>
|
||||
</pre>
|
||||
<p>
|
||||
To cure this problem, all you need to do is upgrade your Python to version
|
||||
2.2.1 or later.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_do_i_debug_my_python_extensi.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="does_boost_python_work_with_mac_.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
67
develop/doc/html/faq/why_is_my_automatic_to_python_co.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Why is my automatic to-python conversion not being found?</title>
|
||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Python">
|
||||
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
|
||||
<link rel="prev" href="how_can_i_automatically_convert_.html" title="How can I automatically convert my custom string type to and from a Python string?">
|
||||
<link rel="next" href="is_boost_python_thread_aware_com.html" title="Is Boost.Python thread-aware/compatible with multiple interpreters?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_can_i_automatically_convert_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_boost_python_thread_aware_com.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="faq.why_is_my_automatic_to_python_co"></a><a class="link" href="why_is_my_automatic_to_python_co.html" title="Why is my automatic to-python conversion not being found?">Why is my automatic
|
||||
to-python conversion not being found?</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<span class="emphasis"><em>Niall Douglas provides these notes:</em></span>
|
||||
</p>
|
||||
<p>
|
||||
If you define custom converters similar to the ones shown above the <code class="computeroutput"><span class="identifier">def_readonly</span><span class="special">()</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">def_readwrite</span><span class="special">()</span></code>
|
||||
member functions provided by <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">class_</span></code>
|
||||
for direct access to your member data will not work as expected. This is
|
||||
because <code class="computeroutput"><span class="identifier">def_readonly</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">)</span></code> is equivalent to:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_internal_reference</span><span class="special">()))</span>
|
||||
</pre>
|
||||
<p>
|
||||
Similarly, <code class="computeroutput"><span class="identifier">def_readwrite</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">)</span></code>
|
||||
is equivalent to:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_internal_reference</span><span class="special">()),</span>
|
||||
<span class="identifier">make_setter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_internal_reference</span><span class="special">())</span>
|
||||
</pre>
|
||||
<p>
|
||||
In order to define return value policies compatible with the custom conversions
|
||||
replace <code class="computeroutput"><span class="identifier">def_readonly</span><span class="special">()</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">def_readwrite</span><span class="special">()</span></code>
|
||||
by <code class="computeroutput"><span class="identifier">add_property</span><span class="special">()</span></code>.
|
||||
E.g.:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"bar"</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_value_policy</span><span class="special"><</span><span class="identifier">return_by_value</span><span class="special">>()),</span>
|
||||
<span class="identifier">make_setter</span><span class="special">(&</span><span class="identifier">foo</span><span class="special">::</span><span class="identifier">bar</span><span class="special">,</span> <span class="identifier">return_value_policy</span><span class="special"><</span><span class="identifier">return_by_value</span><span class="special">>()))</span>
|
||||
</pre>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="how_can_i_automatically_convert_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="is_boost_python_thread_aware_com.html"><img src="../images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
81
develop/doc/html/glossary.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 6. Glossary</title>
|
||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="index.html" title="Boost.Python">
|
||||
<link rel="up" href="index.html" title="Boost.Python">
|
||||
<link rel="prev" href="faq/is_boost_python_thread_aware_com.html" title="Is Boost.Python thread-aware/compatible with multiple interpreters?">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="images/bpl.png"></td></tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="faq/is_boost_python_thread_aware_com.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a>
|
||||
</div>
|
||||
<div class="chapter">
|
||||
<div class="titlepage"><div><div><h1 class="title">
|
||||
<a name="glossary"></a>Chapter 6. Glossary</h1></div></div></div>
|
||||
<div class="variablelist">
|
||||
<p class="title"><b></b></p>
|
||||
<dl class="variablelist">
|
||||
<dt><span class="term">arity <a name="arity"></a></span></dt>
|
||||
<dd><p>
|
||||
The number of argumnts accepted by a function or member function. Unless
|
||||
otherwise specified, the hidden <code class="computeroutput"><span class="keyword">this</span></code>
|
||||
argument to member functions is not counted when specifying arity.
|
||||
</p></dd>
|
||||
<dt><span class="term">ntbs <a name="ntbs"></a></span></dt>
|
||||
<dd><p>
|
||||
Null-Terminated Byte String, or 'C'-string. C++ string literals are
|
||||
<span class="bold"><strong>ntbs</strong></span>es. An <span class="bold"><strong>ntbs</strong></span>
|
||||
must never be null.
|
||||
</p></dd>
|
||||
<dt><span class="term">raise <a name="raise"></a></span></dt>
|
||||
<dd><p>
|
||||
Exceptions in Python are "raised", not "thrown",
|
||||
as they are in C++. When this documentation says that some Python exception
|
||||
is "raised" in the context of C++ code, it means that the corresponding
|
||||
Python exception is set via the <a href="http://www.python.org/doc/current/api/exceptionHandling.html" target="_top">Python/'C'
|
||||
API</a>, and <code class="computeroutput"><span class="identifier">throw_error_already_set</span><span class="special">()</span></code> is called.
|
||||
</p></dd>
|
||||
<dt><span class="term">POD <a name="pod"></a></span></dt>
|
||||
<dd><p>
|
||||
A technical term from the C++ standard. Short for "Plain Ol'Data":
|
||||
A POD-struct is an aggregate class that has no non-static data members
|
||||
of type pointer to member, non-POD-struct, non-POD-union (or array of
|
||||
such types) or reference, and has no user-defined copy assign- ment operator
|
||||
and no user-defined destructor. Similarly, a POD-union is an aggregate
|
||||
union that has no non-static data members of type pointer to member,
|
||||
non-POD-struct, non-POD-union (or array of such types) or reference,
|
||||
and has no user-defined copy assignment operator and no user-defined
|
||||
destructor. A POD class is a class that is either a POD-struct or a POD-union.
|
||||
An aggregate is an array or a class (clause 9) with no user-declared
|
||||
constructors (12.1), no private or protected non-static data members
|
||||
(clause 11), no base classes (clause 10), and no virtual functions (10.3).
|
||||
</p></dd>
|
||||
<dt><span class="term">ODR <a name="odr"></a></span></dt>
|
||||
<dd><p>
|
||||
The "One Definition Rule", which says that any entity in a
|
||||
C++ program must have the same definition in all translation units (object
|
||||
files) which make up a program.
|
||||
</p></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
|
||||
Abrahams, Stefan Seefeld<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="faq/is_boost_python_thread_aware_com.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 374 B |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 391 B After Width: | Height: | Size: 391 B |
|
Before Width: | Height: | Size: 703 B After Width: | Height: | Size: 703 B |
|
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 485 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 410 B |
|
Before Width: | Height: | Size: 827 B After Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 488 B After Width: | Height: | Size: 488 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 509 B After Width: | Height: | Size: 509 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 499 B |
|
Before Width: | Height: | Size: 906 B After Width: | Height: | Size: 906 B |
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 866 B After Width: | Height: | Size: 866 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 446 B |
|
Before Width: | Height: | Size: 926 B After Width: | Height: | Size: 926 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 431 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 441 B After Width: | Height: | Size: 441 B |
|
Before Width: | Height: | Size: 783 B After Width: | Height: | Size: 783 B |
|
Before Width: | Height: | Size: 423 B After Width: | Height: | Size: 423 B |
|
Before Width: | Height: | Size: 967 B After Width: | Height: | Size: 967 B |
|
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 431 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 397 B After Width: | Height: | Size: 397 B |
|
Before Width: | Height: | Size: 738 B After Width: | Height: | Size: 738 B |
|
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 434 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 420 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 358 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 722 B |