Skip to content

Instantly share code, notes, and snippets.

@fschulze
Last active March 3, 2023 22:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fschulze/077320ab51f8ae91381d5e7faa0ac647 to your computer and use it in GitHub Desktop.
Save fschulze/077320ab51f8ae91381d5e7faa0ac647 to your computer and use it in GitHub Desktop.
from devpi_common.url import URL
from devpi_server.readonly import get_mutable_deepcopy
from pluggy import HookimplMarker
from pyramid.view import view_config
devpiserver_hookimpl = HookimplMarker("devpiserver")
@devpiserver_hookimpl
def devpiserver_pyramid_configure(config, pyramid_config):
# by using include, the package name doesn't need to be set explicitly
# for registrations of static views etc
pyramid_config.include('devpi_json_info')
def includeme(config):
config.add_route(
"json_info",
"/{user}/{index}/{project}/json")
config.scan()
@view_config(
route_name="json_info",
accept="application/json",
request_method="GET",
renderer='json')
def json_info_view(context, request):
baseurl = URL(request.application_url).asdir()
version = context.stage.get_latest_version(context.project, stable=True)
info = get_mutable_deepcopy(
context.stage.get_versiondata(context.project, version))
info.pop('+elinks', None)
result = dict(info=info, releases={})
for release in context.stage.get_releaselinks(context.project):
result['releases'].setdefault(release.version, []).append(dict(
url=baseurl.joinpath(release.relpath).url))
return result
MIT License
Copyright (c) 2020 Florian Schulze
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
from setuptools import setup
setup(
name="devpi-json-info",
license="MIT",
entry_points={
'devpi_server': [
"devpi-json-info = devpi_json_info"]},
install_requires=[
'devpi-server'],
py_modules=['devpi_json_info'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment