Skip to content

Commit ee043f1

Browse files
committed
[build] use pyproject.toml replace setup.py
1 parent fefe28d commit ee043f1

File tree

6 files changed

+141
-59
lines changed

6 files changed

+141
-59
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ xArm Python SDK
1010

1111
## Installation
1212
  you can run examples without installation.Only Python3 is supported.
13-
- download
14-
15-
```bash
16-
git clone https://github.com/xArm-Developer/xArm-Python-SDK.git
17-
```
18-
19-
- install
20-
21-
```bash
22-
python setup.py install
23-
```
24-
13+
- Install from source code
14+
- download
15+
```bash
16+
git clone https://github.com/xArm-Developer/xArm-Python-SDK.git
17+
cd cd xArm-Python-SDK
18+
```
19+
- install
20+
- install with build
21+
```bash
22+
pip install build
23+
python -m build
24+
pip install dist/xarm_python_sdk-1.15.1-py3-none-any.whl
25+
```
26+
- install with source code
27+
```bash
28+
pip install .
29+
```
30+
- Install from pypi
2531
```bash
2632
pip install xarm-python-sdk
2733
```

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Supported Products
2222
Compatibility
2323
-------------
2424

25-
- Python 3.6 – 3.13
25+
- Python 3.5 - 3.13
2626

2727
Installation
2828
------------

pyproject.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[build-system]
2+
requires = [
3+
"hatchling; python_full_version >= '3.8'",
4+
"setuptools >= 40.8.0; python_full_version < '3.8'",
5+
]
6+
build-backend = "build_backend"
7+
backend-path = ["xarm"]
8+
9+
[tool.hatch.build.targets.wheel]
10+
packages = ["xarm"]
11+
12+
[tool.hatch.version]
13+
path = "xarm/version.py"
14+
15+
[project]
16+
name = "xarm-python-sdk"
17+
dynamic = ["version"]
18+
authors = [
19+
{ name="Vinman", email="[email protected]" },
20+
]
21+
maintainers = [
22+
{ name="Vinman", email="[email protected]" },
23+
{ name="Minna", email="[email protected]" },
24+
]
25+
description = "Python SDK for UFACTORY robotic arm 850, xArm 5/6/7, and Lite6."
26+
readme = "README.rst"
27+
requires-python = ">=3.5"
28+
classifiers = [
29+
"Intended Audience :: Developers",
30+
"Operating System :: OS Independent",
31+
"Programming Language :: Python",
32+
"Programming Language :: Python :: 3",
33+
"Programming Language :: Python :: 3.5",
34+
"Programming Language :: Python :: 3.6",
35+
"Programming Language :: Python :: 3.7",
36+
"Programming Language :: Python :: 3.8",
37+
"Programming Language :: Python :: 3.9",
38+
"Programming Language :: Python :: 3.10",
39+
"Programming Language :: Python :: 3.11",
40+
"Programming Language :: Python :: 3.12",
41+
"Programming Language :: Python :: 3.13",
42+
"Topic :: Software Development",
43+
]
44+
# license = "BSD-3-Clause"
45+
# license-files = ["LICEN[CS]E*"]
46+
47+
[project.urls]
48+
Homepage = "https://www.ufactory.cc"
49+
Documentation = "https://github.com/xArm-Developer/xArm-Python-SDK/doc/api/xarm_api.md"
50+
Repository = "https://github.com/xArm-Developer/xArm-Python-SDK.git"
51+
Issues = "https://github.com/xArm-Developer/xArm-Python-SDK/issues"

setup.py

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,67 @@
11
#!/usr/bin/env python3
2-
# Software License Agreement (BSD License)
3-
#
4-
# Copyright (c) 2017, UFactory, Inc.
5-
# All rights reserved.
6-
#
7-
# Author: Vinman <[email protected]>
8-
92
import os
10-
from distutils.util import convert_path
3+
import sys
4+
install_setuptools = False
115
try:
126
from setuptools import setup, find_packages
137
except ImportError:
14-
from distutils.core import setup
15-
16-
def find_packages(base_path='.'):
17-
base_path = convert_path(base_path)
18-
found = []
19-
for root, dirs, files in os.walk(base_path, followlinks=True):
20-
dirs[:] = [d for d in dirs if d[0] != '.' and d not in ('ez_setup', '__pycache__')]
21-
relpath = os.path.relpath(root, base_path)
22-
parent = relpath.replace(os.sep, '.').lstrip('.')
23-
if relpath != '.' and parent not in found:
24-
# foo.bar package but no foo package, skip
25-
continue
26-
for dir in dirs:
27-
if os.path.isfile(os.path.join(root, dir, '__init__.py')):
28-
package = '.'.join((parent, dir)) if parent else dir
29-
found.append(package)
30-
return found
8+
os.system('{} -m pip install setuptools'.format(sys.executable))
9+
# os.system('{} -m pip install setuptools==79.0.0'.format(sys.executable))
10+
install_setuptools = True
11+
try:
12+
from setuptools import setup, find_packages
13+
except ImportError as e:
14+
print('setuptools not found, {}'.format(e))
15+
exit(1)
3116

3217
main_ns = {}
33-
ver_path = convert_path('xarm/version.py')
34-
with open(os.path.join(os.getcwd(), ver_path)) as ver_file:
18+
with open(os.path.join(os.getcwd(), 'xarm/version.py')) as ver_file:
3519
exec(ver_file.read(), main_ns)
20+
version = main_ns['__version__']
3621

37-
version = main_ns['__version__']
38-
39-
long_description = open('README.rst').read()
40-
# long_description = 'long description for xArm-Python-SDK'
22+
long_description = open('README.rst', encoding='utf-8').read()
4123

42-
try:
24+
requirements_path = os.path.join(os.getcwd(), 'requirements.txt')
25+
if os.path.exists(requirements_path):
4326
with open(os.path.join(os.getcwd(), 'requirements.txt')) as f:
4427
requirements = f.read().splitlines()
45-
except:
28+
else:
4629
requirements = []
4730

48-
setup(
49-
name='xArm-Python-SDK',
50-
version=version,
51-
author='Vinman',
52-
description='Python SDK for xArm',
53-
packages=find_packages(),
54-
author_email='[email protected]',
55-
install_requires=requirements,
56-
long_description=long_description,
57-
license='MIT',
58-
zip_safe=False
59-
)
31+
try:
32+
setup(
33+
name='xarm-python-sdk',
34+
version=version,
35+
author='Vinman',
36+
author_email='[email protected]',
37+
description='Python SDK for UFACTORY robotic arm 850, xArm 5/6/7, and Lite6.',
38+
long_description=long_description,
39+
url='https://github.com/xArm-Developer/xArm-Python-SDK',
40+
packages=find_packages(),
41+
install_requires=requirements,
42+
# license='BSD',
43+
zip_safe=False,
44+
classifiers=[
45+
"Intended Audience :: Developers",
46+
"License :: OSI Approved :: BSD License",
47+
"Operating System :: OS Independent",
48+
"Programming Language :: Python",
49+
"Programming Language :: Python :: 3",
50+
"Programming Language :: Python :: 3.5",
51+
"Programming Language :: Python :: 3.6",
52+
"Programming Language :: Python :: 3.7",
53+
"Programming Language :: Python :: 3.8",
54+
"Programming Language :: Python :: 3.9",
55+
"Programming Language :: Python :: 3.10",
56+
"Programming Language :: Python :: 3.11",
57+
"Programming Language :: Python :: 3.12",
58+
"Programming Language :: Python :: 3.13",
59+
"Topic :: Software Development",
60+
],
61+
python_requires='>=3.5',
62+
)
63+
except Exception as e:
64+
raise e
65+
finally:
66+
if install_setuptools:
67+
os.system('{} -m pip uninstall setuptools -y'.format(sys.executable))

xarm/build_backend.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
import sys
3+
4+
if sys.version_info.major > 3 or (sys.version_info.major == 3 and sys.version_info.minor >= 8):
5+
# os.environ['_PYPROJECT_HOOKS_BUILD_BACKEND'] = 'hatchling.build'
6+
# requires = [
7+
# "hatchling",
8+
# ]
9+
# build-backend = "hatchling.build"
10+
from hatchling.build import *
11+
else:
12+
# os.environ['_PYPROJECT_HOOKS_BUILD_BACKEND'] = 'setuptools.build_meta'
13+
# requires = [
14+
# "setuptools >= 40.8.0",
15+
# ]
16+
# build-backend = "setuptools.build_meta"
17+
from setuptools.build_meta import *

xarm/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.15.1'
1+
__version__ = '1.15.2'

0 commit comments

Comments
 (0)