Skip to content

Commit f4c68c9

Browse files
ddevilledavedittrich
authored andcommitted
Fix invalid pyproject.toml file and move to setup.cfg (openai#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 9393cb9 commit f4c68c9

File tree

3 files changed

+70
-88
lines changed

3 files changed

+70
-88
lines changed

pyproject.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
[project]
2-
license = {file = "LICENSE"}
3-
classifiers = [
4-
"Programming Language :: Python :: 3",
5-
"License :: OSI Approved :: MIT License",
6-
"Operating System :: OS Independent",
7-
]
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
84

95
[tool.black]
106
target-version = ['py36']

setup.cfg

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[metadata]
2+
name = openai
3+
version = attr: openai.version.VERSION
4+
description = Python client library for the OpenAI API
5+
long_description = file: README.md
6+
long_description_content_type = text/markdown
7+
author = OpenAI
8+
author_email = support@openai.com
9+
url = https://github.com/openai/openai-python
10+
license_files = LICENSE
11+
classifiers =
12+
Programming Language :: Python :: 3
13+
License :: OSI Approved :: MIT License
14+
Operating System :: OS Independent
15+
16+
[options]
17+
packages = find:
18+
python_requires = >=3.7.1
19+
zip_safe = True
20+
include_package_data = True
21+
install_requires =
22+
requests >= 2.20 # to get the patch for CVE-2018-18074
23+
tqdm # Needed for progress bars
24+
typing_extensions; python_version<"3.8" # Needed for type hints for mypy
25+
aiohttp # Needed for async support
26+
27+
[options.extras_require]
28+
dev =
29+
black ~= 21.6b0
30+
pytest == 6.*
31+
pytest-asyncio
32+
pytest-mock
33+
datalib =
34+
numpy
35+
pandas >= 1.2.3 # Needed for CLI fine-tuning data preparation tool
36+
pandas-stubs >= 1.1.0.11 # Needed for type hints for mypy
37+
openpyxl >= 3.0.7 # Needed for CLI fine-tuning data preparation tool xlsx format
38+
wandb =
39+
wandb
40+
numpy
41+
pandas >= 1.2.3 # Needed for CLI fine-tuning data preparation tool
42+
pandas-stubs >= 1.1.0.11 # Needed for type hints for mypy
43+
openpyxl >= 3.0.7 # Needed for CLI fine-tuning data preparation tool xlsx format
44+
embeddings =
45+
scikit-learn >= 1.0.2 # Needed for embedding utils, versions >= 1.1 require python 3.8
46+
tenacity >= 8.0.1
47+
matplotlib
48+
sklearn
49+
plotly
50+
numpy
51+
pandas >= 1.2.3 # Needed for CLI fine-tuning data preparation tool
52+
pandas-stubs >= 1.1.0.11 # Needed for type hints for mypy
53+
openpyxl >= 3.0.7 # Needed for CLI fine-tuning data preparation tool xlsx format
54+
55+
[options.entry_points]
56+
console_scripts =
57+
openai = openai._openai_scripts:main
58+
59+
[options.package_data]
60+
openai = py.typed
61+
62+
[options.packages.find]
63+
exclude =
64+
tests
65+
tests.*

setup.py

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,3 @@
1-
import os
1+
from setuptools import setup
22

3-
from setuptools import find_packages, setup
4-
5-
version_contents = {}
6-
version_path = os.path.join(
7-
os.path.abspath(os.path.dirname(__file__)), "openai/version.py"
8-
)
9-
with open(version_path, "rt") as f:
10-
exec(f.read(), version_contents) # nosec
11-
12-
with open("README.md", "r") as fh:
13-
long_description = fh.read()
14-
15-
16-
DATA_LIBRARIES = [
17-
# These libraries are optional because of their size. See `openai/datalib.py`.
18-
"numpy",
19-
"pandas>=1.2.3", # Needed for CLI fine-tuning data preparation tool
20-
"pandas-stubs>=1.1.0.11", # Needed for type hints for mypy
21-
"openpyxl>=3.0.7", # Needed for CLI fine-tuning data preparation tool xlsx format
22-
]
23-
24-
setup(
25-
name="openai",
26-
description="Python client library for the OpenAI API",
27-
long_description=long_description,
28-
long_description_content_type="text/markdown",
29-
version=version_contents["VERSION"],
30-
install_requires=[
31-
"cliff", # For CLI framework
32-
"requests>=2.20", # to get the patch for CVE-2018-18074
33-
"tqdm", # Needed for progress bars
34-
"python-secrets", # For flexibility in accessing secrets and state apart from source code
35-
'tiktoken', # Needed for calculating number of tokens
36-
'typing_extensions;python_version<"3.8"', # Needed for type hints for mypy
37-
"aiohttp", # Needed for async support
38-
"Pillow", # Needed for manipulating images
39-
],
40-
extras_require={
41-
"dev": ["black~=21.6b0", "pytest==6.*", "pytest-asyncio", "pytest-mock"],
42-
"datalib": DATA_LIBRARIES,
43-
"wandb": [
44-
"wandb",
45-
*DATA_LIBRARIES,
46-
],
47-
"embeddings": [
48-
"scikit-learn>=1.0.2", # Needed for embedding utils, versions >= 1.1 require python 3.8
49-
"tenacity>=8.0.1",
50-
"matplotlib",
51-
"sklearn",
52-
"plotly",
53-
*DATA_LIBRARIES,
54-
],
55-
},
56-
python_requires=">=3.7.1",
57-
entry_points={
58-
"console_scripts": [
59-
"openai=openai._openai_scripts:main",
60-
"ocd=ocd.__main__:main",
61-
],
62-
"ocd": [
63-
"completions create=ocd.completions.create:CompletionsCreate",
64-
"edits create=ocd.edits.create:EditsCreate",
65-
"fine-tune list=ocd.fine_tune.list:FineTuneList",
66-
"images create=ocd.images.create:ImagesCreate",
67-
"models list=ocd.models.list:ModelsList",
68-
"models retrieve=ocd.models.retrieve:ModelsRetrieve",
69-
"models overview=ocd.models.overview:ModelsOverview",
70-
"text analyze=ocd.text.analyze:TextAnalyze",
71-
]
72-
},
73-
packages=find_packages(exclude=["tests", "tests.*"]),
74-
package_data={
75-
"openai": [
76-
"py.typed",
77-
]
78-
},
79-
author="OpenAI",
80-
author_email="support@openai.com",
81-
url="https://github.com/openai/openai-python",
82-
)
3+
setup()

0 commit comments

Comments
 (0)