Skip to content

Commit 4c95d11

Browse files
authored
Replace setup.py with pyproject.toml (#848)
* Replace setup.py with pyproject.toml + update test_pip_install.py * [.gitignore] Add "custom location" folder generated by test_pip_install.py * Install build in CI It is needed for test_pip_install.py * Require setuptools 77.0.0 or more to build the project This is necessary because setuptools added support for ``license`` and ``license-files`` in that version (and we use those in pyproject.toml) Changelog: https://setuptools.pypa.io/en/latest/history.html#v77-0-0
1 parent f2bd605 commit 4c95d11

File tree

6 files changed

+63
-171
lines changed

6 files changed

+63
-171
lines changed

.github/workflows/autotest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
architecture: ${{ matrix.architecture }}
6363
- name: install comtypes
6464
run: |
65-
pip install --upgrade setuptools
65+
pip install --upgrade build
6666
python -m pip install .
6767
pip uninstall comtypes -y
6868
python test_pip_install.py

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ comtypes/gen/
55
!comtypes/gen/__init__.py
66
comtypes/tools/__pycache__/*.pyc
77
comtypes.egg-info/*
8+
custom location/*
89

910
# Byte-compiled / optimized / DLL files
1011
__pycache__/

pyproject.toml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,63 @@
1+
[project]
2+
name = "comtypes"
3+
description = "Pure Python COM package"
4+
readme = "README.md"
5+
requires-python = ">=3.9"
6+
license = "MIT"
7+
license-files = ["LICENSE.txt"]
8+
authors = [
9+
{ name = "Thomas Heller", email = "[email protected]" },
10+
]
11+
classifiers = [
12+
"Development Status :: 5 - Production/Stable",
13+
"Intended Audience :: Developers",
14+
"Operating System :: Microsoft :: Windows",
15+
"Programming Language :: Python",
16+
"Programming Language :: Python :: 3",
17+
"Topic :: Software Development :: Libraries :: Python Modules",
18+
]
19+
dynamic = ["version"]
20+
21+
[project.scripts]
22+
clear_comtypes_cache = "comtypes.clear_cache:main"
23+
24+
[project.urls]
25+
Source = "https://github.com/enthought/comtypes"
26+
Download = "https://github.com/enthought/comtypes/releases"
27+
Issues = "https://github.com/enthought/comtypes/issues"
28+
129
[build-system]
2-
requires = ["setuptools>=61.2"]
30+
requires = ["setuptools>=77.0.0"]
331
build-backend = "setuptools.build_meta"
432

33+
[tool.setuptools]
34+
packages = [
35+
"comtypes",
36+
"comtypes._post_coinit",
37+
"comtypes.client",
38+
"comtypes.server",
39+
"comtypes.tools",
40+
"comtypes.tools.codegenerator",
41+
"comtypes.test",
42+
]
43+
44+
[tool.setuptools.dynamic]
45+
version = { attr = "comtypes.__version__" }
46+
47+
[tool.setuptools.package-data]
48+
"comtypes.test" = [
49+
"TestComServer.idl",
50+
"TestComServer.tlb",
51+
"TestDispServer.idl",
52+
"TestDispServer.tlb",
53+
"mytypelib.idl",
54+
"mylib.idl",
55+
"mylib.tlb",
56+
"urlhist.tlb",
57+
"test_jscript.js",
58+
]
59+
"comtypes" = ["hints.pyi"]
60+
561
[tool.ruff.lint]
662
extend-select = ["I"]
763
ignore = ["E402"]

setup.cfg

Lines changed: 0 additions & 48 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

test_pip_install.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ class TestPipInstall(unittest.TestCase):
2121

2222
def setUp(self):
2323
"""prepare the same package that is usually uploaded to PyPI"""
24-
subprocess.check_call([sys.executable, 'setup.py', 'sdist', '--format=zip'])
24+
subprocess.check_call([sys.executable, '-m', 'build', '--sdist'])
2525

26-
filename_for_upload = 'comtypes-%s.zip' % read_version()
26+
filename_for_upload = 'comtypes-%s.tar.gz' % read_version()
2727
self.target_package = os.path.join(os.getcwd(), 'dist', filename_for_upload)
2828
self.pip_exe = os.path.join(os.path.dirname(sys.executable), 'Scripts', 'pip.exe')
2929

3030
def test_pip_install(self):
31-
"""Test that "pip install comtypes-x.y.z.zip" works"""
31+
"""Test that "pip install comtypes-x.y.z.tar.gz" works"""
3232
subprocess.check_call([self.pip_exe, 'install', self.target_package])
3333

3434
def test_no_cache_dir_custom_location(self):
35-
"""Test that 'pip install comtypes-x.y.z.zip --no-cache-dir --target="...\custom location"' works"""
35+
"""Test that 'pip install comtypes-x.y.z.tar.gz --no-cache-dir --target="...\custom location"' works"""
3636
custom_dir = os.path.join(os.getcwd(), 'custom location')
3737
if os.path.exists(custom_dir):
3838
shutil.rmtree(custom_dir)

0 commit comments

Comments
 (0)