AutoCython-jianjun


NameAutoCython-jianjun JSON
Version 1.3.4 PyPI version JSON
download
home_pageNone
Summary自动Cython,使用Cython批量编译.py文件为.pyd文件!
upload_time2024-05-06 04:52:54
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseMIT License Copyright (c) [2024] [JianJun] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords cython compile pyd pyc python autopyd
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AutoCython

**自动 Cython, 使用 Cython 批量编译 `.py` 文件为 `.pyd` 文件!**
![py_pyd][1]

## 安装

    pip install AutoCython-jianjun

## 依赖

[Cython](https://github.com/cython/cython) 和 C/C++ 编译器

**如果你都配置完毕了你可以跳过本节.**

### Cython

```
pip install Cython
```

### C/C++ 编译器

推荐 `gcc` 和 `visual studio` 选一个, 其他编译器请查阅 Cython 文档.

* `VS` 安装简便, 占用空间大, 配置简单.
* `gcc` 安装简便, 占用空间小, 配置比较复杂.

不想折腾或者你是 Windows 的话推荐安装 VS, Linux 等系统可以直接使用自带的 gcc。

大部分的编译环境都可以使用, 我在 Win, Linux, Mac, Python3.6 到 Python3.10 都可以使用.

**需要注意的是, 如果你使用的 Python 是64位的, 那么对应的 C、C++ 编译器也必须为64位;**

**win下gcc推荐安装MinGW**:

* 64位:<http://mingw-w64.org/>
* 32位:<http://www.mingw.org/>

## 使用

![命令行][11]

### 命令行

使用命令行进行编译:

`AutoCython -h` 或者 `AutoCython --ch` 查看英文和中文帮助.

    # 编译一个文件
    AutoCython -f test.py

    # 编译一个目录
    AutoCython -C D:/python_code/ProjectPath

![AutoCython][2]

**例子**

编译目录 `D:/python_code/ProjectPath`\
排除所有名为 `tmp.py` 的文件\
排除 `./ProjectPath/print_cy.py` 文件\
排除 `./ProjectPath/data/tmp` 目录下的文件不编译\
使用2个CPU核心\
只删除编译后产生的 `build` 文件夹和中间文件 `setup_file`, 保留自动生成的 `C` 代码.\

    AutoCython -C D:/python_code/ProjectPath -E tmp.py;./ProjectPath/print_cy.py;./ProjectPath/data/tmp -M 2 -D bp

## 特性

* **全自动**:自动编译当前目录下所有.py文件, 支持指定目录编译或单文件编译;
* **个性化**:支持指定排除目录或排除文件跳过编译;
* **高效率**:默认启动进程数为cpu核心数四分之一, 大多数情况下可以把cpu跑满;
* **易纠错**:快速纠错, 在编译失败时能极快的获取错误信息;

### 常见错误

* `print(end='')`\
Cython 不支持 print 函数的 end 参数, 可以在外部定义 `def my_print(*args, **kwargs): print(*args, end='', **kwargs)`, 然后在需要编译的文件中导入这个外部函数.

* `新建文本文档.py`\
文件名需要符合  `C` 命名规范

其他问题请查阅 `Cython` 官方文档.

### 手动指定不编译

在不需要编译的文件 **头两行** 任意一行写上 `# AucoCython No Compile` 则该文件会跳过编译.

## 更新记录
1. 20220613 更新对Linux的支持, Linux下需要配置gcc&g++
2. 20221123 可以通过文件头手动指定不编译的文件
3. 20230306 更新可以指定命令行头如 `Python310` 以此支持非Widnows系统下编译
4. 20230324 更新文档
5. 20240506 修复编译失败时遗漏复原 __init__.py 的问题

  [1]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20210824.png
  [2]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_2.jpg
  [3]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_3.jpg
  [4]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_4.jpg
  [5]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_5.jpg
  [6]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_6.jpg
  [7]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_7.jpg
  [8]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_8.jpg
  [9]: https://github.com/EVA-JianJun/AutoCython/releases
  [10]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_10.jpg
  [11]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_11.jpg

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "AutoCython-jianjun",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "cython, compile, pyd, pyc, python, autopyd",
    "author": null,
    "author_email": "jianjun <910667956@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/f7/e0/394c3cc1e8614d290d9a7606bbf4b6111d7ce861c1b1aa35eba7fc6a4ebd/autocython_jianjun-1.3.4.tar.gz",
    "platform": null,
    "description": "# AutoCython\r\n\r\n**\u81ea\u52a8 Cython, \u4f7f\u7528 Cython \u6279\u91cf\u7f16\u8bd1 `.py` \u6587\u4ef6\u4e3a `.pyd` \u6587\u4ef6\uff01**\r\n![py_pyd][1]\r\n\r\n## \u5b89\u88c5\r\n\r\n    pip install AutoCython-jianjun\r\n\r\n## \u4f9d\u8d56\r\n\r\n[Cython](https://github.com/cython/cython) \u548c C/C++ \u7f16\u8bd1\u5668\r\n\r\n**\u5982\u679c\u4f60\u90fd\u914d\u7f6e\u5b8c\u6bd5\u4e86\u4f60\u53ef\u4ee5\u8df3\u8fc7\u672c\u8282.**\r\n\r\n### Cython\r\n\r\n```\r\npip install Cython\r\n```\r\n\r\n### C/C++ \u7f16\u8bd1\u5668\r\n\r\n\u63a8\u8350 `gcc` \u548c `visual studio` \u9009\u4e00\u4e2a, \u5176\u4ed6\u7f16\u8bd1\u5668\u8bf7\u67e5\u9605 Cython \u6587\u6863.\r\n\r\n* `VS` \u5b89\u88c5\u7b80\u4fbf, \u5360\u7528\u7a7a\u95f4\u5927, \u914d\u7f6e\u7b80\u5355.\r\n* `gcc` \u5b89\u88c5\u7b80\u4fbf, \u5360\u7528\u7a7a\u95f4\u5c0f, \u914d\u7f6e\u6bd4\u8f83\u590d\u6742.\r\n\r\n\u4e0d\u60f3\u6298\u817e\u6216\u8005\u4f60\u662f Windows \u7684\u8bdd\u63a8\u8350\u5b89\u88c5 VS, Linux \u7b49\u7cfb\u7edf\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u81ea\u5e26\u7684 gcc\u3002\r\n\r\n\u5927\u90e8\u5206\u7684\u7f16\u8bd1\u73af\u5883\u90fd\u53ef\u4ee5\u4f7f\u7528, \u6211\u5728 Win, Linux, Mac, Python3.6 \u5230 Python3.10 \u90fd\u53ef\u4ee5\u4f7f\u7528.\r\n\r\n**\u9700\u8981\u6ce8\u610f\u7684\u662f, \u5982\u679c\u4f60\u4f7f\u7528\u7684 Python \u662f64\u4f4d\u7684, \u90a3\u4e48\u5bf9\u5e94\u7684 C\u3001C++ \u7f16\u8bd1\u5668\u4e5f\u5fc5\u987b\u4e3a64\u4f4d\uff1b**\r\n\r\n**win\u4e0bgcc\u63a8\u8350\u5b89\u88c5MinGW**\uff1a\r\n\r\n* 64\u4f4d\uff1a<http://mingw-w64.org/>\r\n* 32\u4f4d\uff1a<http://www.mingw.org/>\r\n\r\n## \u4f7f\u7528\r\n\r\n![\u547d\u4ee4\u884c][11]\r\n\r\n### \u547d\u4ee4\u884c\r\n\r\n\u4f7f\u7528\u547d\u4ee4\u884c\u8fdb\u884c\u7f16\u8bd1\uff1a\r\n\r\n`AutoCython -h` \u6216\u8005 `AutoCython --ch` \u67e5\u770b\u82f1\u6587\u548c\u4e2d\u6587\u5e2e\u52a9.\r\n\r\n    # \u7f16\u8bd1\u4e00\u4e2a\u6587\u4ef6\r\n    AutoCython -f test.py\r\n\r\n    # \u7f16\u8bd1\u4e00\u4e2a\u76ee\u5f55\r\n    AutoCython -C D:/python_code/ProjectPath\r\n\r\n![AutoCython][2]\r\n\r\n**\u4f8b\u5b50**\r\n\r\n\u7f16\u8bd1\u76ee\u5f55 `D:/python_code/ProjectPath`\\\r\n\u6392\u9664\u6240\u6709\u540d\u4e3a `tmp.py` \u7684\u6587\u4ef6\\\r\n\u6392\u9664 `./ProjectPath/print_cy.py` \u6587\u4ef6\\\r\n\u6392\u9664 `./ProjectPath/data/tmp` \u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u4e0d\u7f16\u8bd1\\\r\n\u4f7f\u75282\u4e2aCPU\u6838\u5fc3\\\r\n\u53ea\u5220\u9664\u7f16\u8bd1\u540e\u4ea7\u751f\u7684 `build` \u6587\u4ef6\u5939\u548c\u4e2d\u95f4\u6587\u4ef6 `setup_file`, \u4fdd\u7559\u81ea\u52a8\u751f\u6210\u7684 `C` \u4ee3\u7801.\\\r\n\r\n    AutoCython -C D:/python_code/ProjectPath -E tmp.py;./ProjectPath/print_cy.py;./ProjectPath/data/tmp -M 2 -D bp\r\n\r\n## \u7279\u6027\r\n\r\n* **\u5168\u81ea\u52a8**\uff1a\u81ea\u52a8\u7f16\u8bd1\u5f53\u524d\u76ee\u5f55\u4e0b\u6240\u6709.py\u6587\u4ef6, \u652f\u6301\u6307\u5b9a\u76ee\u5f55\u7f16\u8bd1\u6216\u5355\u6587\u4ef6\u7f16\u8bd1\uff1b\r\n* **\u4e2a\u6027\u5316**\uff1a\u652f\u6301\u6307\u5b9a\u6392\u9664\u76ee\u5f55\u6216\u6392\u9664\u6587\u4ef6\u8df3\u8fc7\u7f16\u8bd1\uff1b\r\n* **\u9ad8\u6548\u7387**\uff1a\u9ed8\u8ba4\u542f\u52a8\u8fdb\u7a0b\u6570\u4e3acpu\u6838\u5fc3\u6570\u56db\u5206\u4e4b\u4e00, \u5927\u591a\u6570\u60c5\u51b5\u4e0b\u53ef\u4ee5\u628acpu\u8dd1\u6ee1\uff1b\r\n* **\u6613\u7ea0\u9519**\uff1a\u5feb\u901f\u7ea0\u9519, \u5728\u7f16\u8bd1\u5931\u8d25\u65f6\u80fd\u6781\u5feb\u7684\u83b7\u53d6\u9519\u8bef\u4fe1\u606f\uff1b\r\n\r\n### \u5e38\u89c1\u9519\u8bef\r\n\r\n* `print(end='')`\\\r\nCython \u4e0d\u652f\u6301 print \u51fd\u6570\u7684 end \u53c2\u6570, \u53ef\u4ee5\u5728\u5916\u90e8\u5b9a\u4e49 `def my_print(*args, **kwargs): print(*args, end='', **kwargs)`, \u7136\u540e\u5728\u9700\u8981\u7f16\u8bd1\u7684\u6587\u4ef6\u4e2d\u5bfc\u5165\u8fd9\u4e2a\u5916\u90e8\u51fd\u6570.\r\n\r\n* `\u65b0\u5efa\u6587\u672c\u6587\u6863.py`\\\r\n\u6587\u4ef6\u540d\u9700\u8981\u7b26\u5408  `C` \u547d\u540d\u89c4\u8303\r\n\r\n\u5176\u4ed6\u95ee\u9898\u8bf7\u67e5\u9605 `Cython` \u5b98\u65b9\u6587\u6863.\r\n\r\n### \u624b\u52a8\u6307\u5b9a\u4e0d\u7f16\u8bd1\r\n\r\n\u5728\u4e0d\u9700\u8981\u7f16\u8bd1\u7684\u6587\u4ef6 **\u5934\u4e24\u884c** \u4efb\u610f\u4e00\u884c\u5199\u4e0a `# AucoCython No Compile` \u5219\u8be5\u6587\u4ef6\u4f1a\u8df3\u8fc7\u7f16\u8bd1.\r\n\r\n## \u66f4\u65b0\u8bb0\u5f55\r\n1. 20220613 \u66f4\u65b0\u5bf9Linux\u7684\u652f\u6301, Linux\u4e0b\u9700\u8981\u914d\u7f6egcc&g++\r\n2. 20221123 \u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6\u5934\u624b\u52a8\u6307\u5b9a\u4e0d\u7f16\u8bd1\u7684\u6587\u4ef6\r\n3. 20230306 \u66f4\u65b0\u53ef\u4ee5\u6307\u5b9a\u547d\u4ee4\u884c\u5934\u5982 `Python310` \u4ee5\u6b64\u652f\u6301\u975eWidnows\u7cfb\u7edf\u4e0b\u7f16\u8bd1\r\n4. 20230324 \u66f4\u65b0\u6587\u6863\r\n5. 20240506 \u4fee\u590d\u7f16\u8bd1\u5931\u8d25\u65f6\u9057\u6f0f\u590d\u539f __init__.py \u7684\u95ee\u9898\r\n\r\n  [1]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20210824.png\r\n  [2]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_2.jpg\r\n  [3]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_3.jpg\r\n  [4]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_4.jpg\r\n  [5]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_5.jpg\r\n  [6]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_6.jpg\r\n  [7]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_7.jpg\r\n  [8]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_8.jpg\r\n  [9]: https://github.com/EVA-JianJun/AutoCython/releases\r\n  [10]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_10.jpg\r\n  [11]: https://raw.githubusercontent.com/EVA-JianJun/GitPigBed/master/blog_files/img/AutoCython_20200316_11.jpg\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) [2024] [JianJun]  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "\u81ea\u52a8Cython\uff0c\u4f7f\u7528Cython\u6279\u91cf\u7f16\u8bd1.py\u6587\u4ef6\u4e3a.pyd\u6587\u4ef6\uff01",
    "version": "1.3.4",
    "project_urls": {
        "documentation": "https://github.com/EVA-JianJun/AutoCython#readme",
        "homepage": "https://github.com/EVA-JianJun/AutoCython",
        "repository": "https://github.com/EVA-JianJun/AutoCython"
    },
    "split_keywords": [
        "cython",
        " compile",
        " pyd",
        " pyc",
        " python",
        " autopyd"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "77d26d2c24d1bb5e1d985657aa8a965fa7d48220ddebed3624b008976c582661",
                "md5": "3cbb5d2fe3503fba6719d2b70706abf4",
                "sha256": "8b1af65667270c444f59fdbc8b345530955f289ef8217eaa1a6100f1ec6fb30a"
            },
            "downloads": -1,
            "filename": "AutoCython_jianjun-1.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3cbb5d2fe3503fba6719d2b70706abf4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11284,
            "upload_time": "2024-05-06T04:52:52",
            "upload_time_iso_8601": "2024-05-06T04:52:52.965070Z",
            "url": "https://files.pythonhosted.org/packages/77/d2/6d2c24d1bb5e1d985657aa8a965fa7d48220ddebed3624b008976c582661/AutoCython_jianjun-1.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7e0394c3cc1e8614d290d9a7606bbf4b6111d7ce861c1b1aa35eba7fc6a4ebd",
                "md5": "313a52c2ff4251c2293dccb7500ec2ab",
                "sha256": "102d935bcf3a18312dcc2dedec4873df71f7c355fe4a9fbb3504e82aec7d600c"
            },
            "downloads": -1,
            "filename": "autocython_jianjun-1.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "313a52c2ff4251c2293dccb7500ec2ab",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9906,
            "upload_time": "2024-05-06T04:52:54",
            "upload_time_iso_8601": "2024-05-06T04:52:54.659001Z",
            "url": "https://files.pythonhosted.org/packages/f7/e0/394c3cc1e8614d290d9a7606bbf4b6111d7ce861c1b1aa35eba7fc6a4ebd/autocython_jianjun-1.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-06 04:52:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "EVA-JianJun",
    "github_project": "AutoCython#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "autocython-jianjun"
}
        
Elapsed time: 0.30279s