Skip to content

Commit 13e8068

Browse files
committed
packaging: modernize packaging
- Replace pbr with setuptools, setuptools_scm, and build. - Move most of the packaging settings into pyproject.toml. - Update tox settings to reflect packaging changes. - Update documentation build version detection. - Update documentation for entry points now that setup.cfg is removed. Fixes #33 Addresses #34
1 parent ceaa88f commit 13e8068

File tree

7 files changed

+115
-105
lines changed

7 files changed

+115
-105
lines changed

docs/source/conf.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# serve to show the default.
1414

1515
import datetime
16-
import subprocess
16+
import importlib.metadata
1717

1818
# If extensions (or modules to document with autodoc) are in another directory,
1919
# add these directories to sys.path here. If the directory is relative to the
@@ -51,11 +51,7 @@
5151
# built documents.
5252
#
5353
# The short X.Y version.
54-
version = subprocess.check_output([
55-
'sh', '-c',
56-
'cd ../..; python setup.py --version',
57-
]).decode('utf-8')
58-
version = version.strip()
54+
version = importlib.metadata.version('virtualenvwrapper')
5955
# The full version, including alpha/beta/rc tags.
6056
release = version
6157

docs/source/plugins.rst

+14-9
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,30 @@ Registering Entry Points
162162

163163
The functions defined in the plugin need to be registered as *entry
164164
points* in order for virtualenvwrapper's hook loader to find them.
165-
Entry points are configured in the ``setup.py`` (or ``setup.cfg`` when
166-
using pbr) for your package by mapping the entry point name to the
167-
function in the package that implements it.
165+
Entry points are configured in the packaging instructions for your
166+
package by mapping the entry point name to the function in the package
167+
that implements it.
168168

169-
This partial copy of virtualenvwrapper's ``setup.cfg`` illustrates how
169+
This partial copy of virtualenvwrapper's ``pyproject.toml`` illustrates how
170170
the ``initialize()`` and ``initialize_source()`` entry points are
171171
configured.
172172

173-
.. include:: ../../setup.cfg
174-
:literal:
175-
:start-after: [entry_points]
173+
::
174+
175+
[project.entry-points."virtualenvwrapper.initialize"]
176+
user_scripts = "virtualenvwrapper.user_scripts:initialize"
177+
project = "virtualenvwrapper.project:initialize"
178+
179+
[project.entry-points."virtualenvwrapper.initialize_source"]
180+
user_scripts = "virtualenvwrapper.user_scripts:initialize_source"
176181

177-
The ``entry_points`` section maps the *group names* to lists of entry
182+
Each entry points section maps the *group names* to lists of entry
178183
point specifiers. A different group name is defined by
179184
virtualenvwrapper for each extension point (see
180185
:ref:`plugins-extension-points`).
181186

182187
The entry point specifiers are strings with the syntax ``name =
183-
package.module:function``. By convention, the *name* of each entry
188+
"package.module:function"``. By convention, the *name* of each entry
184189
point is the plugin name, but that is not required (the names are not
185190
used).
186191

pyproject.toml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
[build-system]
2+
requires = ["setuptools", "setuptools_scm[toml]>=6.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
authors = [
7+
{name = "Doug Hellmann", email = "[email protected]"},
8+
{name = "Jason Myers", email = "[email protected]"},
9+
]
10+
11+
classifiers = [
12+
"Development Status :: 5 - Production/Stable",
13+
"License :: OSI Approved :: MIT License",
14+
"Programming Language :: Python",
15+
"Programming Language :: Python :: 3",
16+
"Programming Language :: Python :: 3.8",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Intended Audience :: Developers",
21+
"Environment :: Console",
22+
]
23+
24+
name = "virtualenvwrapper"
25+
description = ""
26+
dynamic = ["version"]
27+
keywords = ["virtualenv"]
28+
license = {text = "MIT"}
29+
readme = "README.txt"
30+
requires-python = ">=3.8"
31+
32+
dependencies = [
33+
"virtualenv",
34+
"virtualenv-clone",
35+
"stevedore",
36+
]
37+
38+
# https://github.com/pypa/setuptools_scm/
39+
[tool.setuptools_scm]
40+
41+
[project.urls]
42+
homepage = "https://virtualenvwrapper.readthedocs.io/"
43+
repository = "https://github.com/python-virtualenvwrapper/virtualenvwrapper"
44+
45+
[project.entry-points."virtualenvwrapper.initialize"]
46+
user_scripts = "virtualenvwrapper.user_scripts:initialize"
47+
project = "virtualenvwrapper.project:initialize"
48+
49+
[project.entry-points."virtualenvwrapper.initialize_source"]
50+
user_scripts = "virtualenvwrapper.user_scripts:initialize_source"
51+
52+
[project.entry-points."virtualenvwrapper.pre_mkvirtualenv"]
53+
user_scripts = "virtualenvwrapper.user_scripts:pre_mkvirtualenv"
54+
55+
[project.entry-points."virtualenvwrapper.post_mkvirtualenv_source"]
56+
user_scripts = "virtualenvwrapper.user_scripts:post_mkvirtualenv_source"
57+
58+
[project.entry-points."virtualenvwrapper.pre_cpvirtualenv"]
59+
user_scripts = "virtualenvwrapper.user_scripts:pre_cpvirtualenv"
60+
61+
[project.entry-points."virtualenvwrapper.post_cpvirtualenv_source"]
62+
user_scripts = "virtualenvwrapper.user_scripts:post_cpvirtualenv_source"
63+
64+
[project.entry-points."virtualenvwrapper.pre_rmvirtualenv"]
65+
user_scripts = "virtualenvwrapper.user_scripts:pre_rmvirtualenv"
66+
67+
[project.entry-points."virtualenvwrapper.post_rmvirtualenv"]
68+
user_scripts = "virtualenvwrapper.user_scripts:post_rmvirtualenv"
69+
70+
[project.entry-points."virtualenvwrapper.project.pre_mkproject"]
71+
project = "virtualenvwrapper.project:pre_mkproject"
72+
73+
[project.entry-points."virtualenvwrapper.project.post_mkproject_source"]
74+
project = "virtualenvwrapper.project:post_mkproject_source"
75+
76+
[project.entry-points."virtualenvwrapper.pre_activate"]
77+
user_scripts = "virtualenvwrapper.user_scripts:pre_activate"
78+
79+
[project.entry-points."virtualenvwrapper.post_activate_source"]
80+
project = "virtualenvwrapper.project:post_activate_source"
81+
user_scripts = "virtualenvwrapper.user_scripts:post_activate_source"
82+
83+
[project.entry-points."virtualenvwrapper.pre_deactivate_source"]
84+
user_scripts = "virtualenvwrapper.user_scripts:pre_deactivate_source"
85+
86+
[project.entry-points."virtualenvwrapper.post_deactivate_source"]
87+
user_scripts = "virtualenvwrapper.user_scripts:post_deactivate_source"
88+
89+
[project.entry-points."virtualenvwrapper.get_env_details"]
90+
user_scripts = "virtualenvwrapper.user_scripts:get_env_details"

requirements.txt

-3
This file was deleted.

setup.cfg

-79
This file was deleted.

setup.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
from setuptools import setup
44

55
setup(
6-
setup_requires=['pbr'],
7-
pbr=True,
6+
# Listing the scripts in pyproject.toml requires them to be python
7+
# entry points for console scripts, but they are shell scripts.
8+
scripts=[
9+
"virtualenvwrapper.sh",
10+
"virtualenvwrapper_lazy.sh",
11+
],
812
)

tox.ini

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
envlist = py,zsh,style
33

44
[testenv]
5-
install_command = pip install -U {opts} {packages}
65
commands = bash ./tests/run_tests {envdir} []
7-
deps = -rrequirements.txt
86
pass_env =
97
HOME
108
USER
@@ -33,18 +31,17 @@ commands = zsh -o shwordsplit ./tests/run_tests {envdir} []
3331

3432
[testenv:docs]
3533
deps =
36-
-r{toxinidir}/requirements.txt
3734
-r{toxinidir}/docs/requirements.txt
3835
commands =
3936
sphinx-build -W -j auto -b html -d docs/build/doctrees docs/source docs/build/html
4037
sphinx-build -W -j auto -b linkcheck -d docs/build/doctrees docs/source docs/build/linkcheck
4138

4239
[testenv:pkglint]
4340
deps=
44-
pbr
41+
build
4542
twine
4643
check-python-versions
4744
commands=
48-
python setup.py sdist
45+
python -m build
4946
twine check dist/*.tar.gz
50-
check-python-versions --only setup.py,setup.cfg,.github/workflows/test.yml
47+
check-python-versions --only pyproject.toml,.github/workflows/test.yml

0 commit comments

Comments
 (0)