Skip to content

Commit 8b49129

Browse files
authored
Package python-ldap with pyproject.toml (#589)
1 parent a73ce55 commit 8b49129

File tree

10 files changed

+140
-114
lines changed

10 files changed

+140
-114
lines changed

.coveragerc

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

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*.pyc
44
__pycache__/
55
.tox
6-
.coverage*
7-
!.coveragerc
86
/.cache
97
/.pytest_cache
108

Doc/installing.rst

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,23 @@ The CVS repository of FreeBSD contains the package
7676
macOS
7777
-----
7878

79-
You can install directly with pip::
79+
You can install directly with pip. First install Xcode command line tools::
8080

8181
$ xcode-select --install
82-
$ pip install python-ldap \
83-
--global-option=build_ext \
84-
--global-option="-I$(xcrun --show-sdk-path)/usr/include/sasl"
82+
83+
Then install python-ldap::
84+
85+
$ pip install python-ldap
86+
87+
For custom installations, you may need to set environment variables::
88+
89+
$ export CPPFLAGS="-I$(xcrun --show-sdk-path)/usr/include/sasl"
90+
$ pip install python-ldap
91+
92+
If using Homebrew::
93+
94+
$ brew install openldap
95+
$ pip install python-ldap
8596

8697

8798
.. _install-source:
@@ -90,11 +101,14 @@ Installing from Source
90101
======================
91102

92103

93-
python-ldap is built and installed using the Python setuptools.
94-
From a source repository::
104+
python-ldap is built and installed using modern Python packaging standards
105+
with pyproject.toml configuration. From a source repository::
106+
107+
$ pip install .
108+
109+
For development installation with editable mode::
95110

96-
$ python -m pip install setuptools
97-
$ python setup.py install
111+
$ pip install -e .
98112

99113
If you have more than one Python interpreter installed locally, you should
100114
use the same one you plan to use python-ldap with.

Doc/spelling_wordlist.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func
6060
Gohlke
6161
GPG
6262
Heimdal
63+
Homebrew
6364
hostport
6465
hrefTarget
6566
hrefText
@@ -106,6 +107,7 @@ previousDN
106107
processResultsCount
107108
Proxied
108109
py
110+
pyproject
109111
pytest
110112
rdn
111113
readthedocs
@@ -146,6 +148,7 @@ syncrepl
146148
syntaxes
147149
timelimit
148150
TLS
151+
toml
149152
tracebacks
150153
tuple
151154
tuples
@@ -162,5 +165,6 @@ userPassword
162165
usr
163166
uuids
164167
Valgrind
168+
Xcode
165169
whitespace
166170
workflow

INSTALL

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Quick build instructions:
22

33
edit setup.cfg (see Build/ for platform-specific examples)
4-
python setup.py build
5-
python setup.py install
4+
pip install .
65

76
Detailed instructions are in Doc/installing.rst, or online at:
87

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include MANIFEST.in Makefile CHANGES INSTALL LICENCE README TODO
2-
include tox.ini .coveragerc
2+
include tox.ini
33
include Modules/*.c Modules/*.h
44
recursive-include Build *.cfg*
55
recursive-include Lib *.py

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Modules/constants_generated.h: Lib/ldap/constants.py
2020
.PHONY: clean
2121
clean:
2222
rm -rf build dist *.egg-info .tox MANIFEST
23-
rm -f .coverage .coverage.*
2423
find . \( -name '*.py[co]' -or -name '*.so*' -or -name '*.dylib' \) \
2524
-delete
2625
find . -depth -name __pycache__ -exec rm -rf {} \;

pyproject.toml

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,108 @@
1+
[build-system]
2+
requires = [
3+
"setuptools",
4+
"setuptools-scm",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[project]
9+
name = "python-ldap"
10+
license.text = "python-ldap" # Replace with 'license' once Python 3.8 is dropped
11+
dynamic = ["version"]
12+
description = "Python modules for implementing LDAP clients"
13+
authors = [
14+
{name = "python-ldap project", email = "python-ldap@python.org"},
15+
]
16+
readme = "README"
17+
requires-python = ">=3.6"
18+
keywords = ["ldap", "directory", "authentication"]
19+
classifiers = [
20+
"Development Status :: 5 - Production/Stable",
21+
"Intended Audience :: Developers",
22+
"Intended Audience :: System Administrators",
23+
"Operating System :: OS Independent",
24+
"Operating System :: MacOS :: MacOS X",
25+
"Operating System :: Microsoft :: Windows",
26+
"Operating System :: POSIX",
27+
"Programming Language :: C",
28+
"Programming Language :: Python",
29+
"Programming Language :: Python :: 3",
30+
"Programming Language :: Python :: 3.6",
31+
"Programming Language :: Python :: 3.7",
32+
"Programming Language :: Python :: 3.8",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Programming Language :: Python :: 3.13",
38+
"Topic :: Database",
39+
"Topic :: Internet",
40+
"Topic :: Software Development :: Libraries :: Python Modules",
41+
"Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP",
42+
"License :: OSI Approved :: Python Software Foundation License",
43+
]
44+
dependencies = [
45+
"pyasn1 >= 0.3.7",
46+
"pyasn1_modules >= 0.1.5",
47+
]
48+
49+
[project.urls]
50+
Homepage = "https://www.python-ldap.org/"
51+
Documentation = "https://python-ldap.readthedocs.io/"
52+
Repository = "https://github.com/python-ldap/python-ldap"
53+
Download = "https://pypi.org/project/python-ldap/"
54+
Changelog = "https://github.com/python-ldap/python-ldap/blob/main/CHANGES"
55+
56+
57+
58+
[tool.setuptools]
59+
zip-safe = false
60+
include-package-data = true
61+
license-files = ["LICENCE", "LICENCE.MIT"]
62+
# Explicitly list all Python modules
63+
py-modules = ["ldapurl", "ldif"]
64+
65+
[tool.setuptools.dynamic]
66+
version = {attr = "ldap.pkginfo.__version__"}
67+
68+
[tool.setuptools.packages.find]
69+
where = ["Lib"]
70+
71+
[tool.setuptools.package-dir]
72+
"" = "Lib"
73+
174
[tool.isort]
2-
line_length=88
3-
known_first_party=['ldap', '_ldap', 'ldapurl', 'ldif', 'slapdtest']
4-
sections=['FUTURE', 'STDLIB', 'THIRDPARTY', 'FIRSTPARTY', 'LOCALFOLDER']
75+
line_length = 88
76+
known_first_party = ["ldap", "_ldap", "ldapurl", "ldif", "slapdtest"]
77+
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
78+
79+
[tool.coverage.run]
80+
branch = true
81+
source = [
82+
"ldap",
83+
"ldif",
84+
"ldapurl",
85+
"slapdtest",
86+
]
87+
88+
[tool.coverage.paths]
89+
source = [
90+
"Lib/",
91+
".tox/*/lib/python*/site-packages/",
92+
]
93+
94+
[tool.coverage.report]
95+
ignore_errors = false
96+
precision = 1
97+
exclude_lines = [
98+
"pragma: no cover",
99+
"raise NotImplementedError",
100+
"if 0:",
101+
"if __name__ == .__main__.:",
102+
"if PY2",
103+
"if not PY2",
104+
]
105+
106+
[tool.coverage.html]
107+
directory = "build/htmlcov"
108+
title = "python-ldap coverage report"

