specify *.pyd output path?

In this post, the answer is for the output path of .c files.

I want to know how can I output all the .pyd file to a specific directory (by default, it mingles with the source code), for example, the directory pyd/ in the source code.

enter image description here

Upvotes: 3

Views: 1265

Answers (2)

Kramer84
Kramer84

Reputation: 47

I stumbeled upon a similar problem and found a solution here.

When writing your setup.py file you can directly specify the command line arguments, rather than passing them during execution :

from psutil import cpu_count
from setuptools import setup
from Cython.Build import cythonize

build_directory = "./build"  # Here you will have your C or C files

pyd_directory = "./pyd/"  # The directory for your pyd file
pyx_name = "your_cython_script.pyx"

setup(
    ext_modules=cythonize(
        pyx_name,
        annotate=True,  # Generate html
        language_level=3,  # Python 3
        nthreads=cpu_count(logical=True),  # Faster compilation
        build_dir=build_directory,
    ),  # Build directory
    options={
        "build": {  # Here you can specify all the command-line arguments
            "build_lib": pyd_directory
        }
    },
)

Upvotes: 0

You can pass the command-line argument --build-lib your/desired/output/path to the python invocation which executes setup.py.

Also, this option is not compatible with --inplace. If you're using that, remove it.

Upvotes: 2

Related Questions