conda / conda

A system-level, binary package and environment manager running on all major operating systems and platforms.
https://docs.conda.io/projects/conda/
Other
6.42k stars 1.66k forks source link

noarch python entry points created by conda differ than those created by conda-build #5001

Closed jjhelmus closed 7 years ago

jjhelmus commented 7 years ago

The entry point scripts which are created by conda for noarch: python packages differ slightly from those created for standard packages by conda-build. The templates for the scripts are:

conda:

python_entry_point_template = dals("""
# -*- coding: utf-8 -*-
if __name__ == '__main__':
    from sys import exit
    from %(module)s import %(func)s
    exit(%(func)s())
""")

conda-build:

PY_TMPL = """\
if __name__ == '__main__':
    import sys
    import %(module)s
    sys.exit(%(module)s.%(func)s())
"""

I've found at least one example where the template used by conda produces a script which does not work but when used with the conda-build template the script run fine.

jjhelmus commented 7 years ago

pip seems to use the following template for entry points (at least when installing wheels):

maker.script_template = """# -*- coding: utf-8 -*-
import re
import sys

from %(module)s import %(import_name)s

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(%(func)s())
"""

I would suggest that both conda and conda-build use this template as it seems the most general. I will put together PRs implementing this in both projects.

github-actions[bot] commented 2 years ago

Hi there, thank you for your contribution to Conda!

This issue has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue if needed.