Commit ca2fbacf

Damien Deville <damien@openai.com>
2023-01-27 05:34:42
Fix invalid pyproject.toml file and move to setup.cfg (#201)
The `[project]` section of a `pyproject.toml` file *has* to include both a `name` and a `version`, that we were missing. However, rather than adding more stuff to `pyproject.toml`, I've moved the license info to the setup file and pointed `pyproject.toml` to use `setuptools` for building (the `pyproject.toml` file is really only needed to integrated with `black`, that doesn't support setup files...) While I was at it I decided to migrate to a `setup.cfg` file rather than `setup.py` since its declaritive config is usally preferred these days (and it's a bit easier to load from version/license files than with a `setup.py` file).
1 parent 86dff29
pyproject.toml
@@ -1,10 +1,6 @@
-[project]
-license = {file = "LICENSE"}
-classifiers = [
-    "Programming Language :: Python :: 3",
-    "License :: OSI Approved :: MIT License",
-    "Operating System :: OS Independent",
-]
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
 
 [tool.black]
 target-version = ['py36']
setup.cfg
@@ -0,0 +1,65 @@
+[metadata]
+name = openai
+version = attr: openai.version.VERSION
+description = Python client library for the OpenAI API
+long_description = file: README.md
+long_description_content_type = text/markdown
+author = OpenAI
+author_email = support@openai.com
+url = https://github.com/openai/openai-python
+license_files = LICENSE
+classifiers =
+  Programming Language :: Python :: 3
+  License :: OSI Approved :: MIT License
+  Operating System :: OS Independent
+
+[options]
+packages = find:
+python_requires = >=3.7.1
+zip_safe = True
+include_package_data = True
+install_requires =
+  requests >= 2.20  # to get the patch for CVE-2018-18074
+  tqdm  # Needed for progress bars
+  typing_extensions; python_version<"3.8"  # Needed for type hints for mypy
+  aiohttp  # Needed for async support
+
+[options.extras_require]
+dev =
+  black ~= 21.6b0
+  pytest == 6.*
+  pytest-asyncio
+  pytest-mock
+datalib =
+  numpy
+  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
+wandb =
+  wandb
+  numpy
+  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
+embeddings =
+  scikit-learn >= 1.0.2  # Needed for embedding utils, versions >= 1.1 require python 3.8
+  tenacity >= 8.0.1
+  matplotlib
+  sklearn
+  plotly
+  numpy
+  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
+
+[options.entry_points]
+console_scripts =
+  openai = openai._openai_scripts:main
+
+[options.package_data]
+  openai = py.typed
+
+[options.packages.find]
+exclude =
+  tests
+  tests.*
setup.py
@@ -1,67 +1,3 @@
-import os
+from setuptools import setup
 
-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)
-    
-with open("README.md", "r") as fh:
-    long_description = fh.read()
-
-
-DATA_LIBRARIES = [
-    # These libraries are optional because of their size. See `openai/datalib.py`.
-    "numpy",
-    "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
-]
-
-setup(
-    name="openai",
-    description="Python client library for the OpenAI API",
-    long_description=long_description,
-    long_description_content_type="text/markdown",
-    version=version_contents["VERSION"],
-    install_requires=[
-        "requests>=2.20",  # to get the patch for CVE-2018-18074
-        "tqdm",  # Needed for progress bars
-        'typing_extensions;python_version<"3.8"',  # Needed for type hints for mypy
-        "aiohttp",  # Needed for async support
-    ],
-    extras_require={
-        "dev": ["black~=21.6b0", "pytest==6.*", "pytest-asyncio", "pytest-mock"],
-        "datalib": DATA_LIBRARIES,
-        "wandb": [
-            "wandb",
-            *DATA_LIBRARIES,
-        ],
-        "embeddings": [
-            "scikit-learn>=1.0.2",  # Needed for embedding utils, versions >= 1.1 require python 3.8
-            "tenacity>=8.0.1",
-            "matplotlib",
-            "sklearn",
-            "plotly",
-            *DATA_LIBRARIES,
-        ],
-    },
-    python_requires=">=3.7.1",
-    entry_points={
-        "console_scripts": [
-            "openai=openai._openai_scripts:main",
-        ],
-    },
-    packages=find_packages(exclude=["tests", "tests.*"]),
-    package_data={
-        "openai": [
-            "py.typed",
-        ]
-    },
-    author="OpenAI",
-    author_email="support@openai.com",
-    url="https://github.com/openai/openai-python",
-)
+setup()