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

Generate js-beautify executable properly on windows when installed from PIP #1266

Closed
brupelo opened this issue Oct 8, 2017 · 3 comments
Closed

Comments

@brupelo
Copy link

brupelo commented Oct 8, 2017

Hi,

After installing js-beautify on a python virtualenv (i.e pip install jsbeautifier) one file js-beautify with no extension has been created on the scripts folder, which contains:

#!d:\software\sublim~2\data\packages\miscel~1\test\scripts\python.exe
#
# Stub script to run jsbeautifier
#
import sys
from jsbeautifier import main
sys.exit(main())

This file, even if it's found in the path (where js-beautify) won't work on windows, it doesn't know anything neither about shebangs nor files without extension... so, could you please fix the setup.py properly so a windows executable will be created instead (like flake8, pep8, youtube-dl, ...). For more info about it take a look to here http://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation. One real example here https://github.com/altendky/st/blob/lib/setup.py#L14.

Thanks in advance.

@brupelo
Copy link
Author

brupelo commented Oct 8, 2017

The good solution would be this one:

setup(name='jsbeautifier',
      version=__version__,
      description='JavaScript unobfuscator and beautifier.',
      long_description=('Beautify, unpack or deobfuscate JavaScript. '
                        'Handles popular online obfuscators.'),
      author='Einar Lielmanis, Stefano Sanfilippo et al.',
      author_email='[email protected]',
      url='http://jsbeautifier.org',
      entry_points={
          'console_scripts': [
              'js-beautify = jsbeautifier:main'
          ]
      },
      packages=['jsbeautifier',
                'jsbeautifier.tests', 'jsbeautifier.tests.generated',
                'jsbeautifier.core',
                'jsbeautifier.javascript',
                'jsbeautifier.unpackers', 'jsbeautifier.unpackers.tests'],
      install_requires=["six>=1.6.1", "editorconfig>=0.12.0"],
      license='MIT',
      test_suite='pytest.collector',
      cmdclass = {'test': PyTest},

     )

And of course, delete js-beautify file from the repo. After this the installation/uninstallation should be clean. Not doing a PR cos i've justed tested on win.

@bitwiseman bitwiseman added this to the v1.7.x milestone Oct 8, 2017
@bitwiseman
Copy link
Member

@brupelo Please do a PR. At very least that will give a better understanding of what you believe the fix should be. Also, as part of the PR you can add tests to verify the new behavior which will further show what your fix does.

@vivainio
Copy link
Contributor

@brupelo solution is correct. I created pull request for it:

#1455

bitwiseman added a commit that referenced this issue Jul 26, 2018
Use entry_points to create script. Fix #1266 (script not working on Windows)
@bitwiseman bitwiseman modified the milestones: v1.8.x, 1.8.0-rc3 Jul 31, 2018
@bitwiseman bitwiseman modified the milestones: 1.8.0-rc4, 1.8.0 Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants