3

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

an offer can't refuse
  • 4,245
  • 5
  • 30
  • 50

2 Answers2

2

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.

Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455
0

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
        }
    },
)
vladsiv
  • 2,718
  • 1
  • 11
  • 21
Kramer84
  • 47
  • 6