├── .gitignore ├── Makefile ├── README.md ├── docker ├── Dockerfile ├── docker-build.sh ├── docker-run.sh └── mirrorlist ├── dub.sdl ├── dub.selections.json ├── source ├── app.d └── nanomsg.dpp └── tests └── test_nanomsg.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.o 3 | source/nanomsg.d 4 | *.pyc 5 | .dub 6 | .pytest_cache -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | dub := dub 2 | dmd := dmd 3 | dub_pkgs_dir := $(HOME)/.dub/packages 4 | dpp_version := 0.4.0 5 | dpp_pkg_dir := $(dub_pkgs_dir)/dpp-$(dpp_version) 6 | dpp_lock := $(dpp_pkg_dir)/dpp.lock 7 | dpp_dir := $(dpp_pkg_dir)/dpp 8 | dpp := $(dpp_dir)/bin/d++ 9 | autowrap_version := 0.5.1 10 | autowrap_dir := $(dub_pkgs_dir)/autowrap-$(autowrap_version)/autowrap 11 | autowrap_pynih_dir := $(autowrap_dir)/pynih 12 | autowrap_pynih_raw_dpp := $(autowrap_pynih_dir)/source/python/raw.dpp 13 | autowrap_pynih_raw_d := $(autowrap_pynih_dir)/source/python/raw.d 14 | PYTHON_INCLUDE_DIR := $(shell python -c 'from distutils.sysconfig import get_python_inc; print(get_python_inc())') 15 | 16 | .PHONY: test libpython-dpp-nanomsg.so nanomsg.so 17 | all: test 18 | 19 | test: nanomsg.so 20 | PYTHONPATH=$(PWD) pytest -s -vv 21 | 22 | nanomsg.so: libpython-dpp-nanomsg.so 23 | cp $< $@ 24 | 25 | libpython-dpp-nanomsg.so: source/nanomsg.d $(autowrap_pynih_raw_d) 26 | $(dub) build -q 27 | 28 | source/nanomsg.d: source/nanomsg.dpp $(dpp) 29 | $(dpp) --preprocess-only --include-path $(PYTHON_INCLUDE_DIR) source/nanomsg.dpp 30 | 31 | $(dpp): $(dpp_lock) $(autowrap_pynih_raw) 32 | cd $(dpp_dir) && $(dub) build -q --compiler=$(dmd) 33 | 34 | $(dpp_lock): 35 | $(dub) fetch dpp --version=$(dpp_version) 36 | 37 | $(autowrap_pynih_raw_d): $(autowrap_pynih_raw_dpp) 38 | make -C $(autowrap_pynih_dir) source/python/raw.d 39 | 40 | $(autowrap_pynih_raw_dpp): 41 | $(dub) fetch autowrap --version=$(autowrap_version) 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Call nanomsg from Python using D as the glue layer 2 | 3 | This repository is an example of using D's powerful metaprogramming features 4 | to enable calling C code from Python without having to write any code at all. 5 | 6 | To package all needed dependencies to build and run the example, there is 7 | a [Dockerfile](docker/Dockerfile) but the container doesn't need to be manually 8 | built. Just: 9 | 10 | * Run `docker/docker-run.sh`. This will build the Docker container and run bash within it. 11 | * Run `make` as soon as you get a bash prompt in the container. This 12 | will build a Python extension then run [Python 13 | tests](tests/test_nanomsg.py) that call into the nanomsg C library. 14 | 15 | That's it. The user code that enables the magic seen in that Python file is 4 lines in 16 | [two](source/app.d) [files](source/nanomsg.dpp). 17 | 18 | The library code that enables it is in two [dub](https://code.dlang.org) packages: 19 | [autowrap](https://github.com/symmetryinvestments/autowrap) and 20 | [dpp](https://github.com/atilaneves/dpp). 21 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM archlinux/base 2 | ADD mirrorlist /etc/pacman.d/mirrorlist 3 | WORKDIR /project 4 | RUN pacman --noconfirm -Syu && pacman -S --noconfirm --needed make dlang python-pip nanomsg clang && pip install pytest && dub fetch dpp --version=0.4.0 && dub fetch autowrap --version=0.5.1 5 | -------------------------------------------------------------------------------- /docker/docker-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" 6 | 7 | if [[ "$(docker images -q dlang/python-nanomsg 2> /dev/null)" == "" ]]; then 8 | docker build --no-cache --pull -t dlang/python-nanomsg "$SCRIPT_DIR" 9 | fi 10 | -------------------------------------------------------------------------------- /docker/docker-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" 6 | "$SCRIPT_DIR"/docker-build.sh 7 | 8 | docker run --rm -v "$SCRIPT_DIR"/..:/project -it dlang/python-nanomsg /bin/bash 9 | -------------------------------------------------------------------------------- /docker/mirrorlist: -------------------------------------------------------------------------------- 1 | ## 2 | ## Arch Linux repository mirrorlist 3 | ## Filtered by mirror score from mirror status page 4 | ## Generated on 2019-04-01 5 | ## 6 | 7 | ## Turkey 8 | Server = http://mirror.veriteknik.net.tr/archlinux/$repo/os/$arch 9 | ## Belarus 10 | Server = http://mirror.datacenter.by/pub/archlinux/$repo/os/$arch 11 | ## France 12 | Server = http://arch.tamcore.eu/$repo/os/$arch 13 | ## Ireland 14 | Server = http://ftp.heanet.ie/mirrors/ftp.archlinux.org/$repo/os/$arch 15 | ## Sweden 16 | Server = http://ftp.myrveln.se/pub/linux/archlinux/$repo/os/$arch 17 | ## France 18 | Server = http://mirror.oldsql.cc/archlinux/$repo/os/$arch 19 | ## Belgium 20 | Server = http://mirror.adct.be/arch/$repo/os/$arch 21 | ## Brazil 22 | Server = http://br.mirror.archlinux-br.org/$repo/os/$arch 23 | ## Netherlands 24 | Server = http://mirror.ams1.nl.leaseweb.net/archlinux/$repo/os/$arch 25 | ## Norway 26 | Server = http://archlinux.uib.no/$repo/os/$arch 27 | ## Czechia 28 | Server = http://ftp.sh.cvut.cz/arch/$repo/os/$arch 29 | ## Greece 30 | Server = http://ftp.otenet.gr/linux/archlinux/$repo/os/$arch 31 | ## Australia 32 | Server = http://ftp.swin.edu.au/archlinux/$repo/os/$arch 33 | ## United Kingdom 34 | Server = http://mirror.netweaver.uk/archlinux/$repo/os/$arch 35 | ## Israel 36 | Server = http://mirror.isoc.org.il/pub/archlinux/$repo/os/$arch 37 | ## Ecuador 38 | Server = http://mirror.espoch.edu.ec/archlinux/$repo/os/$arch 39 | ## France 40 | Server = http://archlinux.mirror.pkern.at/$repo/os/$arch 41 | ## Serbia 42 | Server = http://arch.petarmaric.com/$repo/os/$arch 43 | ## Norway 44 | Server = http://mirror.homelab.no/archlinux/$repo/os/$arch 45 | ## France 46 | Server = http://archlinux.mirrors.benatherton.com/$repo/os/$arch 47 | ## Norway 48 | Server = http://mirror.archlinux.no/$repo/os/$arch 49 | ## Bosnia and Herzegovina 50 | Server = http://archlinux.mirror.ba/$repo/os/$arch 51 | ## China 52 | Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch 53 | ## United States 54 | Server = http://mirror.lty.me/archlinux/$repo/os/$arch 55 | ## Netherlands 56 | Server = http://ftp.snt.utwente.nl/pub/os/linux/archlinux/$repo/os/$arch 57 | ## France 58 | Server = http://archlinux.mirrors.ovh.net/archlinux/$repo/os/$arch 59 | ## Canada 60 | Server = http://mirror.cedille.club/archlinux/$repo/os/$arch 61 | ## Greece 62 | Server = http://foss.aueb.gr/mirrors/linux/archlinux/$repo/os/$arch 63 | ## United Kingdom 64 | Server = http://archlinux.mirrors.uk2.net/$repo/os/$arch 65 | ## United States 66 | Server = http://repo.ialab.dsu.edu/archlinux/$repo/os/$arch 67 | ## Germany 68 | Server = http://ftp-stud.hs-esslingen.de/pub/Mirrors/archlinux/$repo/os/$arch 69 | ## Germany 70 | Server = http://ftp.spline.inf.fu-berlin.de/mirrors/archlinux/$repo/os/$arch 71 | ## Italy 72 | Server = http://archlinux.mirror.garr.it/archlinux/$repo/os/$arch 73 | ## United States 74 | Server = http://mirror.es.its.nyu.edu/archlinux/$repo/os/$arch 75 | ## China 76 | Server = http://mirrors.shu.edu.cn/archlinux/$repo/os/$arch 77 | ## Taiwan 78 | Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch 79 | ## Germany 80 | Server = http://mirrors.n-ix.net/archlinux/$repo/os/$arch 81 | ## Philippines 82 | Server = http://mirror.rise.ph/archlinux/$repo/os/$arch 83 | ## Germany 84 | Server = http://mirror.23media.com/archlinux/$repo/os/$arch 85 | ## Lithuania 86 | Server = http://mirrors.atviras.lt/archlinux/$repo/os/$arch 87 | ## Hungary 88 | Server = http://archmirror.hbit.sztaki.hu/archlinux/$repo/os/$arch 89 | ## Canada 90 | Server = http://mirror.sergal.org/archlinux/$repo/os/$arch 91 | ## Paraguay 92 | Server = http://archlinux.mirror.py/archlinux/$repo/os/$arch 93 | ## United States 94 | Server = http://mirror.umd.edu/archlinux/$repo/os/$arch 95 | ## China 96 | Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch 97 | ## United States 98 | Server = http://mirror.cs.vt.edu/pub/ArchLinux/$repo/os/$arch 99 | ## Belarus 100 | Server = http://ftp.byfly.by/pub/archlinux/$repo/os/$arch 101 | ## South Korea 102 | Server = http://mirror.premi.st/archlinux/$repo/os/$arch 103 | ## Poland 104 | Server = http://ftp.vectranet.pl/archlinux/$repo/os/$arch 105 | ## Brazil 106 | Server = http://pet.inf.ufsc.br/mirrors/archlinux/$repo/os/$arch 107 | ## Hungary 108 | Server = http://ftp.energia.mta.hu/pub/mirrors/ftp.archlinux.org/$repo/os/$arch 109 | ## Spain 110 | Server = http://mirror.librelabucm.org/archlinux/$repo/os/$arch 111 | ## Bulgaria 112 | Server = http://mirrors.netix.net/archlinux/$repo/os/$arch 113 | ## United States 114 | Server = http://mirror.siena.edu/archlinux/$repo/os/$arch 115 | ## Brazil 116 | Server = http://www.caco.ic.unicamp.br/archlinux/$repo/os/$arch 117 | ## Germany 118 | Server = http://archlinux.nullpointer.io/$repo/os/$arch 119 | ## France 120 | Server = http://mirror.cyberbits.eu/archlinux/$repo/os/$arch 121 | ## Switzerland 122 | Server = http://mirror.puzzle.ch/archlinux/$repo/os/$arch 123 | ## Germany 124 | Server = http://packages.oth-regensburg.de/archlinux/$repo/os/$arch 125 | ## Vietnam 126 | Server = http://f.archlinuxvn.org/archlinux/$repo/os/$arch 127 | ## United Kingdom 128 | Server = http://archlinux.uk.mirror.allworldit.com/archlinux/$repo/os/$arch 129 | ## China 130 | Server = http://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch 131 | ## Taiwan 132 | Server = http://ftp.yzu.edu.tw/Linux/archlinux/$repo/os/$arch 133 | ## Germany 134 | Server = http://mirror.wtnet.de/arch/$repo/os/$arch 135 | ## Netherlands 136 | Server = http://archlinux.mirror.wearetriple.com/$repo/os/$arch 137 | ## Luxembourg 138 | Server = http://archlinux.mirror.root.lu/$repo/os/$arch 139 | ## United States 140 | Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch 141 | ## Bangladesh 142 | Server = http://mirror.xeonbd.com/archlinux/$repo/os/$arch 143 | ## United Kingdom 144 | Server = http://mirrors.ukfast.co.uk/sites/archlinux.org/$repo/os/$arch 145 | ## Singapore 146 | Server = http://mirror.0x.sg/archlinux/$repo/os/$arch 147 | ## China 148 | Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch 149 | ## Italy 150 | Server = http://mirrors.prometeus.net/archlinux/$repo/os/$arch 151 | ## Greece 152 | Server = http://mirrors.myaegean.gr/linux/archlinux/$repo/os/$arch 153 | ## Brazil 154 | Server = http://mirror.ufam.edu.br/archlinux/$repo/os/$arch 155 | ## Romania 156 | Server = http://mirrors.nxthost.com/archlinux/$repo/os/$arch 157 | ## Czechia 158 | Server = http://ftp.linux.cz/pub/linux/arch/$repo/os/$arch 159 | ## Macedonia 160 | Server = http://mirror.t-home.mk/archlinux/$repo/os/$arch 161 | ## United States 162 | Server = http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch 163 | ## Sweden 164 | Server = http://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch 165 | ## Poland 166 | Server = http://arch.midov.pl/arch/$repo/os/$arch 167 | ## Japan 168 | Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch 169 | ## Indonesia 170 | Server = http://suro.ubaya.ac.id/archlinux/$repo/os/$arch 171 | ## Poland 172 | Server = http://piotrkosoft.net/pub/mirrors/ftp.archlinux.org/$repo/os/$arch 173 | ## Macedonia 174 | Server = http://arch.softver.org.mk/archlinux/$repo/os/$arch 175 | ## United States 176 | Server = http://il.us.mirror.archlinux-br.org/$repo/os/$arch 177 | ## Hong Kong 178 | Server = http://mirror.xtom.com.hk/archlinux/$repo/os/$arch 179 | ## South Africa 180 | Server = http://archlinux.za.mirror.allworldit.com/archlinux/$repo/os/$arch 181 | ## United States 182 | Server = http://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch 183 | ## Germany 184 | Server = http://mirror.netcologne.de/archlinux/$repo/os/$arch 185 | ## Romania 186 | Server = http://mirrors.m247.ro/archlinux/$repo/os/$arch 187 | ## France 188 | Server = http://ftp.u-strasbg.fr/linux/distributions/archlinux/$repo/os/$arch 189 | ## Germany 190 | Server = http://mirror.f4st.host/archlinux/$repo/os/$arch 191 | ## Finland 192 | Server = http://mirror.pseudoform.org/$repo/os/$arch 193 | ## Germany 194 | Server = http://archlinux.mirror.iphh.net/$repo/os/$arch 195 | ## Netherlands 196 | Server = http://archlinux.mirror.pcextreme.nl/$repo/os/$arch 197 | ## Russia 198 | Server = http://mirror.yandex.ru/archlinux/$repo/os/$arch 199 | ## United States 200 | Server = http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch 201 | ## Australia 202 | Server = http://mirror.internode.on.net/pub/archlinux/$repo/os/$arch 203 | ## Germany 204 | Server = http://ftp.uni-hannover.de/archlinux/$repo/os/$arch 205 | ## United States 206 | Server = http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch 207 | ## United Kingdom 208 | Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch 209 | ## United States 210 | Server = http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch 211 | ## South Africa 212 | Server = http://za.mirror.archlinux-br.org/$repo/os/$arch 213 | ## Denmark 214 | Server = http://mirror.one.com/archlinux/$repo/os/$arch 215 | ## United States 216 | Server = http://mirror.metrocast.net/archlinux/$repo/os/$arch 217 | ## Netherlands 218 | Server = http://mirror.koddos.net/archlinux/$repo/os/$arch 219 | ## Germany 220 | Server = http://mirror.metalgamer.eu/archlinux/$repo/os/$arch 221 | ## Serbia 222 | Server = http://mirror.pmf.kg.ac.rs/archlinux/$repo/os/$arch 223 | ## United States 224 | Server = http://mirrors.sonic.net/archlinux/$repo/os/$arch 225 | ## Germany 226 | Server = http://mirror.selfnet.de/archlinux/$repo/os/$arch 227 | ## Ukraine 228 | Server = http://archlinux.ip-connect.vn.ua/$repo/os/$arch 229 | ## Norway 230 | Server = http://mirror.neuf.no/archlinux/$repo/os/$arch 231 | ## United States 232 | Server = http://arlm.tyzoid.com/$repo/os/$arch 233 | ## Netherlands 234 | Server = http://mirror.i3d.net/pub/archlinux/$repo/os/$arch 235 | ## Germany 236 | Server = http://ftp.uni-bayreuth.de/linux/archlinux/$repo/os/$arch 237 | ## France 238 | Server = http://mirrors.arnoldthebat.co.uk/archlinux/$repo/os/$arch 239 | ## New Caledonia 240 | Server = http://mirror.lagoon.nc/pub/archlinux/$repo/os/$arch 241 | ## Netherlands 242 | Server = http://ftp.nluug.nl/os/Linux/distr/archlinux/$repo/os/$arch 243 | ## Japan 244 | Server = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch 245 | ## United Kingdom 246 | Server = http://www.mirrorservice.org/sites/ftp.archlinux.org/$repo/os/$arch 247 | ## Bulgaria 248 | Server = http://mirrors.uni-plovdiv.net/archlinux/$repo/os/$arch 249 | ## Worldwide 250 | Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch 251 | ## Germany 252 | Server = http://mirror.united-gameserver.de/archlinux/$repo/os/$arch 253 | ## Canada 254 | Server = http://archlinux.mirror.colo-serv.net/$repo/os/$arch 255 | ## Belgium 256 | Server = http://archlinux.mirror.kangaroot.net/$repo/os/$arch 257 | ## Spain 258 | Server = http://osl.ugr.es/archlinux/$repo/os/$arch 259 | ## United States 260 | Server = http://mirrors.gigenet.com/archlinux/$repo/os/$arch 261 | ## France 262 | Server = http://mir.archlinux.fr/$repo/os/$arch 263 | ## Romania 264 | Server = http://mirrors.pidginhost.com/arch/$repo/os/$arch 265 | ## Turkey 266 | Server = http://ftp.linux.org.tr/archlinux/$repo/os/$arch 267 | ## Qatar 268 | Server = http://mirror.qnren.qa/archlinux/$repo/os/$arch 269 | ## United States 270 | Server = http://trapbot.site/arch/$repo/os/$arch 271 | ## United States 272 | Server = http://mirrors.aggregate.org/archlinux/$repo/os/$arch 273 | ## United States 274 | Server = http://mirror.dc02.hackingand.coffee/arch/$repo/os/$arch 275 | ## Netherlands 276 | Server = http://mirror-archlinux.webruimtehosting.nl/$repo/os/$arch 277 | ## Germany 278 | Server = http://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch 279 | ## Germany 280 | Server = http://archlinux.thaller.ws/$repo/os/$arch 281 | ## Romania 282 | Server = http://archlinux.mirrors.linux.ro/$repo/os/$arch 283 | ## United States 284 | Server = http://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch 285 | ## New Zealand 286 | Server = http://mirror.smith.geek.nz/archlinux/$repo/os/$arch 287 | ## Brazil 288 | Server = http://archlinux.pop-es.rnp.br/$repo/os/$arch 289 | ## United States 290 | Server = http://archlinux.surlyjake.com/archlinux/$repo/os/$arch 291 | ## Germany 292 | Server = http://arch.eckner.net/archlinux/$repo/os/$arch 293 | ## Iceland 294 | Server = http://mirror.system.is/arch/$repo/os/$arch 295 | ## South Africa 296 | Server = http://mirror.is.co.za/mirror/archlinux.org/$repo/os/$arch 297 | ## Ukraine 298 | Server = http://mirrors.nix.org.ua/linux/archlinux/$repo/os/$arch 299 | ## France 300 | Server = http://mirror.ibcp.fr/pub/archlinux/$repo/os/$arch 301 | ## Russia 302 | Server = http://mirror.rol.ru/archlinux/$repo/os/$arch 303 | ## China 304 | Server = http://mirrors.163.com/archlinux/$repo/os/$arch 305 | ## Georgia 306 | Server = http://archlinux.grena.ge/$repo/os/$arch 307 | ## United States 308 | Server = http://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch 309 | ## Germany 310 | Server = http://arch.jensgutermuth.de/$repo/os/$arch 311 | ## Iran 312 | Server = http://repo.sadjad.ac.ir/arch/$repo/os/$arch 313 | ## Belgium 314 | Server = http://archlinux.cu.be/$repo/os/$arch 315 | ## United States 316 | Server = http://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch 317 | ## Ecuador 318 | Server = http://mirror.cedia.org.ec/archlinux/$repo/os/$arch 319 | ## France 320 | Server = http://mirrors.phx.ms/arch/$repo/os/$arch 321 | ## Worldwide 322 | Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch 323 | ## France 324 | Server = http://mirror.archlinux.ikoula.com/archlinux/$repo/os/$arch 325 | ## Hungary 326 | Server = http://quantum-mirror.hu/mirrors/pub/archlinux/$repo/os/$arch 327 | ## Colombia 328 | Server = http://mirrors.udenar.edu.co/archlinux/$repo/os/$arch 329 | ## Germany 330 | Server = http://ftp.wrz.de/pub/archlinux/$repo/os/$arch 331 | ## United States 332 | Server = http://mirror.cc.columbia.edu/pub/linux/archlinux/$repo/os/$arch 333 | ## Slovakia 334 | Server = http://tux.rainside.sk/archlinux/$repo/os/$arch 335 | ## Canada 336 | Server = http://archlinux.mirror.rafal.ca/$repo/os/$arch 337 | ## New Caledonia 338 | Server = http://archlinux.nautile.nc/archlinux/$repo/os/$arch 339 | ## Germany 340 | Server = http://ftp.tu-chemnitz.de/pub/linux/archlinux/$repo/os/$arch 341 | ## Brazil 342 | Server = http://mirror.ufscar.br/archlinux/$repo/os/$arch 343 | ## Australia 344 | Server = http://archlinux.melbourneitmirror.net/$repo/os/$arch 345 | ## Austria 346 | Server = http://mirror.easyname.at/archlinux/$repo/os/$arch 347 | ## Canada 348 | Server = http://mirror.csclub.uwaterloo.ca/archlinux/$repo/os/$arch 349 | ## Thailand 350 | Server = http://mirror2.totbb.net/archlinux/$repo/os/$arch 351 | ## France 352 | Server = http://archlinux.vi-di.fr/$repo/os/$arch 353 | ## Portugal 354 | Server = http://glua.ua.pt/pub/archlinux/$repo/os/$arch 355 | ## Iran 356 | Server = http://repo.iut.ac.ir/repo/archlinux/$repo/os/$arch 357 | ## Australia 358 | Server = http://ftp.iinet.net.au/pub/archlinux/$repo/os/$arch 359 | ## Canada 360 | Server = http://muug.ca/mirror/archlinux/$repo/os/$arch 361 | ## France 362 | Server = http://archlinux.polymorf.fr/$repo/os/$arch 363 | ## Thailand 364 | Server = http://mirror.kku.ac.th/archlinux/$repo/os/$arch 365 | ## Germany 366 | Server = http://artfiles.org/archlinux.org/$repo/os/$arch 367 | ## Austria 368 | Server = http://mirror.reisenbauer.ee/archlinux/$repo/os/$arch 369 | ## Germany 370 | Server = http://ftp.gwdg.de/pub/linux/archlinux/$repo/os/$arch 371 | ## Taiwan 372 | Server = http://shadow.ind.ntou.edu.tw/archlinux/$repo/os/$arch 373 | ## Russia 374 | Server = http://mirror.aur.rocks/$repo/os/$arch 375 | ## Ecuador 376 | Server = http://mirror.uta.edu.ec/archlinux/$repo/os/$arch 377 | ## Germany 378 | Server = http://ftp.uni-kl.de/pub/linux/archlinux/$repo/os/$arch 379 | ## Indonesia 380 | Server = http://mirror.poliwangi.ac.id/archlinux/$repo/os/$arch 381 | ## Germany 382 | Server = http://mirrors.niyawe.de/archlinux/$repo/os/$arch 383 | ## Germany 384 | Server = http://archmirror.nebulanet.cc/$repo/os/$arch 385 | ## Germany 386 | Server = http://mirror.thomaskilian.net/archlinux/$repo/os/$arch 387 | ## Denmark 388 | Server = http://mirrors.dotsrc.org/archlinux/$repo/os/$arch 389 | ## Russia 390 | Server = http://archlinux.zepto.cloud/$repo/os/$arch 391 | ## New Zealand 392 | Server = http://mirror.fsmg.org.nz/archlinux/$repo/os/$arch 393 | ## Czechia 394 | Server = http://ftp.fi.muni.cz/pub/linux/arch/$repo/os/$arch 395 | ## Portugal 396 | Server = http://ftp.rnl.tecnico.ulisboa.pt/pub/archlinux/$repo/os/$arch 397 | ## Latvia 398 | Server = http://archlinux.koyanet.lv/archlinux/$repo/os/$arch 399 | ## Netherlands 400 | Server = http://archmirror.lavatech.top/$repo/os/$arch 401 | ## United States 402 | Server = http://mirrors.liquidweb.com/archlinux/$repo/os/$arch 403 | ## Slovakia 404 | Server = http://mirror.lnx.sk/pub/linux/archlinux/$repo/os/$arch 405 | ## Hong Kong 406 | Server = http://mirror-hk.koddos.net/archlinux/$repo/os/$arch 407 | ## Romania 408 | Server = http://mirrors.nav.ro/archlinux/$repo/os/$arch 409 | ## United States 410 | Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch 411 | ## Brazil 412 | Server = http://archlinux.c3sl.ufpr.br/$repo/os/$arch 413 | ## United States 414 | Server = http://mirrors.rutgers.edu/archlinux/$repo/os/$arch 415 | ## India 416 | Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch 417 | ## Greece 418 | Server = http://ftp.ntua.gr/pub/linux/archlinux/$repo/os/$arch 419 | ## United Kingdom 420 | Server = http://arch.serverspace.co.uk/arch/$repo/os/$arch 421 | ## Czechia 422 | Server = http://mirror.vpsfree.cz/archlinux/$repo/os/$arch 423 | ## Japan 424 | Server = http://mirrors.cat.net/archlinux/$repo/os/$arch 425 | ## Australia 426 | Server = http://archlinux.mirror.digitalpacific.com.au/$repo/os/$arch 427 | ## France 428 | Server = http://mirrors.celianvdb.fr/archlinux/$repo/os/$arch 429 | ## Austria 430 | Server = http://mirror.digitalnova.at/archlinux/$repo/os/$arch 431 | ## France 432 | Server = http://mirrors.standaloneinstaller.com/archlinux/$repo/os/$arch 433 | ## United Kingdom 434 | Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch 435 | ## Germany 436 | Server = http://mirror.checkdomain.de/archlinux/$repo/os/$arch 437 | ## China 438 | Server = http://mirror.lzu.edu.cn/archlinux/$repo/os/$arch 439 | ## United States 440 | Server = http://arch.mirror.constant.com/$repo/os/$arch 441 | ## Germany 442 | Server = http://linux.rz.rub.de/archlinux/$repo/os/$arch 443 | ## Spain 444 | Server = http://ftp.rediris.es/mirror/archlinux/$repo/os/$arch 445 | ## France 446 | Server = http://arch.nimukaito.net/$repo/os/$arch 447 | ## Poland 448 | Server = http://mirror.onet.pl/pub/mirrors/archlinux/$repo/os/$arch 449 | ## Netherlands 450 | Server = http://mirror.netrouting.net/archlinux/$repo/os/$arch 451 | ## United States 452 | Server = http://arch.mirror.square-r00t.net/$repo/os/$arch 453 | ## Czechia 454 | Server = http://mirror.dkm.cz/archlinux/$repo/os/$arch 455 | ## Greece 456 | Server = http://ftp.cc.uoc.gr/mirrors/linux/archlinux/$repo/os/$arch 457 | ## South Korea 458 | Server = http://ftp.kaist.ac.kr/ArchLinux/$repo/os/$arch 459 | ## Colombia 460 | Server = http://mirror.upb.edu.co/archlinux/$repo/os/$arch 461 | ## United States 462 | Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch 463 | ## France 464 | Server = http://archlinux.mailtunnel.eu/$repo/os/$arch 465 | ## United States 466 | Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch 467 | ## United States 468 | Server = http://mirrors.xtom.com/archlinux/$repo/os/$arch 469 | ## Hong Kong 470 | Server = http://mirrors.kurnode.com/archlinux/$repo/os/$arch 471 | ## Russia 472 | Server = http://mirror.truenetwork.ru/archlinux/$repo/os/$arch 473 | ## Czechia 474 | Server = http://mirrors.nic.cz/archlinux/$repo/os/$arch 475 | ## Canada 476 | Server = http://archlinux.olanfa.rocks/$repo/os/$arch 477 | ## Singapore 478 | Server = http://mirror.nus.edu.sg/archlinux/$repo/os/$arch 479 | ## Germany 480 | Server = http://archlinux.honkgong.info/$repo/os/$arch 481 | ## Taiwan 482 | Server = http://ftp.tku.edu.tw/Linux/ArchLinux/$repo/os/$arch 483 | ## United States 484 | Server = http://repo.miserver.it.umich.edu/archlinux/$repo/os/$arch 485 | ## United States 486 | Server = http://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch 487 | ## United States 488 | Server = http://ca.us.mirror.archlinux-br.org/$repo/os/$arch 489 | ## Brazil 490 | Server = http://linorg.usp.br/archlinux/$repo/os/$arch 491 | ## Hungary 492 | Server = http://ftp.gtx.hu/archlinux/$repo/os/$arch 493 | ## Germany 494 | Server = http://mirror.orbit-os.com/archlinux/$repo/os/$arch 495 | ## Canada 496 | Server = http://mirror.its.dal.ca/archlinux/$repo/os/$arch 497 | ## Germany 498 | Server = http://mirror.ubrco.de/archlinux/$repo/os/$arch 499 | ## United States 500 | Server = http://mirror.stephen304.com/archlinux/$repo/os/$arch 501 | ## United States 502 | Server = http://distro.ibiblio.org/archlinux/$repo/os/$arch 503 | ## Germany 504 | Server = http://ftp.hosteurope.de/mirror/ftp.archlinux.org/$repo/os/$arch 505 | ## Macedonia 506 | Server = http://mirror.onevip.mk/archlinux/$repo/os/$arch 507 | ## Switzerland 508 | Server = http://pkg.adfinis-sygroup.ch/archlinux/$repo/os/$arch 509 | ## Sweden 510 | Server = http://archlinux.dynamict.se/$repo/os/$arch 511 | ## Czechia 512 | Server = http://gluttony.sin.cvut.cz/arch/$repo/os/$arch 513 | ## Kenya 514 | Server = http://archlinux.mirror.liquidtelecom.com/$repo/os/$arch 515 | ## Chile 516 | Server = http://mirror.archlinux.cl/$repo/os/$arch 517 | ## Finland 518 | Server = http://arch.mirror.far.fi/$repo/os/$arch 519 | ## Kazakhstan 520 | Server = http://mirror.ps.kz/archlinux/$repo/os/$arch 521 | ## Slovenia 522 | Server = http://archimonde.ts.si/archlinux/$repo/os/$arch 523 | ## Germany 524 | Server = http://www.gutscheindrache.com/mirror/archlinux/$repo/os/$arch 525 | ## France 526 | Server = http://archlinux.de-labrusse.fr/$repo/os/$arch 527 | ## United States 528 | Server = http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch 529 | ## Sweden 530 | Server = http://ftp.acc.umu.se/mirror/archlinux/$repo/os/$arch 531 | ## United States 532 | Server = http://mirrors.rit.edu/archlinux/$repo/os/$arch 533 | ## Croatia 534 | Server = http://archlinux.iskon.hr/$repo/os/$arch 535 | ## United States 536 | Server = http://arch.mirrors.pair.com/$repo/os/$arch 537 | ## United States 538 | Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch 539 | ## Germany 540 | Server = http://ftp.fau.de/archlinux/$repo/os/$arch 541 | ## Netherlands 542 | Server = http://mirror.neostrada.nl/archlinux/$repo/os/$arch 543 | ## United States 544 | Server = http://mirror.kaminski.io/archlinux/$repo/os/$arch 545 | ## France 546 | Server = http://mirror.lastmikoi.net/archlinux/$repo/os/$arch 547 | ## South Korea 548 | Server = http://ftp.lanet.kr/pub/archlinux/$repo/os/$arch 549 | ## Germany 550 | Server = http://mirror.fra10.de.leaseweb.net/archlinux/$repo/os/$arch 551 | ## United States 552 | Server = http://mirror.3of.com.br/$repo/os/$arch 553 | 554 | -------------------------------------------------------------------------------- /dub.sdl: -------------------------------------------------------------------------------- 1 | name "python-dpp-nanomsg" 2 | targetType "dynamicLibrary" 3 | dependency "autowrap:pynih" path="/home/atila/kaleidic/autowrap" 4 | preGenerateCommands "make -C $PACKAGE_DIR source/nanomsg.d" 5 | libs "nanomsg" 6 | -------------------------------------------------------------------------------- /dub.selections.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileVersion": 1, 3 | "versions": { 4 | "autowrap": "0.5.1", 5 | "mirror": "0.1.6", 6 | "unit-threaded": "0.10.4" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /source/app.d: -------------------------------------------------------------------------------- 1 | import autowrap; 2 | mixin(wrapDlang!(LibraryName("nanomsg"), Modules(Yes.alwaysExport, "nanomsg"))); 3 | -------------------------------------------------------------------------------- /source/nanomsg.dpp: -------------------------------------------------------------------------------- 1 | #include "nanomsg/nn.h" 2 | #include "nanomsg/pipeline.h" 3 | -------------------------------------------------------------------------------- /tests/test_nanomsg.py: -------------------------------------------------------------------------------- 1 | def test_push_pull(): 2 | from nanomsg import (nn_socket, nn_close, nn_bind, nn_connect, 3 | nn_send, nn_recv, 4 | AF_SP, NN_PUSH, NN_PULL) 5 | import time 6 | 7 | uri = "inproc://test" 8 | 9 | pull = nn_socket(AF_SP, NN_PULL) 10 | raise_on_nanomsg_error(pull) 11 | raise_on_nanomsg_error(nn_bind(pull, uri)) 12 | time.sleep(0.05) 13 | 14 | push = nn_socket(AF_SP, NN_PUSH) 15 | raise_on_nanomsg_error(push) 16 | raise_on_nanomsg_error(nn_connect(push, uri)) 17 | msg = b'abc' 18 | assert nn_send(push, msg, len(msg), 0) == len(msg) 19 | 20 | time.sleep(0.05) 21 | # horrible but works, essentially unsigned char buf[100] 22 | buf = 100 * b'o' 23 | assert nn_recv(pull, buf, len(buf), 0) == len(msg) 24 | assert buf[0:len(msg)] == msg 25 | 26 | raise_on_nanomsg_error(nn_close(push)) 27 | raise_on_nanomsg_error(nn_close(pull)) 28 | 29 | 30 | def raise_on_nanomsg_error(errorcode): 31 | from nanomsg import nn_strerror 32 | import ctypes 33 | 34 | if errorcode < 0: 35 | raise RuntimeError(nn_strerror(ctypes.get_errno())) 36 | --------------------------------------------------------------------------------