astonishing-fish-21892
10/07/2020, 6:33 AM(env)$ cd ode-0.16.2
(env)$ ./configure --enable-double-precision --with-trimesh=opcode --enable-new-trimesh --enable-shared
(env)$ make
(env)$ make install
(env)$ cd bindings/python/
(env)$ pip install cython
(env)$ pip install .
Thread in #generalastonishing-fish-21892
10/07/2020, 6:35 AMI think your approach would be very similar, that you create a custom target and then add a codegen implementation to convert your C code into whatever the artifact type is. (What’s the file extension?)This is what the artifact(s) look like after compilation:
tyler@DESKTOP-5PA52E3:~/ode-test/ode-0.16.2/bindings/python$ tree
.
├── INSTALL.txt
├── TODO.txt
├── demos
│ ├── tutorial1.py
│ ├── tutorial2.py
│ └── tutorial3.py
├── ode.pxd
├── ode.pyx
└── setup.py
1 directory, 8 files
astonishing-fish-21892
10/07/2020, 6:36 AMhundreds-father-404
10/07/2020, 6:39 AM.py
files and resource files like like .txt
files.
That should work just fine if true; you’re going to have two different codegen rules, one to generate PythonSources
and another to generate ResourcesSources
. Thanks to the engine’s design, you could have it so that you still only run the subprocess once to run compilation; both codegen rules can rely on the same compilationastonishing-fish-21892
10/07/2020, 6:40 AMastonishing-fish-21892
10/07/2020, 6:40 AMastonishing-fish-21892
10/07/2020, 6:42 AMhundreds-father-404
10/07/2020, 6:43 AMone target to compile the codeRather than multiple targets, I suspect you might want one target, but multiple rules. Rules are where you define the logic of your plugin, such as running compilation. Targets are simply a declarative way to attach metadata to some code, such as saying “These 5 files are all used for my Cython plugin. They depend on these 3 other files.” You will likely want a target like
cython_library
or c_project
which describes the initial C files.
Your rules then will use the codegen plugin hook to convert the CSources to PythonSources, etc.hundreds-father-404
10/07/2020, 6:43 AMThey’re not actually generated by the compilation processOkay, what files are being generated?
astonishing-fish-21892
10/07/2020, 6:44 AMastonishing-fish-21892
10/07/2020, 6:48 AMmake
is actually doing.... truth is, I can't quite figure it out... one moment...hundreds-father-404
10/07/2020, 6:48 AMastonishing-fish-21892
10/07/2020, 6:50 AMmake
here is actually just making .o
files for every single corresponding source file, then make install
is actually linking them up into `.so`'s. Very strange, I've never seen code do something like that before. The important element is that it drops /usr/local/lib/libode.so
and it drops /usr/local/include/ode/
hundreds-father-404
10/07/2020, 6:53 AM.pyx
files into .so
resources, from what I understand. In Pants terms, the codegen will go from CythonSources -> ResourcesSources
Check out Noah’s thread for the setup.py
command. On the Cython docs, it looks like there are multiple ways to invoke Cython. Using setup.py
may end up being easier, but we should also be able to get things working with your current workflowastonishing-fish-21892
10/07/2020, 6:53 AMastonishing-fish-21892
10/07/2020, 6:54 AMtyler@DESKTOP-5PA52E3:~/ode-test/ode-0.16.2/bindings/python$ cat setup.py
#! /usr/bin/env python
from distutils.core import setup
from distutils.extension import Extension
from subprocess import Popen, PIPE, CalledProcessError
try:
from Cython.Distutils import build_ext
except ImportError:
raise SystemExit("Requires Cython (<http://cython.org/>)")
try:
ode_cflags = Popen(
["pkg-config", "--cflags", "ode"],
stdout=PIPE).stdout.read().decode('ascii').split()
ode_libs = Popen(
["pkg-config", "--libs", "ode"],
stdout=PIPE).stdout.read().decode('ascii').split()
except (OSError, CalledProcessError):
raise SystemExit("Failed to find ODE with 'pkg-config'. Please make sure "
"that it is installed and available on your system path.")
ode_ext = Extension("ode", ["ode.pyx"],
extra_compile_args=ode_cflags,
extra_link_args=ode_libs)
if __name__ == "__main__":
setup(
name="Open Dynamics Engine",
version="0.12",
author="Gideon Klompje",
# author_email="",
# maintainer="",
# maintainer_email="",
url="<http://www.ode.org>",
description="Bindings for the Open Dynamics Engine",
long_description=(
"A free, industrial quality library for simulating articulated "
"rigid body dynamics - for example ground vehicles, legged "
"creatures, and moving objects in VR environments. It's fast, "
"flexible & robust. Built-in collision detection."),
# download_url="<https://opende.svn.sourceforge.net/svnroot/opende>",
# classifiers=[],
# platforms=[],
license="BSD License, GNU Lesser General Public License (LGPL)",
cmdclass={"build_ext": build_ext},
ext_modules=[ode_ext]
)
astonishing-fish-21892
10/07/2020, 6:54 AMhundreds-father-404
10/07/2020, 6:55 AMastonishing-fish-21892
10/07/2020, 6:56 AMhundreds-father-404
10/07/2020, 3:35 PM