setup.py

Lines changed: 4 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""
2-
setup.py - Setup package with the help Python's DistUtils
2+
setup.py - C extension module configuration for python-ldap
33
44
See https://www.python-ldap.org/ for details.
5+
This file handles only the C extension modules (_ldap) configuration,
6+
while pyproject.toml handles all project metadata, dependencies, and other settings.
57
"""
68

79
import sys,os
@@ -54,52 +56,8 @@ class OpenLDAP2:
5456
LDAP_CLASS.extra_link_args.append('-pg')
5557
LDAP_CLASS.libs.append('gcov')
5658

57-
#-- Let distutils/setuptools do the rest
58-
name = 'python-ldap'
59-
59+
#-- C extension modules configuration only
6060
setup(
61-
#-- Package description
62-
name = name,
63-
license=pkginfo.__license__,
64-
version=pkginfo.__version__,
65-
description = 'Python modules for implementing LDAP clients',
66-
long_description = """python-ldap:
67-
python-ldap provides an object-oriented API to access LDAP directory servers
68-
from Python programs. Mainly it wraps the OpenLDAP 2.x libs for that purpose.
69-
Additionally the package contains modules for other LDAP-related stuff
70-
(e.g. processing LDIF, LDAPURLs, LDAPv3 schema, LDAPv3 extended operations
71-
and controls, etc.).
72-
""",
73-
author = 'python-ldap project',
74-
author_email = 'python-ldap@python.org',
75-
url = 'https://www.python-ldap.org/',
76-
download_url = 'https://pypi.org/project/python-ldap/',
77-
classifiers = [
78-
'Development Status :: 5 - Production/Stable',
79-
'Intended Audience :: Developers',
80-
'Intended Audience :: System Administrators',
81-
'Operating System :: OS Independent',
82-
'Operating System :: MacOS :: MacOS X',
83-
'Operating System :: Microsoft :: Windows',
84-
'Operating System :: POSIX',
85-
'Programming Language :: C',
86-
87-
'Programming Language :: Python',
88-
'Programming Language :: Python :: 3',
89-
'Programming Language :: Python :: 3.9',
90-
'Programming Language :: Python :: 3.10',
91-
'Programming Language :: Python :: 3.11',
92-
'Programming Language :: Python :: 3.12',
93-
'Programming Language :: Python :: 3.13',
94-
# Note: when updating Python versions, also change tox.ini and .github/workflows/*
95-
96-
'Topic :: Database',
97-
'Topic :: Internet',
98-
'Topic :: Software Development :: Libraries :: Python Modules',
99-
'Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP',
100-
'License :: OSI Approved :: Python Software Foundation License',
101-
],
102-
#-- C extension modules
10361
ext_modules = [
10462
Extension(
10563
'_ldap',
@@ -135,28 +93,4 @@ class OpenLDAP2:
13593
]
13694
),
13795
],
138-
#-- Python "stand alone" modules
139-
py_modules = [
140-
'ldapurl',
141-
'ldif',
142-
143-
],
144-
packages = [
145-
'ldap',
146-
'ldap.controls',
147-
'ldap.extop',
148-
'ldap.schema',
149-
'slapdtest',
150-
'slapdtest.certs',
151-
],
152-
package_dir = {'': 'Lib',},
153-
data_files = LDAP_CLASS.extra_files,
154-
include_package_data=True,
155-
install_requires=[
156-
'pyasn1 >= 0.3.7',
157-
'pyasn1_modules >= 0.1.5',
158-
],
159-
zip_safe=False,
160-
python_requires='>=3.9',
161-
test_suite = 'Tests',
16296
)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ commands = {envpython} -bb -Werror \
3333
setenv =
3434
CFLAGS=-Wno-int-in-bool-context -Werror -std=c99
3535

36+
3637
[testenv:py3-nosasltls]
3738
basepython = python3
3839
# don't install, install dependencies manually

0 commit comments

Comments
 (0)