cycompi


Namecycompi JSON
Version 0.13 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/cycompi
SummaryCython Compilation Made Simple
upload_time2024-02-02 14:41:57
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords numpy c cython
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Cython Compilation Made Simple

cycompi is a lightweight Python module designed to simplify the compilation of Cython code by providing a convenient interface. With Cycompi, you can effortlessly compile your Cython modules with minimal setup and enjoy the advantages of improved performance and enhanced functionality.

## Tested against Windows / Python 3.11 / Anaconda

## pip install cycompi

```python
    Compile Cython code using the provided configuration, options, and command line arguments.
    :param name: name of the module 
    :param configdict: dictionary containing configuration settings (passed to setuptools.Extension)
    :param optionsdict: dictionary containing options settings (passed to Cython.Compiler.Options)
    :param cmd_line_args: command line arguments (passed to setup as compiler_directives)
    :param **kwargs: additional keyword arguments to be passed to subprocess.run

    :return: None

    Example usage:
        from cycompi import compile_cython_code
        import numpy as np
        import os

        numpyincludefolder = np.get_include()
		
		# Explanation: https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html
		# Most of the time, I use this configuration: 
        optionsdict = {
            "Options.docstrings": False,
            "Options.embed_pos_in_docstring": False,
            "Options.generate_cleanup_code": False,
            "Options.clear_to_none": True,
            "Options.annotate": True,
            "Options.fast_fail": False,
            "Options.warning_errors": False,
            "Options.error_on_unknown_names": True,
            "Options.error_on_uninitialized": True,
            "Options.convert_range": True,
            "Options.cache_builtins": True,
            "Options.gcc_branch_hints": True,
            "Options.lookup_module_cpdef": False,
            "Options.embed": False,
            "Options.cimport_from_pyx": False,
            "Options.buffer_max_dims": 8,
            "Options.closure_freelist_size": 8,
        }
        configdict = {
            "py_limited_api": False,
            "name": "cythondict",
            "sources": ["lookdi.pyx"],
            "include_dirs": [numpyincludefolder],
            "define_macros": [
                ("NPY_NO_DEPRECATED_API", 1),
                ("NPY_1_7_API_VERSION", 1),
                ("CYTHON_USE_DICT_VERSIONS", 1),
                ("CYTHON_FAST_GIL", 1),
                ("CYTHON_USE_PYLIST_INTERNALS", 1),
                ("CYTHON_USE_UNICODE_INTERNALS", 1),
                ("CYTHON_ASSUME_SAFE_MACROS", 1),
                ("CYTHON_USE_TYPE_SLOTS", 1),
                ("CYTHON_USE_PYTYPE_LOOKUP", 1),
                ("CYTHON_USE_ASYNC_SLOTS", 1),
                ("CYTHON_USE_PYLONG_INTERNALS", 1),
                ("CYTHON_USE_UNICODE_WRITER", 1),
                ("CYTHON_UNPACK_METHODS", 1),
                ("CYTHON_USE_EXC_INFO_STACK", 1),
                ("CYTHON_ATOMICS", 1),
            ],
            "undef_macros": [],
            "library_dirs": [],
            "libraries": [],
            "runtime_library_dirs": [],
            "extra_objects": [],
            "extra_compile_args": ["/O2", "/Oy"],
            "extra_link_args": [],
            "export_symbols": [],
            "swig_opts": [],
            "depends": [],
            "language": "c",
            "optional": None,
        }
        compiler_directives = {
            "binding": True,
            "boundscheck": False,
            "wraparound": False,
            "initializedcheck": False,
            "nonecheck": False,
            "overflowcheck": False,
            "overflowcheck.fold": True,
            "embedsignature": False,
            "embedsignature.format": "c",  # (c / python / clinic)
            "cdivision": True,
            "cdivision_warnings": False,
            "cpow": True,
            "always_allow_keywords": False,
            "c_api_binop_methods": False,
            "profile": False,
            "linetrace": False,
            "infer_types": True,
            "language_level": 3,  # (2/3/3str)
            "c_string_type": "bytes",  # (bytes / str / unicode)
            "c_string_encoding": "default",  # (ascii, default, utf-8, etc.)
            "type_version_tag": False,
            "unraisable_tracebacks": True,
            "iterable_coroutine": True,
            "annotation_typing": True,
            "emit_code_comments": True,
            "cpp_locals": False,
            "legacy_implicit_noexcept": False,
            "optimize.use_switch": True,
            "optimize.unpack_method_calls": True,
            "warn.undeclared": False,  # (default False)
            "warn.unreachable": True,  # (default True)
            "warn.maybe_uninitialized": False,  # (default False)
            "warn.unused": False,  # (default False)
            "warn.unused_arg": False,  # (default False)
            "warn.unused_result": False,  # (default False)
            "warn.multiple_declarators": True,  # (default True)
            "show_performance_hints": True,  # (default True)
        }

        compile_cython_code(
            name="lookdi",
            configdict=configdict,
            optionsdict=optionsdict,
            cmd_line_args=compiler_directives,
            cwd=os.getcwd(),
            shell=True,
            env=os.environ.copy(),
        )

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/cycompi",
    "name": "cycompi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "numpy,C,cython",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2a/e6/c2e3f18ebfa1ce3932df9bc03498aab74e034f657eccb43d14ac4231e6e7/cycompi-0.13.tar.gz",
    "platform": null,
    "description": "\r\n# Cython Compilation Made Simple\r\n\r\ncycompi is a lightweight Python module designed to simplify the compilation of Cython code by providing a convenient interface. With Cycompi, you can effortlessly compile your Cython modules with minimal setup and enjoy the advantages of improved performance and enhanced functionality.\r\n\r\n## Tested against Windows / Python 3.11 / Anaconda\r\n\r\n## pip install cycompi\r\n\r\n```python\r\n    Compile Cython code using the provided configuration, options, and command line arguments.\r\n    :param name: name of the module \r\n    :param configdict: dictionary containing configuration settings (passed to setuptools.Extension)\r\n    :param optionsdict: dictionary containing options settings (passed to Cython.Compiler.Options)\r\n    :param cmd_line_args: command line arguments (passed to setup as compiler_directives)\r\n    :param **kwargs: additional keyword arguments to be passed to subprocess.run\r\n\r\n    :return: None\r\n\r\n    Example usage:\r\n        from cycompi import compile_cython_code\r\n        import numpy as np\r\n        import os\r\n\r\n        numpyincludefolder = np.get_include()\r\n\t\t\r\n\t\t# Explanation: https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html\r\n\t\t# Most of the time, I use this configuration: \r\n        optionsdict = {\r\n            \"Options.docstrings\": False,\r\n            \"Options.embed_pos_in_docstring\": False,\r\n            \"Options.generate_cleanup_code\": False,\r\n            \"Options.clear_to_none\": True,\r\n            \"Options.annotate\": True,\r\n            \"Options.fast_fail\": False,\r\n            \"Options.warning_errors\": False,\r\n            \"Options.error_on_unknown_names\": True,\r\n            \"Options.error_on_uninitialized\": True,\r\n            \"Options.convert_range\": True,\r\n            \"Options.cache_builtins\": True,\r\n            \"Options.gcc_branch_hints\": True,\r\n            \"Options.lookup_module_cpdef\": False,\r\n            \"Options.embed\": False,\r\n            \"Options.cimport_from_pyx\": False,\r\n            \"Options.buffer_max_dims\": 8,\r\n            \"Options.closure_freelist_size\": 8,\r\n        }\r\n        configdict = {\r\n            \"py_limited_api\": False,\r\n            \"name\": \"cythondict\",\r\n            \"sources\": [\"lookdi.pyx\"],\r\n            \"include_dirs\": [numpyincludefolder],\r\n            \"define_macros\": [\r\n                (\"NPY_NO_DEPRECATED_API\", 1),\r\n                (\"NPY_1_7_API_VERSION\", 1),\r\n                (\"CYTHON_USE_DICT_VERSIONS\", 1),\r\n                (\"CYTHON_FAST_GIL\", 1),\r\n                (\"CYTHON_USE_PYLIST_INTERNALS\", 1),\r\n                (\"CYTHON_USE_UNICODE_INTERNALS\", 1),\r\n                (\"CYTHON_ASSUME_SAFE_MACROS\", 1),\r\n                (\"CYTHON_USE_TYPE_SLOTS\", 1),\r\n                (\"CYTHON_USE_PYTYPE_LOOKUP\", 1),\r\n                (\"CYTHON_USE_ASYNC_SLOTS\", 1),\r\n                (\"CYTHON_USE_PYLONG_INTERNALS\", 1),\r\n                (\"CYTHON_USE_UNICODE_WRITER\", 1),\r\n                (\"CYTHON_UNPACK_METHODS\", 1),\r\n                (\"CYTHON_USE_EXC_INFO_STACK\", 1),\r\n                (\"CYTHON_ATOMICS\", 1),\r\n            ],\r\n            \"undef_macros\": [],\r\n            \"library_dirs\": [],\r\n            \"libraries\": [],\r\n            \"runtime_library_dirs\": [],\r\n            \"extra_objects\": [],\r\n            \"extra_compile_args\": [\"/O2\", \"/Oy\"],\r\n            \"extra_link_args\": [],\r\n            \"export_symbols\": [],\r\n            \"swig_opts\": [],\r\n            \"depends\": [],\r\n            \"language\": \"c\",\r\n            \"optional\": None,\r\n        }\r\n        compiler_directives = {\r\n            \"binding\": True,\r\n            \"boundscheck\": False,\r\n            \"wraparound\": False,\r\n            \"initializedcheck\": False,\r\n            \"nonecheck\": False,\r\n            \"overflowcheck\": False,\r\n            \"overflowcheck.fold\": True,\r\n            \"embedsignature\": False,\r\n            \"embedsignature.format\": \"c\",  # (c / python / clinic)\r\n            \"cdivision\": True,\r\n            \"cdivision_warnings\": False,\r\n            \"cpow\": True,\r\n            \"always_allow_keywords\": False,\r\n            \"c_api_binop_methods\": False,\r\n            \"profile\": False,\r\n            \"linetrace\": False,\r\n            \"infer_types\": True,\r\n            \"language_level\": 3,  # (2/3/3str)\r\n            \"c_string_type\": \"bytes\",  # (bytes / str / unicode)\r\n            \"c_string_encoding\": \"default\",  # (ascii, default, utf-8, etc.)\r\n            \"type_version_tag\": False,\r\n            \"unraisable_tracebacks\": True,\r\n            \"iterable_coroutine\": True,\r\n            \"annotation_typing\": True,\r\n            \"emit_code_comments\": True,\r\n            \"cpp_locals\": False,\r\n            \"legacy_implicit_noexcept\": False,\r\n            \"optimize.use_switch\": True,\r\n            \"optimize.unpack_method_calls\": True,\r\n            \"warn.undeclared\": False,  # (default False)\r\n            \"warn.unreachable\": True,  # (default True)\r\n            \"warn.maybe_uninitialized\": False,  # (default False)\r\n            \"warn.unused\": False,  # (default False)\r\n            \"warn.unused_arg\": False,  # (default False)\r\n            \"warn.unused_result\": False,  # (default False)\r\n            \"warn.multiple_declarators\": True,  # (default True)\r\n            \"show_performance_hints\": True,  # (default True)\r\n        }\r\n\r\n        compile_cython_code(\r\n            name=\"lookdi\",\r\n            configdict=configdict,\r\n            optionsdict=optionsdict,\r\n            cmd_line_args=compiler_directives,\r\n            cwd=os.getcwd(),\r\n            shell=True,\r\n            env=os.environ.copy(),\r\n        )\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cython Compilation Made Simple",
    "version": "0.13",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/cycompi"
    },
    "split_keywords": [
        "numpy",
        "c",
        "cython"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cc03358be56415a6a38f810b21c2178264d4dd833e0d2101cfaf637604fc874d",
                "md5": "4de641db468a30e1419d7ecd32f3d9db",
                "sha256": "ecd05b3b1710cd6a940cd45b3288e49b2e16684de545df5ca489c4e738533f95"
            },
            "downloads": -1,
            "filename": "cycompi-0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4de641db468a30e1419d7ecd32f3d9db",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8783,
            "upload_time": "2024-02-02T14:41:55",
            "upload_time_iso_8601": "2024-02-02T14:41:55.921349Z",
            "url": "https://files.pythonhosted.org/packages/cc/03/358be56415a6a38f810b21c2178264d4dd833e0d2101cfaf637604fc874d/cycompi-0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ae6c2e3f18ebfa1ce3932df9bc03498aab74e034f657eccb43d14ac4231e6e7",
                "md5": "2cb89e9d241764674aef3599f8881586",
                "sha256": "280394ea337d54c9f1e40afe4c7e1ee96b61b0d6c8f6026b2f66a24e24c6946b"
            },
            "downloads": -1,
            "filename": "cycompi-0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "2cb89e9d241764674aef3599f8881586",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5883,
            "upload_time": "2024-02-02T14:41:57",
            "upload_time_iso_8601": "2024-02-02T14:41:57.655929Z",
            "url": "https://files.pythonhosted.org/packages/2a/e6/c2e3f18ebfa1ce3932df9bc03498aab74e034f657eccb43d14ac4231e6e7/cycompi-0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-02 14:41:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "cycompi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cycompi"
}
        
Elapsed time: 0.42444s