You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if it might make sense to switch from scripts to entry_points console_scripts in setup.py. This is the more modern and preferred approach and recommended by PyPA nowadays.
Holy moly, you had the exact same idea as me! I added platform-specific logic in order to detect the Windows 10 operating system and then use the entry_pointsconsole_scripts logic to allow setup.py to compile a Windows executable to the Scripts directory. This fixes the issue with Windows users having to install 3rd party programs that support running bash scripts since the bin/openai file is exactly that.
Platform-specific logic isn't necessarily needed, however I figured we'd leave the Linux / Mac implementation unchanged for the time being. Here's my code:
--
import os
import sys
from setuptools import find_packages, setup
version_contents = {}
version_path = os.path.join(
os.path.abspath(os.path.dirname(__file__)), "openai/version.py"
)
with open(version_path, "rt") as f:
exec(f.read(), version_contents)
if sys.platform == 'win32':
# https://stackoverflow.com/questions/51785602/is-possible-to-install-a-module-and-a-wrapper-script-using-pip-at-once
# Windows users: Include 'entry_points' in setup() but we exclude "bin/openai"
entry_points = {
'console_scripts' : [ 'openai = openai.openai_cli_tool:main' ]
}
scripts = []
else:
# Linux and macOS users: No 'entry_points' needed in setup() but we include "bin/openai"
entry_points = {}
scripts = ["bin/openai"]
setup(
name="openai",
description="Python client library for the OpenAI API",
version=version_contents["VERSION"],
install_requires=[
"requests>=2.20", # to get the patch for CVE-2018-18074
"tqdm", # Needed for progress bars
"pandas>=1.2.3", # Needed for CLI fine-tuning data preparation tool
"pandas-stubs>=1.1.0.11", # Needed for type hints for mypy
"openpyxl>=3.0.7", # Needed for CLI fine-tuning data preparation tool xlsx format
],
extras_require={"dev": ["black~=21.6b0", "pytest==6.*"]},
python_requires=">=3.7.1",
scripts=scripts,
entry_points=entry_points,
packages=find_packages(exclude=["tests", "tests.*"]),
package_data={
"openai": [
"data/ca-certificates.crt",
"py.typed",
]
},
author="OpenAI",
author_email="support@openai.com",
url="https://github.com/openai/openai-python",
)
Since one of the key points of entry_points is cross platform support I wouldn't exclude it for a particular platform (and it'S much more modern anyways) but I have #52 so the maintainers from here can weigh in and then we can adapt accordingly.
Activity
DutytoDevelop commentedon Dec 16, 2021
Holy moly, you had the exact same idea as me! I added platform-specific logic in order to detect the Windows 10 operating system and then use the
entry_pointsconsole_scriptslogic to allow setup.py to compile a Windows executable to theScriptsdirectory. This fixes the issue with Windows users having to install 3rd party programs that support running bash scripts since thebin/openaifile is exactly that.Platform-specific logic isn't necessarily needed, however I figured we'd leave the Linux / Mac implementation unchanged for the time being. Here's my code:
--
BastianZim commentedon Dec 17, 2021
Haha that's great to hear!
Since one of the key points of
entry_pointsis cross platform support I wouldn't exclude it for a particular platform (and it'S much more modern anyways) but I have #52 so the maintainers from here can weigh in and then we can adapt accordingly.renaming snapshot to model (openai#27)
renaming snapshot to model (openai#27)