symmetryinvestments / autowrap

Wrap existing D code for use in Python, Excel, C#
BSD 3-Clause "New" or "Revised" License
80 stars 16 forks source link

Error: module python is in file 'autowrap/python.d' which cannot be read #247

Closed tastyminerals closed 4 years ago

tastyminerals commented 4 years ago

I am obviously doing something wrong. I want to make a small D library available for Python. I followed the README and created a dub project with just one source/app.d file containing:

import autowrap.python;
mixin(wrapAll(LibraryName("demo_for_python"), Modules("my_d_lib"),));

dub.sdl

name "demo_for_python"
description "A minimal D application."
dependency "my_d_lib" version="~>0.0.1"
dependency "autowrap" version="~>0.5.2"
targetType "dynamicLibrary"

Issuing dub build gives me the following error.

Running pre-generate commands for autowrap:pynih...
make: Entering directory '/home/tasty/.dub/packages/autowrap-0.5.2/autowrap/pynih'
make: 'source/python/raw.d' is up to date.
make: Leaving directory '/home/tasty/.dub/packages/autowrap-0.5.2/autowrap/pynih'
Performing "debug" build using /usr/bin/dmd for x86_64.
mir-core 1.1.7: target for configuration "library" is up to date.
mir-algorithm 3.8.13: target for configuration "default" is up to date.
my_d_lib 0.0.1: target for configuration "library" is up to date.
demo_for_python ~master: building configuration "library"...
source/app.d(1,8): Error: module python is in file 'autowrap/python.d' which cannot be read
import path[0] = source/
import path[1] = ../../.dub/packages/my_d_lib-0.0.1/my_d_lib/source/
import path[2] = ../../.dub/packages/mir-algorithm-3.8.13/mir-algorithm/source/
import path[3] = ../../.dub/packages/mir-core-1.1.7/mir-core/source/
import path[4] = /usr/include/dmd/phobos
import path[5] = /usr/include/dmd/druntime/import
/usr/bin/dmd failed with exit code 1.
atilaneves commented 4 years ago

Two things.

First, you should depend on autowrap:python. It doesn't make sense to autowrap for multiple languages at once.

Second, autowrap:python right now defaults to the pyd backend, and due to how pyd works, you're going to have to select a subconfiguration for your Python version, or the env configuration for just using what's in the environment (i.e. your current virtualenv). So:

dependency "autowrap:python" version="~>0.5.2"

and either:

subConfiguration "autowrap:python" "python37"

(assuming you have Python 3.7), or:

subConfiguration "autowrap:python" "env"

I recommend "env".