首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为pip配置Python C扩展

为pip配置Python C扩展
EN

Stack Overflow用户
提问于 2020-04-27 05:29:49
回答 1查看 270关注 0票数 0

我写了一个Python C扩展,它工作得很好。通过python setup.py install works进行安装。但是,pip找不到我的头文件-所以pip安装不起作用。

代码语言:javascript
复制
> pip install
Collecting jcalg1==1.0.1
  Downloading https://files.pythonhosted.org/packages/a1/83/08b5fc2fbd36c8ac0668ae64c05cc88f3f6bd8fe68f058b19b11a463afa1/jcalg1-1.0.1.tar.gz
Installing collected packages: jcalg1
  Running setup.py install for jcalg1 ... error
    ERROR: Command errored out with exit status 1:
(...)
src\main.cpp(7): fatal error C1083: Cannot open include file: 'jcalg1.h': No such file or directory
(...)

这是我的setup.py,头文件位于src文件夹中。

代码语言:javascript
复制
from setuptools import setup,Extension
import setuptools
from setuptools import find_packages
import pathlib

# The actual C extension
jc_module = Extension('jcalg1', include_dirs=["src"], sources = ['src\main.cpp'], libraries =["src\jcalg1_static"])

# The directory containing this file
HERE = pathlib.Path(__file__).parent

# The text of the README file
README = (HERE / "README.md").read_text()

# This call to setup() does all the work
setup(
    name="jcalg1",
    version="1.0.1",
    description="Interface to the JCALG1 compression library",
    long_description=README,
    long_description_content_type="text/markdown",
    url="https://github.com/CallMeAlexO/jcalg1",
    author="Alex Osheter",
    author_email="alex.osheter@gmail.com",
    license="MIT",
    classifiers=[
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.7",
    ],
    ext_modules = [ jc_module ],
    packages=find_packages()
)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-28 09:03:28

您可以在项目根目录中创建MANIFEST.in文件:

代码语言:javascript
复制
include src\*.h

include src\*.lib

然后重新构建您的包。它会将头文件和库文件添加到您的包中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61448363

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档