From 2d4bb1c2b4cb158534fab2450bc2ba3d9d893543 Mon Sep 17 00:00:00 2001 From: Matthew Pontefract Date: Fri, 28 Sep 2012 16:00:21 +0100 Subject: [PATCH 1/7] added detail to README that will help new users setup the repository --- README.rst | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index e68452f..7d92f49 100644 --- a/README.rst +++ b/README.rst @@ -46,6 +46,76 @@ Then add an include in your url config for ``djangopypi.urls``:: This will make the repository interface be accessible at ``/pypi/``. +Package upload directory +^^^^^^^^^^^^^^^^^^^^^^^^ + +By default packages are uploaded to ``/dists`` so you need both +to ensure that ``MEDIA_ROOT`` is assigned a value and that the +``/dists`` directory is created and writable by the web server. + +You may change the directory to which packages are uploaded by setting +``DJANGOPYPI_RELEASE_UPLOAD_TO``; this will be a sub-directory of ``MEDIA_ROOT``. + + +Other settings +^^^^^^^^^^^^^^ + +Look in the ``djangopy`` source code for ``settings.py`` to see other +settings you can override. + + +Data initialisation +^^^^^^^^^^^^^^^^^^^ + +Load the classifier database with the management command:: + + $ python manage.py loadclassifiers + + +Package download handler +^^^^^^^^^^^^^^^^^^^^^^^^ + +Packages are downloaded from the following URL: +``/simple//dists/-.tar.gz#`` + +You will need to configure either your development server to deliver the +package from the upload directory, or your web server (e.g. NGINX or Apache). + +To configure your Django development server ensure that ``urls.py`` looks +something like following:: + + import os + from django.conf.urls import patterns, include, url + from django.conf import settings + + # ... other code here including Django admin auto-discover ... + + urlpatterns = patterns('', + # ... url patterns... + + url(r'^simple/[\w\d_\.\-]+/dists/(?P.*)$', 'django.views.static.serve', + {'document_root': os.path.join(settings.MEDIA_ROOT, + settings.DJANGOPYPI_RELEASE_UPLOAD_TO)}), + url(r'', include("djangopypi.urls")), + + # .. url patterns... + ) + +This should only be used for the Django development server. + +When using a web server, configure that to deliver packages from the +upload dist directory directly from this URL. For example, you may have +a clause in an NGINX configuration file something like the following:: + + server { + ... configuration... + + location ~ ^/simple/[a-zA-Z0-9\,\-\.]+/dists/ { + alias /path/to/upload/dists/; + } + + ... configuration... + } Uploading to your PyPI ---------------------- @@ -92,4 +162,12 @@ To push the package to the local pypi:: $ python setup.py mregister -r local sdist mupload -r local .. [#] ``djangopypi`` is South enabled, if you are using South then you will need - to run the South ``migrate`` command to get the tables. \ No newline at end of file + to run the South ``migrate`` command to get the tables. + +Installing a package with pip +----------------------------- + +To install your package with pip:: + + $ pip install -i http://my.pypiserver.com/simple/ + From c95efc326d3268b85551c5c00e91ef19bd7f78a4 Mon Sep 17 00:00:00 2001 From: Matthew Pontefract Date: Fri, 28 Sep 2012 17:02:58 +0200 Subject: [PATCH 2/7] Update README.rst fixed sub-sub heading underlines which broke GitHub rendering --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 7d92f49..5be0fa3 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,7 @@ This will make the repository interface be accessible at ``/pypi/``. Package upload directory -^^^^^^^^^^^^^^^^^^^^^^^^ +++++++++++++++++++++++++ By default packages are uploaded to ``/dists`` so you need both to ensure that ``MEDIA_ROOT`` is assigned a value and that the @@ -58,14 +58,14 @@ You may change the directory to which packages are uploaded by setting Other settings -^^^^^^^^^^^^^^ +++++++++++++++ Look in the ``djangopy`` source code for ``settings.py`` to see other settings you can override. Data initialisation -^^^^^^^^^^^^^^^^^^^ ++++++++++++++++++++ Load the classifier database with the management command:: @@ -73,7 +73,7 @@ Load the classifier database with the management command:: Package download handler -^^^^^^^^^^^^^^^^^^^^^^^^ +++++++++++++++++++++++++ Packages are downloaded from the following URL: ``/simple//dists/-.tar.gz#`` From 37bb6b61b4f61f626545a9bb16dae8141cb8daed Mon Sep 17 00:00:00 2001 From: Matthew Pontefract Date: Fri, 28 Sep 2012 23:11:30 +0100 Subject: [PATCH 3/7] added clause to README detailing managing fall-back repositories with pip --- README.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.rst b/README.rst index 7d92f49..6239697 100644 --- a/README.rst +++ b/README.rst @@ -171,3 +171,15 @@ To install your package with pip:: $ pip install -i http://my.pypiserver.com/simple/ +If you want to fall back to PyPi or another repository in the event the +package is not on your new server, or if you are installing a number +of packages, some on your private server and some on another, you can use:: + + $ pip install -i http://localhost:8000/simple/ \ + --extra-index-url=http://pypi.python.org/simple/ + +(substitute your djangopypi server URL for the ``localhost`` one in this example) + +The downside is that each install of a package hosted on the repository in +``--extra-index-url`` will start with a call to the first repository which +will fail before pip falls back to the alternative. From 2e45c35e9f268f59353376f4254aea9f4941bb66 Mon Sep 17 00:00:00 2001 From: Matthew Pontefract Date: Fri, 28 Sep 2012 23:14:14 +0100 Subject: [PATCH 4/7] corrected pip command with multiple repos --- README.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 2b39735..6e3d380 100644 --- a/README.rst +++ b/README.rst @@ -172,11 +172,13 @@ To install your package with pip:: $ pip install -i http://my.pypiserver.com/simple/ If you want to fall back to PyPi or another repository in the event the -package is not on your new server, or if you are installing a number -of packages, some on your private server and some on another, you can use:: +package is not on your new server, or in particular if you are installing a number +of packages, some on your private server and some on another, you can use +pip in the following manner:: $ pip install -i http://localhost:8000/simple/ \ - --extra-index-url=http://pypi.python.org/simple/ + --extra-index-url=http://pypi.python.org/simple/ \ + -r requirements.txt (substitute your djangopypi server URL for the ``localhost`` one in this example) From c5940990be4cfc3359da833913c57a67cdb1b454 Mon Sep 17 00:00:00 2001 From: Matthew Pontefract Date: Sat, 29 Sep 2012 10:52:53 +0200 Subject: [PATCH 5/7] Update README.rst Minor correction picked up by reviewer. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6e3d380..6508356 100644 --- a/README.rst +++ b/README.rst @@ -60,7 +60,7 @@ You may change the directory to which packages are uploaded by setting Other settings ++++++++++++++ -Look in the ``djangopy`` source code for ``settings.py`` to see other +Look in the ``djangopypi`` source code for ``settings.py`` to see other settings you can override. From 7c4ac440fd27f20b7fcd61f62112b2c5fb353140 Mon Sep 17 00:00:00 2001 From: Matthew Pontefract Date: Sat, 29 Sep 2012 19:31:17 +0100 Subject: [PATCH 6/7] instructions for proxying to upstream index added to README --- README.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6508356..0340f2e 100644 --- a/README.rst +++ b/README.rst @@ -176,7 +176,7 @@ package is not on your new server, or in particular if you are installing a numb of packages, some on your private server and some on another, you can use pip in the following manner:: - $ pip install -i http://localhost:8000/simple/ \ + $ pip install -i http://my.pypiserver.com/simple/ \ --extra-index-url=http://pypi.python.org/simple/ \ -r requirements.txt @@ -185,3 +185,18 @@ pip in the following manner:: The downside is that each install of a package hosted on the repository in ``--extra-index-url`` will start with a call to the first repository which will fail before pip falls back to the alternative. + +Transparent proxy to an upstream PyPi repository +++++++++++++++++++++++++++++++++++++++++++++++++ + +The above method works well, but you can also let djangopypi do the hard work +and redirect to an upstream index if the requested package is not found +locally. By default this is disabled. To enable proxying to the default +upstream repository ``http://pypi.python.org`` the following must be set in +``settings.py``:: + + DJANGOPYPI_PROXY_MISSING = True + +If you'd like to fall-back to some other repository, also add:: + + DJANGOPYPI_PROXY_BASE_URL = 'http://my.pypirepository.org' From a7327492418611a9435185aeeda4e562ac70cd7a Mon Sep 17 00:00:00 2001 From: Matthew Pontefract Date: Sat, 29 Sep 2012 20:34:56 +0200 Subject: [PATCH 7/7] Update README.rst corrected rst formatting; moved footnote to foot. --- README.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 0340f2e..1eb28ab 100644 --- a/README.rst +++ b/README.rst @@ -161,9 +161,6 @@ To push the package to the local pypi:: $ python setup.py mregister -r local sdist mupload -r local -.. [#] ``djangopypi`` is South enabled, if you are using South then you will need - to run the South ``migrate`` command to get the tables. - Installing a package with pip ----------------------------- @@ -187,7 +184,7 @@ The downside is that each install of a package hosted on the repository in will fail before pip falls back to the alternative. Transparent proxy to an upstream PyPi repository -++++++++++++++++++++++++++++++++++++++++++++++++ +________________________________________________ The above method works well, but you can also let djangopypi do the hard work and redirect to an upstream index if the requested package is not found @@ -199,4 +196,7 @@ upstream repository ``http://pypi.python.org`` the following must be set in If you'd like to fall-back to some other repository, also add:: - DJANGOPYPI_PROXY_BASE_URL = 'http://my.pypirepository.org' + DJANGOPYPI_PROXY_BASE_URL = 'http://my.alternativepypi.com' + +.. [#] ``djangopypi`` is South enabled, if you are using South then you will need + to run the South ``migrate`` command to get the tables. \ No newline at end of file