source: trunk/setup.py

Last change on this file was 9ca17d78, checked in by Itamar Turner-Trauring <itamar@…>, at 2021-01-13T15:21:06Z

Add some overall timeout, and timeout on specific test that seems to be the
issue somehow.

  • Property mode set to 100644
File size: 16.1 KB
Line 
1#! /usr/bin/env python
2# -*- coding: utf-8 -*-
3import sys
4
5# Tahoe-LAFS -- secure, distributed storage grid
6#
7# Copyright © 2006-2012 The Tahoe-LAFS Software Foundation
8#
9# This file is part of Tahoe-LAFS.
10#
11# See the docs/about.rst file for licensing information.
12
13import os, subprocess, re
14
15basedir = os.path.dirname(os.path.abspath(__file__))
16
17# locate our version number
18
19def read_version_py(infname):
20    try:
21        verstrline = open(infname, "rt").read()
22    except EnvironmentError:
23        return None
24    else:
25        VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
26        mo = re.search(VSRE, verstrline, re.M)
27        if mo:
28            return mo.group(1)
29
30VERSION_PY_FILENAME = 'src/allmydata/_version.py'
31version = read_version_py(VERSION_PY_FILENAME)
32
33install_requires = [
34    # we don't need much out of setuptools but the version checking stuff
35    # needs pkg_resources and PEP 440 version specifiers.
36    "setuptools >= 28.8.0",
37
38    "zfec >= 1.1.0",
39
40    # zope.interface >= 3.6.0 is required for Twisted >= 12.1.0.
41    "zope.interface >= 3.6.0",
42
43    # * foolscap < 0.5.1 had a performance bug which spent O(N**2) CPU for
44    #   transferring large mutable files of size N.
45    # * foolscap < 0.6 is incompatible with Twisted 10.2.0.
46    # * foolscap 0.6.1 quiets a DeprecationWarning.
47    # * foolscap < 0.6.3 is incompatible with Twisted 11.1.0 and newer.
48    # * foolscap 0.8.0 generates 2048-bit RSA-with-SHA-256 signatures,
49    #   rather than 1024-bit RSA-with-MD5. This also allows us to work
50    #   with a FIPS build of OpenSSL.
51    # * foolscap >= 0.12.3 provides tcp/tor/i2p connection handlers we need,
52    #   and allocate_tcp_port
53    # * foolscap >= 0.12.5 has ConnectionInfo and ReconnectionInfo
54    # * foolscap >= 0.12.6 has an i2p.sam_endpoint() that takes kwargs
55    # * foolscap 0.13.2 drops i2p support completely
56    # * foolscap >= 20.4 is necessary for Python 3
57    "foolscap == 0.13.1 ; python_version < '3.0'",
58    "foolscap >= 20.4.0 ; python_version > '3.0'",
59
60    # * cryptography 2.6 introduced some ed25519 APIs we rely on.  Note that
61    #   Twisted[conch] also depends on cryptography and Twisted[tls]
62    #   transitively depends on cryptography.  So it's anyone's guess what
63    #   version of cryptography will *really* be installed.
64    "cryptography >= 2.6",
65
66    # * The SFTP frontend depends on Twisted 11.0.0 to fix the SSH server
67    #   rekeying bug <https://twistedmatrix.com/trac/ticket/4395>
68    # * The SFTP frontend and manhole depend on the conch extra. However, we
69    #   can't explicitly declare that without an undesirable dependency on gmpy,
70    #   as explained in ticket #2740.
71    # * Due to a setuptools bug, we need to declare a dependency on the tls
72    #   extra even though we only depend on it via foolscap.
73    # * Twisted >= 15.1.0 is the first version that provided the [tls] extra.
74    # * Twisted-16.1.0 fixes https://twistedmatrix.com/trac/ticket/8223,
75    #   which otherwise causes test_system to fail (DirtyReactorError, due to
76    #   leftover timers)
77    # * Twisted-16.4.0 introduces `python -m twisted.trial` which is needed
78    #   for coverage testing
79    # * Twisted 16.6.0 drops the undesirable gmpy dependency from the conch
80    #   extra, letting us use that extra instead of trying to duplicate its
81    #   dependencies here.  Twisted[conch] >18.7 introduces a dependency on
82    #   bcrypt.  It is nice to avoid that if the user ends up with an older
83    #   version of Twisted.  That's hard to express except by using the extra.
84    #
85    # * Twisted 18.4.0 adds `client` and `host` attributes to `Request` in the
86    # * initializer, needed by logic in our custom `Request` subclass.
87    #
88    #   In a perfect world, Twisted[conch] would be a dependency of an "sftp"
89    #   extra.  However, pip fails to resolve the dependencies all
90    #   dependencies when asked for Twisted[tls] *and* Twisted[conch].
91    #   Specifically, "Twisted[conch]" (as the later requirement) is ignored.
92    #   If there were an Tahoe-LAFS sftp extra that dependended on
93    #   Twisted[conch] and install_requires only included Twisted[tls] then
94    #   `pip install tahoe-lafs[sftp]` would not install requirements
95    #   specified by Twisted[conch].  Since this would be the *whole point* of
96    #   an sftp extra in Tahoe-LAFS, there is no point in having one.
97    # * Twisted 19.10 introduces Site.getContentFile which we use to get
98    #   temporary upload files placed into a per-node temporary directory.
99    "Twisted[tls,conch] >= 19.10.0",
100
101    "PyYAML >= 3.11",
102
103    "six >= 1.10.0",
104
105    # for 'tahoe invite' and 'tahoe join'
106    "magic-wormhole >= 0.10.2",
107
108    # Eliot is contemplating dropping Python 2 support.  Stick to a version we
109    # know works on Python 2.7.
110    "eliot ~= 1.7 ; python_version < '3.0'",
111    # On Python 3, we want a new enough version to support custom JSON encoders.
112    "eliot >= 1.13.0 ; python_version > '3.0'",
113
114    # Pyrsistent 0.17.0 (which we use by way of Eliot) has dropped
115    # Python 2 entirely; stick to the version known to work for us.
116    # XXX: drop this bound: https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3404
117    "pyrsistent < 0.17.0",
118
119    # A great way to define types of values.
120    # XXX: drop the upper bound: https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3390
121    "attrs >= 18.2.0, < 20",
122
123    # WebSocket library for twisted and asyncio
124    "autobahn >= 19.5.2",
125
126    # Support for Python 3 transition
127    "future >= 0.18.2",
128
129    # Discover local network configuration
130    "netifaces",
131
132    # Utility code:
133    "pyutil >= 3.3.0",
134
135    # Linux distribution detection:
136    "distro >= 1.4.0",
137
138    # Backported configparser for Python 2:
139    "configparser ; python_version < '3.0'",
140]
141
142setup_requires = [
143    'setuptools >= 28.8.0',  # for PEP-440 style versions
144]
145
146tor_requires = [
147    # This is exactly what `foolscap[tor]` means but pip resolves the pair of
148    # dependencies "foolscap[i2p] foolscap[tor]" to "foolscap[i2p]" so we lose
149    # this if we don't declare it ourselves!
150    "txtorcon >= 0.17.0",
151]
152
153i2p_requires = [
154    # txi2p has Python 3 support, but it's unreleased: https://github.com/str4d/txi2p/issues/10.
155    # URL lookups are in PEP-508 (via https://stackoverflow.com/a/54794506).
156    # Also see the comment in tor_requires.
157    "txi2p @ git+https://github.com/str4d/txi2p@0611b9a86172cb70d2f5e415a88eee9f230590b3#egg=txi2p",
158]
159
160if len(sys.argv) > 1 and sys.argv[1] == '--fakedependency':
161    del sys.argv[1]
162    install_requires += ["fakedependency >= 1.0.0"]
163
164from setuptools import find_packages, setup
165from setuptools import Command
166from setuptools.command import install
167
168
169trove_classifiers=[
170    "Development Status :: 5 - Production/Stable",
171    "Environment :: Console",
172    "Environment :: Web Environment",
173    "License :: OSI Approved :: GNU General Public License (GPL)",
174    "License :: DFSG approved",
175    "License :: Other/Proprietary License",
176    "Intended Audience :: Developers",
177    "Intended Audience :: End Users/Desktop",
178    "Intended Audience :: System Administrators",
179    "Operating System :: Microsoft",
180    "Operating System :: Microsoft :: Windows",
181    "Operating System :: Unix",
182    "Operating System :: POSIX :: Linux",
183    "Operating System :: POSIX",
184    "Operating System :: MacOS :: MacOS X",
185    "Operating System :: OS Independent",
186    "Natural Language :: English",
187    "Programming Language :: C",
188    "Programming Language :: Python",
189    "Programming Language :: Python :: 2",
190    "Programming Language :: Python :: 2.7",
191    "Topic :: Utilities",
192    "Topic :: System :: Systems Administration",
193    "Topic :: System :: Filesystems",
194    "Topic :: System :: Distributed Computing",
195    "Topic :: Software Development :: Libraries",
196    "Topic :: System :: Archiving :: Backup",
197    "Topic :: System :: Archiving :: Mirroring",
198    "Topic :: System :: Archiving",
199    ]
200
201
202GIT_VERSION_BODY = '''
203# This _version.py is generated from git metadata by the tahoe setup.py.
204
205__pkgname__ = "%(pkgname)s"
206real_version = "%(version)s"
207full_version = "%(full)s"
208branch = "%(branch)s"
209verstr = "%(normalized)s"
210__version__ = verstr
211'''
212
213def run_command(args, cwd=None):
214    use_shell = sys.platform == "win32"
215    try:
216        p = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=cwd, shell=use_shell)
217    except EnvironmentError as e:  # if this gives a SyntaxError, note that Tahoe-LAFS requires Python 2.7+
218        print("Warning: unable to run %r." % (" ".join(args),))
219        print(e)
220        return None
221    stdout = p.communicate()[0].strip()
222    if p.returncode != 0:
223        print("Warning: %r returned error code %r." % (" ".join(args), p.returncode))
224        return None
225    return stdout
226
227
228def versions_from_git(tag_prefix):
229    # This runs 'git' from the directory that contains this file. That either
230    # means someone ran a setup.py command (and this code is in
231    # versioneer.py, thus the containing directory is the root of the source
232    # tree), or someone ran a project-specific entry point (and this code is
233    # in _version.py, thus the containing directory is somewhere deeper in
234    # the source tree). This only gets called if the git-archive 'subst'
235    # variables were *not* expanded, and _version.py hasn't already been
236    # rewritten with a short version string, meaning we're inside a checked
237    # out source tree.
238
239    # versions_from_git (as copied from python-versioneer) returns strings
240    # like "1.9.0-25-gb73aba9-dirty", which means we're in a tree with
241    # uncommited changes (-dirty), the latest checkin is revision b73aba9,
242    # the most recent tag was 1.9.0, and b73aba9 has 25 commits that weren't
243    # in 1.9.0 . The narrow-minded NormalizedVersion parser that takes our
244    # output (meant to enable sorting of version strings) refuses most of
245    # that. Tahoe uses a function named suggest_normalized_version() that can
246    # handle "1.9.0.post25", so dumb down our output to match.
247
248    try:
249        source_dir = os.path.dirname(os.path.abspath(__file__))
250    except NameError as e:
251        # some py2exe/bbfreeze/non-CPython implementations don't do __file__
252        print("Warning: unable to find version because we could not obtain the source directory.")
253        print(e)
254        return {}
255    stdout = run_command(["git", "describe", "--tags", "--dirty", "--always"],
256                         cwd=source_dir)
257    if stdout is None:
258        # run_command already complained.
259        return {}
260    stdout = stdout.decode("ascii")
261    if not stdout.startswith(tag_prefix):
262        print("Warning: tag %r doesn't start with prefix %r." % (stdout, tag_prefix))
263        return {}
264    version = stdout[len(tag_prefix):]
265    pieces = version.split("-")
266    if len(pieces) == 1:
267        normalized_version = pieces[0]
268    else:
269        normalized_version = "%s.post%s" % (pieces[0], pieces[1])
270
271    stdout = run_command(["git", "rev-parse", "HEAD"], cwd=source_dir)
272    if stdout is None:
273        # run_command already complained.
274        return {}
275    full = stdout.decode("ascii").strip()
276    if version.endswith("-dirty"):
277        full += "-dirty"
278        normalized_version += ".dev0"
279
280    # Thanks to Jistanidiot at <http://stackoverflow.com/questions/6245570/get-current-branch-name>.
281    stdout = run_command(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=source_dir)
282    branch = (stdout or b"unknown").decode("ascii").strip()
283
284    # this returns native strings (bytes on py2, unicode on py3)
285    return {"version": version, "normalized": normalized_version,
286            "full": full, "branch": branch}
287
288# setup.cfg has an [aliases] section which runs "update_version" before many
289# commands (like "build" and "sdist") that need to know our package version
290# ahead of time. If you add different commands (or if we forgot some), you
291# may need to add it to setup.cfg and configure it to run update_version
292# before your command.
293
294class UpdateVersion(Command):
295    description = "update _version.py from revision-control metadata"
296    user_options = install.install.user_options
297
298    def initialize_options(self):
299        pass
300    def finalize_options(self):
301        pass
302    def run(self):
303        global version
304        verstr = version
305        if os.path.isdir(os.path.join(basedir, ".git")):
306            verstr = self.try_from_git()
307
308        if verstr:
309            self.distribution.metadata.version = verstr
310        else:
311            print("""\
312********************************************************************
313Warning: no version information found. This may cause tests to fail.
314********************************************************************
315""")
316
317    def try_from_git(self):
318        # If we change the release tag names, we must change this too
319        versions = versions_from_git("tahoe-lafs-")
320
321        # setup.py might be run by either py2 or py3 (when run by tox, which
322        # uses py3 on modern debian/ubuntu distros). We want this generated
323        # file to contain native strings on both (str=bytes in py2,
324        # str=unicode in py3)
325        if versions:
326            body = GIT_VERSION_BODY % {
327                "pkgname": self.distribution.get_name(),
328                "version": versions["version"],
329                "normalized": versions["normalized"],
330                "full": versions["full"],
331                "branch": versions["branch"],
332                }
333            f = open(VERSION_PY_FILENAME, "wb")
334            f.write(body.encode("ascii"))
335            f.close()
336            print("Wrote normalized version %r into '%s'" % (versions["normalized"], VERSION_PY_FILENAME))
337
338        return versions.get("normalized", None)
339
340class PleaseUseTox(Command):
341    user_options = []
342    def initialize_options(self):
343        pass
344    def finalize_options(self):
345        pass
346
347    def run(self):
348        print("ERROR: Please use 'tox' to run the test suite.")
349        sys.exit(1)
350
351setup_args = {}
352if version:
353    setup_args["version"] = version
354
355setup(name="tahoe-lafs", # also set in __init__.py
356      description='secure, decentralized, fault-tolerant file store',
357      long_description=open('README.rst', 'rU').read(),
358      author='the Tahoe-LAFS project',
359      author_email='tahoe-dev@tahoe-lafs.org',
360      url='https://tahoe-lafs.org/',
361      license='GNU GPL', # see README.rst -- there is an alternative licence
362      cmdclass={"update_version": UpdateVersion,
363                "test": PleaseUseTox,
364                },
365      package_dir = {'':'src'},
366      packages=find_packages('src') + ['allmydata.test.plugins'],
367      classifiers=trove_classifiers,
368      # We support Python 2.7, and we're working on support for 3.6 (the
369      # highest version that PyPy currently supports).
370      python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*",
371      install_requires=install_requires,
372      extras_require={
373          # Duplicate the Twisted pywin32 dependency here.  See
374          # https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2392 for some
375          # discussion.
376          ':sys_platform=="win32"': ["pywin32 != 226"],
377          "test": [
378              "flake8",
379              # Pin a specific pyflakes so we don't have different folks
380              # disagreeing on what is or is not a lint issue.  We can bump
381              # this version from time to time, but we will do it
382              # intentionally.
383              "pyflakes == 2.2.0",
384              "coverage ~= 5.0",
385              "mock",
386              "tox",
387              "pytest",
388              "pytest-twisted",
389              "hypothesis >= 3.6.1",
390              "treq",
391              "towncrier",
392              "testtools",
393              "fixtures",
394              "beautifulsoup4",
395              "html5lib",
396              "junitxml",
397              "tenacity",
398              "paramiko",
399              "pytest-timeout",
400          ] + tor_requires + i2p_requires,
401          "tor": tor_requires,
402          "i2p": i2p_requires,
403      },
404      package_data={"allmydata.web": ["*.xhtml",
405                                      "static/*.js", "static/*.png", "static/*.css",
406                                      "static/img/*.png",
407                                      "static/css/*.css",
408                                      ],
409                    "allmydata": ["ported-modules.txt"],
410                    },
411      include_package_data=True,
412      setup_requires=setup_requires,
413      entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] },
414      **setup_args
415      )
Note: See TracBrowser for help on using the repository browser.