Merge lp:~cjwatson/loggerhead/modernize-setup into lp:loggerhead

Proposed by Colin Watson
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 529
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~cjwatson/loggerhead/modernize-setup
Merge into: lp:loggerhead
Prerequisite: lp:~cjwatson/loggerhead/chameleon
Diff against target: 266 lines (+111/-69)
7 files modified
NEWS (+7/-0)
__init__.py (+11/-1)
docs/conf.py (+3/-3)
docs/index.rst (+11/-7)
loggerhead/__init__.py (+12/-15)
setup.cfg (+66/-0)
setup.py (+1/-43)
To merge this branch: bzr merge lp:~cjwatson/loggerhead/modernize-setup
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+428047@code.launchpad.net

Commit message

Modernize packaging.

Description of the change

There are new dependencies on `importlib_metadata` (for Python < 3.8) and `packaging`, in order to avoid a self-import in `setup.py`. People proxying Loggerhead through Apache should install the `loggerhead[proxied]` extra; people running it via FastCGI, SCGI, or AJP should install the `loggerhead[flup]` extra.

The version handling rearrangements make it possible to install Loggerhead using `pip`.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2022-08-08 17:28:36 +0000
3+++ NEWS 2022-08-08 17:28:36 +0000
4@@ -18,6 +18,13 @@
5
6 - Port from SimpleTAL to Chameleon. (Colin Watson)
7
8+ - Modernize packaging. There are new dependencies on
9+ ``importlib_metadata`` (for Python < 3.8) and ``packaging``, in order
10+ to avoid a self-import in ``setup.py``. People proxying Loggerhead
11+ through Apache should install the ``loggerhead[proxied]`` extra;
12+ people running it via FastCGI, SCGI, or AJP should install the
13+ ``loggerhead[flup]`` extra. (Colin Watson, #1831661)
14+
15 1.20.0 [18Jul2021]
16 ------------------
17
18
19=== modified file '__init__.py'
20--- __init__.py 2018-11-03 18:15:51 +0000
21+++ __init__.py 2022-08-08 17:28:36 +0000
22@@ -30,9 +30,19 @@
23 starts a web server to browse the contents of a branch.
24 """
25
26+try:
27+ import importlib.metadata as importlib_metadata
28+except ImportError:
29+ import importlib_metadata
30 import sys
31
32-version_info = (1, 20, 0) # Keep in sync with loggerhead/__init__.py
33+from packaging.version import Version
34+
35+try:
36+ version_info = Version(importlib_metadata.version("loggerhead")).release
37+except importlib_metadata.PackageNotFoundError:
38+ # Support running tests from the build tree without installation.
39+ version_info = None
40
41 import breezy
42 from breezy import commands
43
44=== modified file 'docs/conf.py'
45--- docs/conf.py 2010-03-25 10:25:13 +0000
46+++ docs/conf.py 2022-08-08 17:28:36 +0000
47@@ -11,7 +11,7 @@
48 # All configuration values have a default; values that are commented out
49 # serve to show the default.
50
51-import sys, os
52+from loggerhead import __version__
53
54 # If extensions (or modules to document with autodoc) are in another directory,
55 # add these directories to sys.path here. If the directory is relative to the
56@@ -45,9 +45,9 @@
57 # built documents.
58 #
59 # The short X.Y version.
60-version = '1.17'
61+version = __version__
62 # The full version, including alpha/beta/rc tags.
63-release = '1.17'
64+release = __version__
65
66 # The language for content autogenerated by Sphinx. Refer to documentation
67 # for a list of supported languages.
68
69=== modified file 'docs/index.rst'
70--- docs/index.rst 2022-08-08 17:28:36 +0000
71+++ docs/index.rst 2022-08-08 17:28:36 +0000
72@@ -17,7 +17,7 @@
73
74 - Paste for the server. (You need version 1.2 or newer of Paste).
75
76-- Paste Deploy (optional, needed when proxying through Apache).
77+- PasteDeploy (optional, needed when proxying through Apache).
78
79 - flup (optional, needed to use FastCGI, SCGI or AJP).
80
81@@ -32,15 +32,19 @@
82 $ sudo apt-get install python-pastedeploy
83 $ sudo apt-get install python-flup
84
85-Installing Dependencies Using :command:`easy_install`
86-#####################################################
87+Installing Dependencies Using :command:`pip`
88+############################################
89+
90+You should normally create and activate a virtual environment first.
91
92 .. code-block:: sh
93
94- $ easy_install Chameleon
95- $ easy_install Paste
96- $ easy_install PasteDeploy
97- $ easy_install flup
98+ # Basic installation only
99+ $ pip install loggerhead
100+ # Installation for proxying through Apache
101+ $ pip install 'loggerhead[proxied]'
102+ # Installation for FastCGI, SCGI or AJP
103+ $ pip install 'loggerhead[flup]'
104
105
106 Running the Standalone Loggerhead Server
107
108=== modified file 'loggerhead/__init__.py'
109--- loggerhead/__init__.py 2021-11-15 14:40:11 +0000
110+++ loggerhead/__init__.py 2022-08-08 17:28:36 +0000
111@@ -15,20 +15,17 @@
112 # along with this program; if not, write to the Free Software
113 # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
114
115-"""A simple container to turn this into a python package.
116-
117-We also check the versions of some dependencies.
118-"""
119-
120-import pkg_resources
121-
122-__version__ = '1.20.0' # Keep in sync with ../__init__.py.
123+"""A simple container to turn this into a python package."""
124+
125+try:
126+ import importlib.metadata as importlib_metadata
127+except ImportError:
128+ import importlib_metadata
129+
130+try:
131+ __version__ = importlib_metadata.version("loggerhead")
132+except importlib_metadata.PackageNotFoundError:
133+ # Support running tests from the build tree without installation.
134+ __version__ = None
135 __revision__ = None
136 required_breezy = (3, 1)
137-
138-pkg_resources.get_distribution('Paste>=1.6')
139-try:
140- pkg_resources.get_distribution('PasteDeploy>=1.3')
141-except pkg_resources.DistributionNotFound:
142- # No paste.deploy is OK, but an old paste.deploy is bad.
143- pass
144
145=== added file 'setup.cfg'
146--- setup.cfg 1970-01-01 00:00:00 +0000
147+++ setup.cfg 2022-08-08 17:28:36 +0000
148@@ -0,0 +1,66 @@
149+# Copyright (C) 2008-2022 Canonical Ltd.
150+#
151+# This program is free software; you can redistribute it and/or modify
152+# it under the terms of the GNU General Public License as published by
153+# the Free Software Foundation; either version 2 of the License, or
154+# (at your option) any later version.
155+#
156+# This program is distributed in the hope that it will be useful,
157+# but WITHOUT ANY WARRANTY; without even the implied warranty of
158+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
159+# GNU General Public License for more details.
160+#
161+# You should have received a copy of the GNU General Public License
162+# along with this program; if not, write to the Free Software
163+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
164+
165+[metadata]
166+name = loggerhead
167+version = 2.0.0.dev0
168+description = Loggerhead is a web viewer for projects in bazaar
169+long_description = file: README.rst
170+long_description_content_type = text/x-rst
171+license = GNU GPL v2 or later
172+maintainer = Michael Hudson
173+maintainer_email = michael.hudson@canonical.com
174+
175+[options]
176+scripts =
177+ loggerhead-serve
178+packages =
179+ breezy.plugins.loggerhead
180+ loggerhead
181+ loggerhead.apps
182+ loggerhead.controllers
183+ loggerhead.middleware
184+ loggerhead.templates
185+package_dir =
186+ breezy.plugins.loggerhead=.
187+install_requires =
188+ Chameleon
189+ Paste>=1.6
190+ bleach
191+ breezy>=3.1
192+ importlib-metadata; python_version < "3.8"
193+ packaging
194+
195+[options.data_files]
196+share/man/man1 =
197+ loggerhead-serve.1
198+share/doc/loggerhead =
199+ apache-loggerhead.conf
200+ breezy.conf
201+ loggerheadd
202+
203+[options.extras_require]
204+proxied =
205+ PasteDeploy>=1.3
206+flup =
207+ flup
208+
209+[options.package_data]
210+loggerhead =
211+ static/css/*.css
212+ static/images/*
213+ static/javascript/*.js
214+ templates/*.pt
215
216=== modified file 'setup.py'
217--- setup.py 2022-02-23 19:28:51 +0000
218+++ setup.py 2022-08-08 17:28:36 +0000
219@@ -20,46 +20,4 @@
220
221 from setuptools import setup
222
223-import loggerhead
224-
225-
226-with open("README.rst") as readme:
227- long_description = readme.read()
228-
229-
230-setup(
231- name="loggerhead",
232- version=loggerhead.__version__,
233- description="Loggerhead is a web viewer for projects in bazaar",
234- long_description=long_description,
235- long_description_content_type="text/x-rst",
236- license="GNU GPL v2 or later",
237- maintainer="Michael Hudson",
238- maintainer_email="michael.hudson@canonical.com",
239- scripts=[
240- "loggerhead-serve",
241- ],
242- packages=["loggerhead",
243- "loggerhead/apps",
244- "loggerhead/controllers",
245- "loggerhead/middleware",
246- "loggerhead/templates",
247- "breezy.plugins.loggerhead"],
248- package_dir={'breezy.plugins.loggerhead': '.'},
249- package_data={"loggerhead": ["templates/*.pt",
250- "static/css/*.css",
251- "static/javascript/*.js",
252- "static/images/*"]},
253- data_files=[
254- ('share/man/man1', ['loggerhead-serve.1']),
255- ('share/doc/loggerhead', ['apache-loggerhead.conf',
256- 'loggerheadd',
257- 'breezy.conf']),
258- ],
259- install_requires=[
260- 'paste',
261- 'bleach',
262- 'breezy>=3.1',
263- ],
264- testsuite='loggerhead.tests.test_suite',
265- )
266+setup()

Subscribers

People subscribed via source and target branches