Closed macintacos closed 2 years ago
Oh also, I can't seem to figure out how to get docstrings from Nim files carried over so that my editor can recognize them.
Hi @macintacos! Thanks for checking out Nimporter!
The basic workflow is as follows:
rustup
workflow from the Rust community.nim
from the command line and it works, you'll be able to use Nimporter easilymain.py
. One thing to note is that Nimporter must be imported before any Nim extension modules. I usually go: import nimporter, the_nim_ext_mod
all on one linepip
or nimporter compile
. Nimporter keeps track of changes to the Nim extensions automatically and will recompile next time it is imported when it sees a change in the Nim code. For all normal development, just have a Python module import Nimporter and then the Nim extension. This will trigger an initial build and then rebuilds when changes are detected.setup.py
that is used to hookup all the Nim extensions in the project. Nimporter was designed to support any number of deeply-nested Nim extension within a Python package heirarchy. When you specify ext_modules=nimporter.build_nim_extensions()
in the setup.py
, you are telling Nimporter to go and compile all the extensions in the project when a source or binary distribution is built from Pip.nimporter compile
is intended in situations where a setup.py
cannot easily run. It performs all of the Nim extension compilation the exact same as if they were imported and should not be used except when packaging for restrictive environments.setup.py
, you can python setup.py sdist
to get a source distribution of the entire project. Alternatively, you can package into a platform-specific bundle using python setup.py bdist_wheel
.If you run into any other issues, please let me or @SekouDiaoNlp know and we will do our best to help out! 😄
Closing this for now but definitely reopen if you run into any other issues! :)
Hello! New to Nim, not-so-new to Python, but trying to figure out how to use this tool to get the best of both.
I setup the following repo to mess around with some stuff based on what I'm reading in the README: https://github.com/macintacos/nimport-playground
The project is pretty "rough", I would say. I'm not really understanding what the expected "workflow" is supposed to be. Right now I:
python -m venv venv && source venv/bin/activate.fish
)python setup.py install
twice, because the first timenimporter
isn't installed and yet it seemingly needs to be used in the call tosetup()
(?)python -m play.main
as I see fit.However, if I want to edit the Nim code, it seems like I need to recompile it completely with
nimporter compile
and thenpython setup.py install
again. At first I thought runningpython setup.py install
again would work (after changing some of the Nim code), but that doesn't seem to do anything.Is this the expected workflow? Or am I missing something about my setup? Sorry if I'm missing something obvious 😬