-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathsetup.py
More file actions
54 lines (45 loc) · 1.46 KB
/
setup.py
File metadata and controls
54 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import setuptools
import toml
import os
import sys
usage = """
Usage: python setup.py bdist_wheel --plat-name <platform>
The PACKAGE_VERSION environment variable must be set to the desired version.
Example:
PACKAGE_VERSION=0.5.9 python setup.py bdist_wheel --plat-name linux_x86_64
"""
with open("pyproject.toml", "r") as f:
pyproject = toml.load(f)
project = pyproject["project"]
# Get version from environment or default
version = os.environ.get("PACKAGE_VERSION", "")
if not version:
print("PACKAGE_VERSION environment variable is not set.")
print(usage)
sys.exit(1)
# Get Python platform name from --plat-name argument
plat_name = None
for i, arg in enumerate(sys.argv):
if arg == "--plat-name" and i + 1 < len(sys.argv):
plat_name = sys.argv[i + 1]
break
if not plat_name:
print("Error: --plat-name argument is required")
print(usage)
sys.exit(1)
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
setuptools.setup(
name=project["name"],
version=version,
description=project.get("description", ""),
author=project["authors"][0]["name"],
long_description=long_description,
long_description_content_type="text/markdown",
url=project["urls"]["Homepage"],
packages=setuptools.find_packages(where="src"),
package_dir={"": "src"},
include_package_data=True,
python_requires=project.get("requires-python", ">=3"),
classifiers=project.get("classifiers", []),
)