Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q & A: call flow. #139

Closed
ChaselChiu opened this issue Aug 9, 2024 · 3 comments
Closed

Q & A: call flow. #139

ChaselChiu opened this issue Aug 9, 2024 · 3 comments

Comments

@ChaselChiu
Copy link

Hello,

This is just Q & A, sorry that I might have overlooked some document somewhere, but I have been searching for a while.
I noticed that after "pip install swig", there will be several swig.exe there (I'm using virtual python env):
\python39\scripts\swig.exe
\python39\scripts\swig4.0.exe
\python39\site-packages\swig\data\bin\swig.exe <= (this is the same one from swigwin4.2.1.zip)

Could you share what's the purpose of those 2 more different swig.exe in scripts folder?
It seems like we are supposedly to call swig.exe from scripts folder (by default only scripts folder in the env path) and somehow it will call to bin folder swig.exe to work with SWIG_LIB, but I'm not sure how to achieve this so would like to understand it for education of myself.

Thanks!

@nightlark
Copy link
Owner

Those two executables in the scripts folder are automatically created by pip for the console scripts entry points (https://setuptools.pypa.io/en/latest/userguide/entry_point.html#console-scripts) listed in https://github.com/nightlark/swig-pypi/blob/bbcf58eff/pyproject.toml#L46-L48 and essentially just call the underlying Python module/function name listed in the entry point. The swig4.0 entry point was added to address an issue with CMake searching for a program named swig4.0 (#120).

What you described is correct, calling the swig.exe in the scripts folder (after ensuring it is in the env path by e.g. activating the virtual environment) then calls the swig function in the swig Python module (https://github.com/nightlark/swig-pypi/blob/main/src/swig/__init__.py), which is a simple Python script that calls the actual swig.exe file (with SWIG_LIB being set using the env argument).

Side note regarding virtual environments: I've often started to recommend using pipx (https://github.com/pypa/pipx#on-windows) for installing Python apps, since pipx takes care of creating a fresh virtual environment for each installed app and the entry point scripts it creates automatically activate the virtual environment -- one less thing to remember to do. 😄

@ChaselChiu
Copy link
Author

Thanks for clarification and suggestion!

@ChaselChiu
Copy link
Author

closing this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants