-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't build with setup.py build #122
Comments
Here is What my setup.py looks like: from pyd.support import setup, Extension
projName = "Epidemiad"
setup(
name=projName,
version='0.1',
ext_modules=[
Extension(projName, ['source/models.d'],
extra_compile_args=['-w'],
build_deimos=True,
d_lump=True
)
],
) and here is my dub.conf: {
"authors": [
"Flávio Codeco Coelho"
],
"copyright": "Copyright © 2019, Flávio Codeco Coelho",
"dependencies": {
"mir": "~>3.2.0",
"mir-algorithm": "~>3.5.5",
"mir-random": "~>2.2.6",
"pyd": "~>0.12.0"
},
"description": "Stochastic SIR model in D",
"license": "MIT",
"name": "epidemiad",
"sourcePaths": [
"source/"
],
"subConfigurations": {
"pyd": "python37"
}
} |
looks like Extension accepts arguments libraries, include_dirs, and library_dirs as lists of strings. these would correspond to -l -I<include_dir> -L<library_dir> on the dmd command line, so if you can figure out what dub is feeding your compiler, it might be possible to get it building with setup.py |
I'll give it a shot, but it would be nice if Extension could get that info straight from dub.conf, when it's available. Do you think that would be feasible? this would make it much easier for newcomers to PyD like me. |
I have added my any other suggestions? |
I got it to build after adding various Mir related directories to from pyd.support import setup, Extension
projName = "Epidemiad"
setup(
name=projName,
version='0.1',
ext_modules=[
Extension(projName, ['source/models.d'],
include_dirs=['~/.dub/packages/mir-random-2.2.6/mir-random/source',
'~/.dub/packages/mir-core-1.0.2/mir-core/source/',
'~/.dub/packages/mir-3.2.0/mir/source/',
'~/.dub/packages/mir-linux-kernel-1.0.1/mir-linux-kernel/source/',
'~/.dub/packages/mir-algorithm-3.5.5/mir-algorithm/source/'
],
# extra_compile_args=['-w'],
build_deimos=True,
d_lump=True
)
],
) but now I am getting the the following error when I try to import it: In [1]: import Epidemiad
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-a8bc7d58532c> in <module>
----> 1 import Epidemiad
ImportError: /home/fccoelho/Documentos/Aulas/FGV_Programming_Languages/D/Exercicios/Epidemia/epidemiad/build/lib.linux-x86_64-3.7/Epidemiad.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _D3mir6random12__ModuleInfoZ |
If this simple example gets sorted it can become a good example of using PyD in a project making use of Mir. ;-) |
seems like there ought to be library references whenever there are include directories. the latter tells the compile step that the included symbols exist, but the link step needs the libraries. I haven't used dub in a while, I'm assuming it isn't just globbing the sources of all the dependencies into the compile of your application. |
{
...
"targets": [
{
"rootPackage": "epidemiad",
"packages": [
"epidemiad",
"mir"
],
"rootConfiguration": "application",
"buildSettings": {
"targetType": 2,
"targetPath": "/home/fccoelho/Documentos/Aulas/FGV_Programming_Languages/D/Exercicios/Epidemia/epidemiad",
"targetName": "epidemiad",
"workingDirectory": "",
"mainSourceFile": "/home/fccoelho/Documentos/Aulas/FGV_Programming_Languages/D/Exercicios/Epidemia/epidemiad/source/app.d",
"dflags": [],
"lflags": [],
"libs": [
"python3.7m"
],
"linkerFiles": [
"/home/fccoelho/.dub/packages/mir-random-2.2.6/mir-random/libmir-random.a",
"/home/fccoelho/.dub/packages/mir-algorithm-3.5.6/mir-algorithm/libmir-algorithm.a",
"/home/fccoelho/.dub/packages/mir-core-1.0.2/mir-core/libmir-core.a",
"/home/fccoelho/.dub/packages/mir-linux-kernel-1.0.1/mir-linux-kernel/libmir-linux-kernel.a",
"/home/fccoelho/.dub/packages/pyd-0.12.0/pyd/libpyd.a"
],
"sourceFiles": [
"/home/fccoelho/Documentos/Aulas/FGV_Programming_Languages/D/Exercicios/Epidemia/epidemiad/source/app.d",
"/home/fccoelho/Documentos/Aulas/FGV_Programming_Languages/D/Exercicios/Epidemia/epidemiad/source/models.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/glas/l1.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/glas/l2.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/glas/package.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/model/lda/hoffman.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/sparse/blas/axpy.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/sparse/blas/dot.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/sparse/blas/gemm.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/sparse/blas/gemv.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/sparse/blas/package.d",
"/home/fccoelho/.dub/packages/mir-3.2.0/mir/source/mir/sparse/package.d"
],
...
} I tried using the linker files above as libraries but it didn't work. |
seems you want to put those linkerFiles in the parameter extra_link_args like so:
|
Thanks a lot @ariovistus ! it worked! from pyd.support import setup, Extension
import os, json
f = os.popen('dub describe')
build_pars = json.loads(f.read())['targets'][0]['buildSettings']
projName = "epidemiad"
setup(
name=projName,
version='0.1',
ext_modules=[
Extension(projName, ['source/models.d'],
include_dirs=build_pars['importPaths'],
extra_link_args=build_pars['linkerFiles'],
# extra_compile_args=['-w'],
build_deimos=True,
d_lump=True
)
],
) Now I can import the library which is built with |
I have a small Pyd project with a single module which builds and runs normally with dub, but is raising the following error when I try to build it with
python setup.py build
:It seems that it can't find the
variable
package from withinmir
Is there another way to build it with dub into a library which can be imported from Python?
The text was updated successfully, but these errors were encountered: