Skip to main content

The Cross-Platform Cython/Python Compiler

Project description

We all know the beauties of Cython:

  1. Writing C extensions is as easy as Python

  2. Almost any valid Python is valid Cython, as Cython is a superset of Python

  3. It has the readability of Python, but the speed of C

  4. Minimal effort has to be taken in order to speed up some programs by three to four orders of magnitude

However, compiling is not always easy. There are a few places that disutils’ setup.py can get tripped up.

  1. vcvarsall.bat not found error

  2. gcc: undefined reference to…

  3. Other errors basically referring to ‘compiler not found’

Cython may be almost as easy to write as Python, but sometimes nowhere near the level of easiness that it takes to run Python. This is where Cyther comes into play. Cyther is an attempt at a cross platform compiler that wields both the standard cython compiler and gcc to make sure that these errors don’t happen. Cyther is extremely easy to use. One can call cyther.py from the command line, or import core on the module level, then call that.

A few examples:

from cyther import core
core('cython_file.pyx')

same can be done with:

C:/Python35> cyther cython_file.pyx

Here are some neat little option examples:

from cyther import core
core('python_file.py -t -l')
# -t means that cyther will not compile it if the source file is not older than the compiled file
# -l means that cyther will build locally, if not given, it builds in __cythercache__

Perhaps the most useful feature of Cyther:

from cyther import core
core('cython_file.pyx -w')

This -w command means that cyther will keep looking at that file indefinitely and whenever it sees a change in the source code, it will automatically compile it without the user having to do anything. Here is the output of the -w option in the command line and stdout:

Compiling the file 'D:\python\notes.py'
cython -a -p -o D:\python\notes.c D:\python\notes.py -l
gcc -shared -w -O3 -I D:\Python35\include -L D:\Python35\libs -o D:\python\notes.pyd D:\python\notes.c -l python35
...<count:1>...
Compiling the file 'D:\python\test.pyx'
...<count:2>...
Compiling the file 'D:\python\test.pyx'
...<count:3>...
Compiling the file 'D:\python\test2.pyx'
...<count:4>...

Keep in mind that anything that you pass to core, you can also pass to cyther from the command line. Now, try to meditate on this command:

C:/Python35> cyther cython_file.pyx python_file.py test.pyx -w -l -o something -cython _l

This command will compile these three files, then proceed to watch them continuously, and if they change, they will be recompiled. Also, their .c and .a files will be built in the same directory. Even further, we pass the option _l (-l) to cython, which will create listing files for the three files specified. Notice that we put a -o option, when in reality this makes no sense. Cyther knows this and will erase this option before it goes to compile, so the files will not be compiled under the same name. To get an idea of what Cyther is currently capable of, type core('-h') or cyther -h from the command line.

Cyther isn’t quite perfect yet, so all the incompatabilities and assumptions that Cyther makes are listed below. We strongly recommend that you look them over before even touching the download button. In the near future we hope to make Cyther as polished as possible, and bring the list of assumptions listed below to a minimum. There are even plans in the works to be able to automatically recompile shared object libraries that are entirely missing on one’s system; critical to Cython compilation.

Assumptions cyther makes about your system:

  1. Cython and gcc are both installed, and accessible from the system console

  2. Your environment path variable is able to be found by shutil.which

  3. gcc can work with the option -l pythonXY (libpythonXY.a exists in your python libs directory)

  4. Almost any gcc compiled C program will work on Windows

Hey you! Yes you. If you notice any bugs or peculiarities, please report them to our bug tracker, it will help us out a lot:

https://github.com/nickpandolfi/Cyther/issues

If you have any questions or concerns, or even any suggestions, don’t hesitate to contact me at:

npandolfi@wpi.edu

Happy compiling!!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

Cyther-0.4.1.zip (13.9 kB view details)

Uploaded Source

Cyther-0.4.1.tar.gz (10.1 kB view details)

Uploaded Source

Cyther-0.4.1.tar.bz2 (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Cyther-0.4.1.win32.exe (145.0 kB view details)

Uploaded Source

File details

Details for the file Cyther-0.4.1.zip.

File metadata

  • Download URL: Cyther-0.4.1.zip
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Cyther-0.4.1.zip
Algorithm Hash digest
SHA256 ad7deed3eb2345250ef4500d72f44c1ad23f6c193152347fe538141ab1a7da52
MD5 2a2efd57e1e9739c3579682bcff41ec8
BLAKE2b-256 a7e14b7fc4c90cf66ea99a84dc61675ec7145ca6626e3eb10126cbaf209b206d

See more details on using hashes here.

File details

Details for the file Cyther-0.4.1.tar.gz.

File metadata

  • Download URL: Cyther-0.4.1.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Cyther-0.4.1.tar.gz
Algorithm Hash digest
SHA256 88704e0c61a80c998c7e6a1e588609719f0176559974d9702d2d24ce3b84cfdf
MD5 4d69620334c5d1a55d6e849f0228ce69
BLAKE2b-256 53768cb372a14bbc0472e881dae94f00e4c64124fdf876f18421d9a5e41fb984

See more details on using hashes here.

File details

Details for the file Cyther-0.4.1.tar.bz2.

File metadata

  • Download URL: Cyther-0.4.1.tar.bz2
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Cyther-0.4.1.tar.bz2
Algorithm Hash digest
SHA256 2dbdea6921fddd2a823720a3c8639b73410b9cf802fda327ab8cf030fbae8cee
MD5 cca5010f07a07c262de782c6f4485c55
BLAKE2b-256 e570d7c9f53f6c06a3f4e5e3a6b34f0a95ab71fbea1926a78b410f6969e74b13

See more details on using hashes here.

File details

Details for the file Cyther-0.4.1.win32.exe.

File metadata

  • Download URL: Cyther-0.4.1.win32.exe
  • Upload date:
  • Size: 145.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Cyther-0.4.1.win32.exe
Algorithm Hash digest
SHA256 8bb002e11e0df3018b9efd4749a83fc752cbc7196cc6a40451fc1bead28806dd
MD5 250cb61ac5d4ece3270fc2dfd3a6276b
BLAKE2b-256 7fd8f2eeb4eaa9a3c01c77b495f471380bb0bab43b6b19ce0ab3016bd735d9c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page