编辑使用Setuptools编译文件的位置

发布于 2025-01-29 11:00:57 字数 578 浏览 3 评论 0原文

我正在使用setuptools使用Cython使用以下代码来编译PYX文件

from Cython.Distutils import build_ext

extensions=[Extension("filtering.filter", "filtering/filter.pyx")

setup(
   name="..",
   ........
   ext_modules=extensions,
   cmdclass={"build_ext", build_ext}
   include_dirs=[".", numpy.get_include()]
)

。 /代码> 运行PIP安装。它正确地编译了文件,但将其存储在错误的位置,它将其存储在filtering/而不是my_project/filtering/

我尝试使用setup.cfg使用inplace = 1,也尝试了build> build_lib =。。放置 任何帮助都赞赏

I am using setuptools to compile a pyx file using Cython using the following code in my setup.py

from Cython.Distutils import build_ext

extensions=[Extension("filtering.filter", "filtering/filter.pyx")

setup(
   name="..",
   ........
   ext_modules=extensions,
   cmdclass={"build_ext", build_ext}
   include_dirs=[".", numpy.get_include()]
)

I want to use pip install . to install this rather than python setup.py ...
When running pip install . it compiles the file correctly, but stores it in the wrong place, it stores it in filtering/ rather than my_project/filtering/

I have tried using a setup.cfg with inplace=1 and also tried build_lib=. but this does not put it in the correct place either
Any help appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在梵高的星空下 2025-02-05 11:00:58

我正在编写一个软件包,其中所有代码都在src目录中,此方法对我来说很好。

软件包结构

src
 |-- foo
 |   |-- foo.pyx
 |
 |-- setup.py
 |-- setup.cfg
 |-- (.toml, LICENSE ... )

setup.cfg

[metadata]
.
.
.
[options]
packages = find:
package_dir = src
.
.
.
[options.packages.find]
where = src

setup.py

from setuptools import setup
from setuptools.extension import Extension
from Cython.Build import cythonize

ext_modules = [
    Extension(
        name = "foo.foo.pyx",
        sources = ["src/foo/foo.pyx"]
    )
]

if __name__ == "__main__":

    setup(
        ext_modules=cythonize(ext_modules)
    )

我不确定.cfg文件的最后一部分是否是文件(其中...)严格必要。

I'm writing a package in which all the code goes inside the src directory, and this approach works fine for me.

Package structure

src
 |-- foo
 |   |-- foo.pyx
 |
 |-- setup.py
 |-- setup.cfg
 |-- (.toml, LICENSE ... )

setup.cfg

[metadata]
.
.
.
[options]
packages = find:
package_dir = src
.
.
.
[options.packages.find]
where = src

setup.py

from setuptools import setup
from setuptools.extension import Extension
from Cython.Build import cythonize

ext_modules = [
    Extension(
        name = "foo.foo.pyx",
        sources = ["src/foo/foo.pyx"]
    )
]

if __name__ == "__main__":

    setup(
        ext_modules=cythonize(ext_modules)
    )

I'm not sure if the last part of the .cfg file (where ...) is strictly necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文