The problem I am having is Windows specific, but I think this is a good opportunity to learn more about my options.
So, I have a project that I wish to install on Windows, Linux and Mac machines. I am using setuptools
as by build-backend to build my utility for deployment.
I am using a pyproject.toml
file for my project build specs. wherein I specify the project.scripts
.
something like this
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name=mypackage
....
[project.scripts]
myapp = "mypackage.mymodule:main"
When install the package using pip
, I do see the myapp.exe
file getting created in the Scripts
directory. But, due to a quirk of an upstream dependency my executable ends up also looking for myapp
binary-executable file as well (instead of just working with myapp.exe
)…
So now I am looking for workarounds so that my utility does not break ..
One workaround I came up with was to use shutils
to copy the myapp.exe
file as myapp
within the Scripts
directory as soon as the application starts. That way when the dependency looks for myapp
it finds it and everything works.
I tried to create a symlink first, but found out that to create a symlink you need admin permission in Windows. So, I had to come up with this cheap hack of copying the myapp.exe
as myapp
.
I am not happy with this workaround because it clutters my application. I’d like to keep my build code and quirks separate from my application code if I can help it.
So, I was wondering if I could get my build system to create both myapp.exe
and myapp
executables if the target OS is Windows7/10/11 ? Can I do that ? If so, how ?