Skip to main content

cyrun

cyrun allows you to write cython code that runs like a scripting language, with compilation happening in the background. Here is an example:

#!/usr/bin/env cyrun
print("Hello World!")

You can use the usual cython build metadata at the beginning of the script to adjust compilation settings:

# distutils: name = test
# distutils: sources =
# distutils: define_macros = TESTMACRO
# distutils: undef_macros = TESTMACRO
# distutils: libraries =
# distutils: library_dirs = test
# distutils: runtime_library_dirs = test
# distutils: include_dirs = test
# distutils: extra_objects =
# distutils: extra_compile_args = -Wall
# distutils: extra_link_args =
# distutils: export_symbols =
# distutils: depends =
# distutils: language = c++

cyrun also adds the following metadata for searching for project-level module folders:

# cyrun: base = modules # starting from script folder, search all
  top-level directories for a folder called modules, and add it to
  the include path and build path
# cyrun: realpath = # if the script is a symlink, resolve it to the
  real path before searching
# cyrun: ignore = # ignore certain folder names during the search

If the setting begins with “interpolate:”, then cython will enable string interpolation using the interpolate module <https://pypi.python.org/pypi/interpolate> on all the distutils metadata fields. This allows setting fields such as include_dir dynamically, e.g.:

# interpolate: distutils: include_dirs = {__import__('pysam').get_include()}
# interpolate: distutils: extra_link_args = {__import__('pysam').get_libraries()}
# interpolate: distutils: define_macros = {['%s=%s' % (d[0],d[1]) for d in __import__('pysam').get_defines()]}

The interpolate module uses curly braces for templating, the same as string.format(), except you are allowed to embed a python expression instead of just variable names. Please note that only expressions are allowed, not statements. Also, you’ll have to avoid using double quotes and curly braces within the templates, as escaping doesn’t work well. Use single quotes for strings and dict() for dictionaries if you need them. See interpolate docs <http://edk141.co.uk/a/interpolate> and interpolate PyPI page <https://pypi.python.org/pypi/interpolate> for more details.

cyrun stores compiled cython libraries in a cache folder:

- if CYTHON_BIN environment variable is set, use that folder
- otherwise, if there is a .cython folder in the script folder, use that
- otherwise, set it to ~/.cache/cython

cyrun uses the following environment variables:

CYTHON_BIN - optional path to cached cython binaries
SKIP - if set, skip compilation step
CHECK - if set, don't run the module after the build step
VERBOSE - if set, enable verbose build output
FORCE - if set, force compilation
DEBUG - if set, run cygdb debugger on the compiled script

Compilation is performed using distutils and cythonize(). Modules will only recompile if source code timestamps are newer than the cached binary file.

Metadata

Release files for cyrun 0.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cyrun 0.17
File Size Uploaded Provenance Actions
cyrun-0.17.tar.gz 4.3 kB Without provenance Details for cyrun-0.17.tar.gz

Release files / cyrun-0.17.tar.gz

Download URL cyrun-0.17.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
58adea73a31f5d214544c3750ead8094619b9bd21e399eac0be25ef403a76540
BLAKE2b-256 checksum
How to use checksums
478765c04291c2f9d13034309517ba4b50c796aa05d5d0706e75746121864c30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cyrun 0.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page