feross / SpoofMAC

:briefcase: Change your MAC address for debugging
https://feross.org/spoofmac/
3.02k stars 271 forks source link

Remove ".py" from command name #34

Closed feross closed 9 years ago

feross commented 9 years ago

In 2.0.0 the command unintentionally changed to spoof-mac.py. Let's fix that.

cc @pteek

pteek commented 9 years ago

Yes it is needed on Win 7. I confirmed on 32bit ultimate and 64bit Home premium machines.

The simplest solution would be to just keep two files, one with .py. Is this too bad of a hack?

feross commented 9 years ago

Is this due to some change in Python 3? It was working before without the .py extension. @TkTech – can you confirm?

pteek commented 9 years ago

Windows uses only file extensions to associates files with programs. How it could work?

feross commented 9 years ago

I mean, Windows users have been using this library for years. It was working somehow. I don't know enough about Windows to explain why it worked. @cjbarker added that support, maybe he can chime in?

cjbarker commented 9 years ago

It was working fine on Windows 7 (Professional) 32 & 64bit. Windows does not require a file extension when you invoke via command line. The python interpreter does not care or enforce a file extension. Windows simply uses file extensions to link them to a default application to run. Just make sure you have the python.exe within your user's "PATH" environment variable.

Here's a simple example via cmd line w/ NO file extension: echo print 'Hello World!' > test python test Hello World!

Have you tested installing this EGG to verify calling it with no file extension?

As mentioned, it worked fine in the past. If you're still having issues I can take a look on Windows machine at home (don't have VM setup on current machine).

asmeurer commented 9 years ago

setuptools installs a .exe proxy for its entry points that point to the Python file automatically. .bat proxies are also possible.

pteek commented 9 years ago

If we use "python spoof-mac" it will work.I didn't like the extra python invocation and wanted the script to run just like any other command line tool.

In Linux, you can simply type spoof-mac and it will work because of the first line invoking a shell. I think the same functionality should be present in windows. Only typing spoof-mac should launch the script. Hence, we need the .py.

cjbarker commented 9 years ago

That's because Linux & Mac support the shebang line to map the script to the environment's interpreter. No such option exists in windows (excluding cygwin). Thus, you can either explicitly invoke the script with the interpreter or associate the file extension with the python.exe.

Allegedly, in Python 3.3 associates .py and .pyw file types with the respective launchers, py.exe and pyw.exe (no console), which enables shebang support in scripts. This still doesn't solve backwards compatibility.

I would recommend updating README for Windows to denote the three ways of invocation: 1) explicit python interpreter 2) File extension association with executable and possible 3) python 3 associate with .py|w

feross commented 9 years ago

@cjbarker I just added you as a collaborator on this repo. Feel free to make whatever README changes you want to clarify the Windows situation.

pteek commented 9 years ago

We have two scripts for now, one for win and one for nix. We will try to create a symlink spoof-mac to spoof-mac.py. Hopefully this will work on both platforms(git will ignore it on win and replicate on nix)

feross commented 9 years ago

Status of this?

pteek commented 9 years ago

I will test the symlink method.

feross commented 9 years ago

I believe this was fixed in 2.0.2, so I will close now.