Unten ist eine Momentaufnahme der Seite angezeigt, wie sie am 02.06.2024 angezeigt wurde (das letzte Datum, an dem unser Crawler sie besucht hat). Es handelt sich um die Version der Seite, die für das Ranking Ihrer Suchergebnisse verwendet wurde. Die Seite hat sich möglicherweise seit der letzten Zwischenspeicherung geändert. Damit Sie sehen können, was sich geändert hat (ohne die Markierungen), navigieren Sie zur aktuellen Seite.
Bing ist nicht für den Inhalt dieser Seite verantwortlich.
Call C code in repository downloaded straight from GitHub - Python Help - Discussions on Python.org
Discussions on Python.org
I write my programs in such a way that they can be downloaded straight from GitHub, requiring no packages to be installed. While that works for pure python code, I’m not sure how this works for C code.
No, this is not really possible in general for C. You will have to compile it (requiring a C compiler) and the code will potentially need to be modified to generate a library with the hello_world function being marked as a public function.
Outside of a toy example, what are you actually trying to do overall?
A conversion of a proprietary data format to json. Hundreds of folders containing each thousands of these files. My current Python code is far slower than other programs written in C.
So, if I want my code to be excutable, I need a Python version when it isn’t build, right?
You can include a C extension in your python project, and set up a backend that will build the extension on install. Users will need to have the proper tools installed on their machine (i.e. a compiler) but if they do they can install the package with pip install git+https://... and it will be built for them.
This can be a hassle for complex projects, and people generally prefer to download prebuilt wheels. But it works fine.
Thanks. Note that that wouldn’t work when using git clone https://github.com/... or when downloading the code straight from GitHub. But I think it would be a fun challenge to attempt.
It does require that the code is formatted as a package that can be installed [1].
I prefer this structure rather than a loose collection of scripts in a repo–it’s easier for me to grab the package on a new machine, and it allows me to import that code into other projects if appropriate. And I feel that organizing code into packages helps me to design things more cleanly. But other people do this differently.
all that pip is doing in this situation is cloning the repo and running pip install .↩︎
I have a setup.py for installing the dependencies if someone want to use them in their own scripts.
It might make sense to install __main__.py as well such that the C implementation can be used.
Also, there shouldn’t be an __init__.py in this directory, as it trips up linters.