Commit Graph

773 Commits

Author SHA1 Message Date
Dmitrii Orlov f2330fa95e
Merge branch 'master' into chore-adjust-contributors-entry-in-readme-rst 2022-02-21 09:21:01 +01:00
Dmitrii Orlov e608e8645f
Merge pull request #416 from dee-me-tree-or-love/fix-small-styling-fixes
fix(small-black-format-fixes): small styling fixes
2022-02-21 09:20:27 +01:00
Dmitrii Orlov 3b1a0f828d
Merge branch 'master' into fix-small-styling-fixes 2022-02-20 21:28:30 +01:00
Dmitrii Orlov 22d47a53db
Merge pull request #413 from domdfcoding/patch-1
Specify doctype for generated pages.
2022-02-20 21:27:49 +01:00
Dmitrii Orlov cd4bff5785
Merge pull request #414 from luismsgomes/master
Fixed violation of PEP 503 warning with pip>=22
2022-02-20 21:20:06 +01:00
Dmitrii Orlov a10cdcead3 Fix black errors on test_server.py 2022-02-20 21:17:20 +01:00
Dmitrii Orlov 049ae42b1a Fix black errors on backend.py 2022-02-20 21:16:51 +01:00
Dmitrii Orlov 050bc9e17c
Merge branch 'master' into chore-adjust-contributors-entry-in-readme-rst 2022-02-20 21:07:49 +01:00
Dmitrii Orlov ee912cf1d3 chore(new-people): adjust maintainers & add call for new people 2022-02-20 21:06:12 +01:00
Luís Gomes 64b4d21318 Fixed violation of PEP 503 warning with pip>=22
When using pip >=22, we get the following warning:

"DEPRECATION: The HTML index page being used (https://....) is not a proper
HTML 5 document. This is in violation of PEP 503 which requires these pages
to be well-formed HTML 5 documents. Please reach out to the owners of this
index page, and ask them to update this index page to a valid HTML 5
document. pip 22.2 will enforce this behaviour change. Discussion can be
found at https://github.com/pypa/pip/issues/10825"
2022-02-10 13:42:02 +00:00
Dominic Davis-Foster 057d3b469d
Specify doctype for generated pages.
This ensures compliance with PEP 503
2022-01-30 22:26:29 +00:00
Dmitrii Orlov bdbd839a1b
Merge pull request #407 from dee-me-tree-or-love/tp-temporarily-disable-cpython39-tests
Temporary disable tests for python3.9
2021-11-18 16:47:30 +01:00
Dmitrii Orlov 652a7171a6 disable tests for python3.9 2021-11-16 21:04:25 +01:00
Dmitrii Orlov d34c99269a
Merge pull request #400 from dee-me-tree-or-love/tp-fix-mypy-check-dependencies-for-CI 2021-10-01 07:11:50 +02:00
Dmitrii Orlov a1d7264e03 Include Black Formatter fix 2021-09-10 14:02:54 +02:00
Dmitrii Orlov 48688d7e4c
Merge branch 'master' into tp-fix-mypy-check-dependencies-for-CI 2021-09-02 13:18:40 +02:00
Dmitrii Orlov 2885ac2e6d
Merge pull request #401 from dee-me-tree-or-love/tp-allow-gh-actions-for-fork-pull-requests
Allow GH actions to run on pull requests for forks
2021-09-02 13:18:27 +02:00
Dmitrii Orlov be39eb2f05 Allow GH actions to run on pull requests for forks 2021-08-27 09:19:33 +02:00
Dmitrii Orlov a1002c5e99 Install requires stub types for mypy in ci.yml 2021-08-27 09:11:26 +02:00
Dmitrii Orlov 3713da9d66
Merge pull request #395 from awachtler/master
added JSON Topic for use with micropython-upip
2021-08-26 13:39:32 +02:00
awachtler 7693c03485 json_info/doc: fixed typo in README.rst
<
2021-08-15 07:28:22 +02:00
awachtler 4e189aec9c json_info/doc: fix formatting 2021-08-13 06:59:36 +02:00
awachtler fb81ab767a doc/json_info: added usage description with micropython. 2021-08-13 06:57:13 +02:00
awachtler e7bc2bb75d test_app.py/json_info: added tests for the json_info endpoint 2021-08-12 07:46:42 +02:00
awachtler c205355253 _app.py/json_info: improved error handling
- added redirect if package name is not normalized
- raise 404 error if package is not found
2021-08-12 07:43:57 +02:00
awachtler a9414fb964 renamed max_version to latest_version 2021-07-19 05:46:43 +02:00
awachtler 1ae9f20e3f rollback version info 2021-07-19 05:44:58 +02:00
awachtler d28fc966af rework json_info, made url generic, restructured code 2021-07-18 07:21:19 +02:00
awachtler 43958e4548 initial add json support 2021-07-16 12:23:05 +02:00
Dmitry Orlov 35fcdd0e06
Contributor documentation directory and README (#383)
* documentation directory setup

* basic README.md file as introduction

* fix typos...

Co-authored-by: Dmitrii Orlov <orlov@satelligence.com>
2021-04-15 10:16:08 -05:00
Bao Trinh 302b4a8a43
Correct README example (#380)
The readme incorrectly specifies `watchdog` as the name of the extra to install. It's actually specified as `cache`. see: df300de33d/setup.py (L49)
2021-03-04 09:08:16 -06:00
Matthew Planchard df300de33d
Push to Docker Hub from CI (#375)
Adds a new helper script to determine which docker tags are needed for a
given ref going through CI, and uses those tags to populate the GH
actions matrix for a docker deploy step.
2021-02-07 20:24:33 -06:00
Matthew Planchard 8306de15db
Gunicorn/gevent docker, log fixes, cache busting (#371)
Updates the Docker configuration to use the gunicorn server with gevent
workers by default. Adds `waitress` to the docker container, so that if
no server is specified, we will fall back to that rather than `wsgiref`.

Making this happen brought a few other issues to light, which are also
addressed here.

- Docker log output not immediately being flushed to stdout (#358):
  resolved by setting the `PYTHONUNBUFFERED` env var to `t` in the
  docker container
- When the WSGIRef server is selected, its access logs are written
  directly to stderr, rather than going through the logging machinery:
  resolved by adding a new `WsgiHandler` class and passing in to
  bottle's `run()` method when running the wsgi server. This required a
  new `ServerCheck` class to determine whether the wsgi server is
  selected when the `auto` option is used
- When using `gunicorn` along with the watchdog cache, package uplaods
  were not being picked up by the watcher. Updated the `add_package`
  and `remove_package` methods on the `CachingFileBackend` to bust the
  cache
2021-02-07 17:04:06 -06:00
Matthew Planchard d868005e1f
Docker improvements (#365)
* Docker improvements

This addresses much of what was brought up in #359. Specifically, it:

- Significantly improves testing for the Docker image, adding a
  `docker/test_docker.py` file using the regular pytest machinery to
  set up and run docker images for testing
- Hopefully addresses a variety of permissions issues, by being explicit
  about what access pypiserver needs and asking for it, only erroring
  if that access is not available
  - Requires RX permissions on `/data` (R to read files, X to list files
    and to be able to cd into the directory. This is important since
    `/data` is the `WORKDIR`)
  - Requires RWX permissions on `/data/packages`, so that we can list
    packages, write packages, and read packages.
  - When running in the default configuration (as root on Linux or
    as the pypiserver-named rootish user on Mac), with no volumes
    mounted, these requirements are all satisfied
  - Volume mounts still must be readable by the pypiserver user (UID
    9898) in order for the container to run. However, we now error early
    if this is not the case, and direct users to a useful issue.
  - If the container is run as a non-root, non-pypiserver user (e.g.
    because someone ran `docker run --user=<user_id>`, we try to run
    pypiserver as that user). Provided that user has access to the
    necessary directories, it should run fine.
- Fixes issues with running help and similar commands
- Updates the Docker image to use `PYPISERVER_PORT` for port
  specification, while still falling back to `PORT` for backwards
  compatibility
- Moves some docker-related things into a `/docker` directory
- Adds a `Makefile` for building a test fixture package sdist and wheel,
  so that test code can call `make mypkg` and not need to worry about it
  potentially building multiple times

The only issue #359 raises that's not addressed here is the one of
running pypiserver in the Docker container using some non-default server
for performance. I would like to do some benchmarking before deciding on
what to do there.
2021-02-06 11:28:15 -06:00
Matthew Planchard df7454ff20
Add aggregate "tests" job (#370)
Adds an aggregate "tests" job to CI so that we can gate merges on that
without needing to keep merge gates up-to-date with the names of the
various jobs that collectively represent "all tests".

Also dropped the `pull-request` trigger, which I included originally
because I wasn't sure whether the tests on push would run for forks,
which they do!
2021-02-02 20:36:41 -06:00
PelleK cf424c982d
Refactor storage operations into separate Backend classes (#348)
Following the discussion in #253 and #325 I've created a first iteration on what a `Backend` interface could look like and how the current file storage operations may be refactored into this interface. It goes from the following principles

* `app.py` talks only to `core.py` with regards to package operations
* at configuration time, a `Backend` implementation is chosen and created for the lifetime of the configured app
* `core.py` proxies requests for packages to this `Backend()`
* The `Backend` interface/api is defined through three things
  * methods that an implementation must implement
  * methods that an implementation may override if it knows better than the defaults
  * the `PkgFIle` class that is (should be) the main carrier of data
* where possible, implementation details must be hidden from concrete `Backend`s to promote extensibility

Other things I've done in this PR:
* I've tried to talk about packages and projects, rather than files and prefixes, since these are the domain terms PEP503 uses, and imho it's also more clear what it means
* Better testability of the `CacheManager` (no more race conditions when `watchdog` is installed during testing)
* Cleanup some more Python 2 code
* Started moving away from  `os.path` and `py.path` in favour of `pathlib`

Furthermore I've created a `plugin.py` with a sample of how I think plugin system could look like. This sampIe assumes we use `argparse`  and allows for the extension of cli arguments that a plugin may need. I think the actual implementation of such a plugin system is beyond the scope of this PR, but I've used it as a target for the Backend refactoring. If requested, I'll remove it from this PR.

The following things still need to be done / discussed. These can be part of this PR or moved into their own, separate PRs
- [ ] Simplify the `PgkFile` class. It currently consists of a number of attributes that don't necessarily belong with it, and not all attributes are aptly named (imho). I would like to minimalize the scope of `PkgFile` so that its only concern is being a data carrier between the app and the backends, and make its use more clear.
- [ ] Add a `PkgFile.metadata` that backend implementations may use to store custom data for packages. For example the current `PkgFile.root` attribute is an implementation detail of the filestorage backends, and other Backend implementations should not be bothered by it.
- [ ] Use `pathlib` wherever possible. This may also result in less attributes for `PkgFile`, since some things may be just contained in a single `Path` object, instead of multtiple strings.
- [ ] Improve testing of the `CacheManager`.

----
* move some functions around in preparation for backend module

* rename pkg_utils to pkg_helpers to prevent confusion with stdlib pkgutil

* further implement the current filestorage as simple file backend

* rename prefix to project, since that's more descriptive

* add digester func as attribute to pkgfile

* WIP caching backend

* WIP make cache better testable

* better testability of cache

* WIP file backends as plugin

* fix typos, run black

* Apply suggestions from code review

Co-authored-by: Matthew Planchard <mplanchard@users.noreply.github.com>

* add more type hints to pass mypy, fix tox.ini

* add package count method to backend

* add package count method to backend

* minor changes

* bugfix when checking invalid whl file

* check for existing package recursively, bugfix, some more pathlib

* fix unittest

* rm dead code

* exclude bottle.py from coverage

* fix merge mistakes

* fix tab indentation

* backend as a cli argument

* fix cli, add tests

* fix mypy

* fix more silly mistakes

* process feedback

* remove dead code

Co-authored-by: Matthew Planchard <mplanchard@users.noreply.github.com>
2021-02-02 11:44:29 -06:00
sangarshanan 7688e1b2bd
Fix silly typo in the readme :) (#362) 2020-11-19 19:22:58 -06:00
Matthew Planchard d0694d9e15
Switch to GH actions (#361)
* Switch to GH actions

Removes the travis config and adds a GH actions config. Resolves #360.

As part of this:

- only runs the README check once, instead of for each python version
- only runs mypy once, removing it from tox
- unifies the pypy and cpython tests in tox by separating dev and test
  requirements, and only installing the latter for running tests in tox

* Update README w/badge & link to GH actions tests
2020-11-15 20:08:58 -06:00
PelleK 4b1bd1c9db
Refactor test_server to increase speed (#354)
I gave test_server.py some much needed attention. This file now take ~30 seconds on my machine to run (down from 130 seconds), and I cleaned up the code a little. Let's see how this goes in CI

Commits:
-------------
* minimize time.sleep, convert to pathlib
* refactor, dry code
* run black

Co-authored-by: Matthew Planchard <mplanchard@users.noreply.github.com>
2020-11-15 15:57:53 -06:00
PelleK 4e1fd1eedc
Fix version incompatibility that breaks twine in docker test (#356)
* Fix version incompatibility that breaks twine in docker test

* upgrade pip before using feature flag
2020-11-15 15:08:57 -06:00
Matthew Planchard 15d81147ac
Add python 3.9 testing (#351)
* Add python 3.9 testing

* Add 3.9 proper

According to this, it's available now: https://travis-ci.community/t/python-3-9-0-build/10091/18
2020-10-28 07:11:06 -05:00
Matthew Planchard c668b1814a
Use argparse config throughout app (#349)
This PR is a pretty substantial refactor of the entrypoints of pypiserver (`__main__` and `__init__`) to use the argparse-based config added in #339.

- Updated `RunConfig` and `UpdateConfig` classes to have exclusive init kwargs, instead of taking an namespace. This turned out to be much easier when working with the library-style app initialization in `__init__`, both for direct instantiation and via paste config
- Added an `iter_packages()` method to the `RunConfig` to iterate over packages specified by the configuration (note @elfjes, I think that replacing this with e.g. a `backend` reference will be a nice way to tie in #348)
- Added a general-purpose method to map legacy keyword arguments to the `app()` and `paste_app_factory()` functions to updated forms
- Refactored the `paste_app_factory()` to not mutate the incoming dictionary
- Removed all argument-parsing and config-related code from `__main__` and `core`
- Moved `_logwrite` from `__init__` to `__main__`, since that was the only place it was being used after the updates to `core`
- Updated `digest_file` to use `hashlib.new(algo)` instead of `getattr(hashlib, algo)`, because the former supports more algorithms
- Updated `setup.py` to, instead of calling `eval()` on the entirety of `__init__`, to instead just evaluate the line that defines the version
- Assigned the config to a `._pypiserver_config` attribute on the `Bottle` instance to reduce hacky test workarounds
- Fixed the tox config, which I broke in #339 

* Config: add auth & absolute path resolution

* Config: check pkg dirs on config creation

* Instantiate config with kwargs, not namespace

* WIP: still pulling the threads

* Init seems to be working

* tests passing locally, still need to update cache

* Fix tox command

* unused import

* Fix typing

* Be more selective in exec() in setup.py

* Require accurate casing for hash algos

* Remove old comment

* Comments, minor updates and simplifications

* move _logwrite to a more reasonable place

* Update config to work with cache

* Type cachemanager listdir in core

* Update config module docstring, rename method

* Add more comments re: paste config

* Add comments to main, remove unneded check

* Remove commented code

* Use {posargs} instead of [] for clarity in tox

* Add dupe check for kwarg updater

* Remove unused references on app instance

* Fix typo

* Remove redundancy in log level parsing
2020-10-25 18:48:28 -05:00
Matthew Planchard 47d6efe196
Restore ability to drop hashing in new config (#347)
Thanks @elfjes for pointing out that I'd missed this! I also went ahead
and bumped the version in the README to 2.0.0dev1, so that it's clear
that what's in master shouldn't be what people expect from pypi or in the
docker image.
2020-10-11 14:16:57 -05:00
Matthew Planchard 8014fa56fc
Merge branch 'v1.4.x' 2020-10-10 08:21:35 -05:00
Matthew Planchard 776d319eb1
chore(ver): bump 1.4.1-->1.4.2 2020-10-10 08:15:56 -05:00
Matthew Planchard ab8b33e5fb
CHORE: prep for v1.4.2 2020-10-10 08:14:50 -05:00
PelleK e0bff63ab9
fix docker entrypoint script, improve docker build speed/caching (#344)
Co-authored-by: Pelle Koster <pelle.koster@nginfra.nl>
2020-10-10 08:12:06 -05:00
Matthew Planchard 0594c33e53
Backwards-compatible argparse config (not yet in use) (#339)
Adds an argparse config that, while adding subcommands (`pypi-server run` and `pypi-server update`), retains full commandline backwards compatibility with the existing config parsing logic.

There's a bit of hackery required to do this, so this also issues a warning if using the non-subcommand arguments, allowing us to potentially remove support for the old form in our next next major version bump (i.e. 3.0).

Also adds a `.pyproject.toml` with a black config, and a mypy config block to `setup.cfg`.

`mypy` is now called in `tox`, currently only for `config.py`, because nothing else typechecks successfully.

----

* WIP: argparse config

* Complete config

* Test all the config options

* Another test and a note re: being unused

* mypy config, call mypy in tox

* No mypy on pypy

* Fix tox config

* Add venv to black ignore

* fix tox config (again)

* Fix formatting, simplify error handling

* FMT: Run black on changed files
2020-10-08 19:37:39 -05:00
PelleK d886bc2eba
Cleanup code to python 3.6 (#342)
* Cleanup setup.py

* remove explicit inheritance from object

* convert most string interpolations to f-strings

Co-authored-by: Pelle Koster <pelle.koster@nginfra.nl>
2020-10-07 20:45:51 -05:00
Matthew Planchard b44edb61ce
CHORE: pull CHANGES.rst from v1.4.x 2020-10-05 21:15:33 -05:00