{"id":18568681,"url":"https://github.com/anxuae/setuptools-cythonize","last_synced_at":"2025-04-10T05:32:58.994Z","repository":{"id":43288181,"uuid":"171926063","full_name":"anxuae/setuptools-cythonize","owner":"anxuae","description":"Distribute python modules/packages as binary files (compilation based on Cython)","archived":false,"fork":false,"pushed_at":"2023-02-23T10:01:06.000Z","size":989,"stargazers_count":40,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T16:47:57.312Z","etag":null,"topics":["cython","python","setuptools","wheel"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anxuae.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-21T18:47:47.000Z","updated_at":"2024-06-23T04:42:24.000Z","dependencies_parsed_at":"2024-06-19T17:12:32.196Z","dependency_job_id":"f7c89d62-8584-44e9-8938-25ee7628d6aa","html_url":"https://github.com/anxuae/setuptools-cythonize","commit_stats":{"total_commits":54,"total_committers":4,"mean_commits":13.5,"dds":0.05555555555555558,"last_synced_commit":"11d16bf09bf8d779cdfc2232ff5e72fa7482f8ca"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anxuae%2Fsetuptools-cythonize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anxuae%2Fsetuptools-cythonize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anxuae%2Fsetuptools-cythonize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anxuae%2Fsetuptools-cythonize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anxuae","download_url":"https://codeload.github.com/anxuae/setuptools-cythonize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248163303,"owners_count":21057906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cython","python","setuptools","wheel"],"created_at":"2024-11-06T22:29:58.703Z","updated_at":"2025-04-10T05:32:57.556Z","avatar_url":"https://github.com/anxuae.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n.. image:: https://raw.githubusercontent.com/anxuae/setuptools-cythonize/master/docs/cythonize.png\n   :align: center\n   :alt: setuptools-cythonize\n\n|PythonVersions| |PypiPackage| |Downloads|\n\nThe ``setuptools-cythonize`` provides ``distutils`` classes to compile **Python** source code into\n**C** code using ``Cython``. The generated code is packaged into a platform dependent archive.\n\n.. image:: https://raw.githubusercontent.com/anxuae/setuptools-cythonize/master/docs/cythonization.png\n   :align: center\n   :alt: cythonization\n\nInstall\n-------\n\n::\n\n     $\u003e pip install setuptools-cythonize\n\n\nSetup configuration\n-------------------\n\nAdd the ``cmdclass`` keyword to the setup:\n\n.. code-block:: python\n\n    from setuptools import setup\n    from setuptools_cythonize import get_cmdclass\n\n    setup(\n        cmdclass=get_cmdclass(),\n        name=\"my_package\",\n        version=\"2.0.5\",\n        description=\"My custom library\",\n        ...\n    )\n\n.. note:: the function ``get_cmdclass()`` force **wheel** as default format\n          (recommended format for binary distribution). This behavior can be\n          disabled by passing the parameter ``wheel_default=False``.\n\nSome packages can be excluded from the *cythonization* by setting the ``exclude_cythonize``\noption. The module names matching is done using the function\n`fnmatch.fnmatchcase \u003chttps://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatchcase\u003e`_ .\n\n.. code-block:: python\n\n    from setuptools import setup\n    from setuptools_cythonize import get_cmdclass\n\n    setup(\n        cmdclass=get_cmdclass(),\n        name=\"my_package\",\n        ...\n        options={\n            'build_py':\n                {'exclude_cythonize': ['my_package.subpack*']}\n        },\n        ...\n    )\n\n.. note:: some Python modules starting with ``__`` are excluded from the cythonization.\n          This includes:\n\n          - the ``__init__.py`` files which are mandatory to keep the Python\n            packages integrity\n          - the ``__main__.py`` file in order to exectute the package using\n            the command ``python -m ...``\n\nThe `Cython compiler options \u003chttps://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiler-options\u003e`_\ncan also be customized before running the ``setup``:\n\n.. code-block:: python\n\n    from setuptools import setup\n\n    from Cython.Compiler import Options\n\n    Options.docstrings = False\n\n    setup(\n        ...\n    )\n\nTo speedup files compilation, the *cythonization* can be performed in parallel by setting the ``parallel``\noption. The number of CPUs availbale can be retrived using the ``multiprocessing`` module. For instance:\n\n.. code-block:: python\n\n    import multiprocessing\n    from setuptools import setup\n    from setuptools_cythonize import get_cmdclass\n\n    setup(\n        cmdclass=get_cmdclass(),\n        name=\"my_package\",\n        ...\n        options={\n            'build_ext':\n                {'parallel': multiprocessing.cpu_count()}\n        },\n        ...\n    )\n\nPackaging\n---------\n\nGenerate your package by executing the ``setup.py`` file, all Python modules (except\nthe ones defined in ``exclude_cythonize``) will be compiled and packaged::\n\n     $\u003e python setup.py bdist --cythonize\n\nA source package can still be generated by removing the ``--cythonize`` option::\n\n     $\u003e python setup.py bdist\n   \n\n!:warning: **If you want upload binary wheel on PyPI**, `read the PEP 513 – A Platform Tag for Portable Linux Built \u003chttps://peps.python.org/pep-0513/#rationale\u003e`_ :warning:!\n\n\n.. |PythonVersions| image:: https://img.shields.io/badge/python-2.7+ / 3.5+-red.svg\n   :target: https://www.python.org/downloads\n   :alt: Python 2.7+/3.5+\n\n.. |PypiPackage| image:: https://badge.fury.io/py/setuptools-cythonize.svg\n   :target: https://pypi.org/project/setuptools-cythonize\n   :alt: PyPi package\n\n.. |Downloads| image:: https://img.shields.io/pypi/dm/setuptools-cythonize?color=purple\n   :target: https://pypi.org/project/setuptools-cythonize\n   :alt: PyPi downloads\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanxuae%2Fsetuptools-cythonize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanxuae%2Fsetuptools-cythonize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanxuae%2Fsetuptools-cythonize/lists"}