diff --git a/README.rst b/README.rst index 62fd3d9..5a34c17 100644 --- a/README.rst +++ b/README.rst @@ -66,8 +66,9 @@ pypi-server -h will print a detailed usage message:: -i INTERFACE, --interface INTERFACE listen on interface INTERFACE (default: 0.0.0.0, any interface) - -r PACKAGES_DIRECTORY, --root PACKAGES_DIRECTORY - [deprecated] serve packages from PACKAGES_DIRECTORY + --disable-fallback + disable redirect to real PyPI index for packages not found in the + local index --server METHOD use METHOD to run the server. Valid values include paste, @@ -75,6 +76,9 @@ pypi-server -h will print a detailed usage message:: default is to use "auto" which chooses one of paste, cherrypy, twisted or wsgiref. + -r PACKAGES_DIRECTORY, --root PACKAGES_DIRECTORY + [deprecated] serve packages from PACKAGES_DIRECTORY + pypi-server -h pypi-server --help show this help message diff --git a/pypiserver/core.py b/pypiserver/core.py index ec1fdb2..9fc633a 100755 --- a/pypiserver/core.py +++ b/pypiserver/core.py @@ -16,6 +16,13 @@ mimetypes.add_type("application/octet-stream", ".egg") packages = None +class configuration(object): + def __init__(self): + self.fallback_url = "http://pypi.python.org/simple" + self.redirect_to_fallback = True + +config = configuration() + def guess_pkgname(path): pkgname = re.split(r"-\d+\.", os.path.basename(path))[0] @@ -104,6 +111,8 @@ def simple_redirect(prefix): @route("/simple/:prefix/") def simple(prefix=""): files = packages.find_packages(prefix) + if not files and config.redirect_to_fallback: + return redirect("%s/%s/" % (config.fallback_url.rstrip("/"), prefix)) files.sort() res = ["