Commit Graph

789 Commits

Author SHA1 Message Date
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
PelleK 8101cf9192
Run black on codebase (#336)
* run black on codebase

* add black check to travis ci

* add pyproject.toml, revert black on bottle.py

Co-authored-by: Pelle Koster <pelle.koster@nginfra.nl>
2020-10-05 21:04:22 -05:00
Matthew Planchard 5ca5351d80
chore(ver): bump 1.4.0-->1.4.1 2020-10-05 20:51:01 -05:00
Matthew Planchard b322aebb87
FIX: bash -> sh in entryoint 2020-10-05 20:26:28 -05:00
Matthew Planchard 1f696e56c1
DOC: Update changelog and readme for v1.4.1 2020-10-05 20:20:53 -05:00
Matthew Planchard 75ec4e95c0
FIX: only chown /data/packages in entrypoint
@stephen-dexda pointed out in #341 that our update in #330 changed
the `chown` operation to apply to the entire `/data` directory,
rather than just `/data/packages`. For anyone who was previously
relying on a workflow like mounting a read-only secrets directory
into `/data` to host authentication information, this broke their
workflow.

This fix sets `entrypoint.sh` to only `chown` `/data/packages`, which
should ensure that the permissions issues resolved by #330 (e.g. #309)
remain fixed, while also fixing the issue in #341.
2020-10-05 20:13:16 -05:00
Matthew Planchard 4ab210c82b
MAINT: drop standalone, drop py 2.7 and 3.5 (#338) 2020-10-03 22:25:14 -05:00
Matthew Planchard b208103951
chore(ver): bump 1.3.2-->1.4.0 2020-10-03 17:45:40 -05:00
Norman Schenck 12ae6c118a
Update Dockerfile. Update docker base images. (#330)
Co-authored-by: Matthew Planchard <mplanchard@users.noreply.github.com>
2020-10-03 17:00:47 -05:00
PelleK 8b1979031e
Log messages to stdout instead of stderr (#334)
* log to stdout

* add stdout logging to config and test it

* remove non-implemented parameter from docs

* configure log stream based on config, somehow this change got lost

* fix unittests for other python versions

* option to specify log stream

* Be more explicit in usage text

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

* remove redundant arguments

* be more consistent in usage text

* add test for disabling stream logging

* fix side-effect of unittests

Co-authored-by: Matthew Planchard <mplanchard@users.noreply.github.com>
2020-10-03 16:30:49 -05:00
Matthew Planchard aa2d78cd45
DOC: Add link to zulip chat to README 2020-10-03 15:25:53 -05:00
Daan Luttik dbb7761606
Moved flask-pypi-proxy and pip2pi to a new "Unmaintained or archived" header since the former is archived and the latter has seen barely any development since mid 2015 and no development since sep 2019. (#326) 2020-09-14 22:16:27 -05:00
Peter Slovak c21cf72c25
Add the option to specify list of modules we don't want to update (#298)
* Add the option to specify list of modules we don't want to update

Signed-off-by: Peter Slovak <peter.slovak@websupport.sk>

* Fix docs

Signed-off-by: Peter Slovak <peter.slovak@websupport.sk>

* Minimize the number of strip() calls

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

* Log an exception when we fail to open/read the package blacklist file

* Abort server startup if we fail to read the blacklist file

Co-authored-by: Matthew Planchard <mplanchard@users.noreply.github.com>
2020-07-16 23:03:30 -05:00
John Children 90d0ea151e
Include watchdog for cache in Docker image (#323)
Include watchdog as a dependency in the docker image pip requirements.
This is very useful in situations where your packages are mounted over
the network which may be a typical use case for the image.

As passlib is included as a default dependency this seems like a natural
addition.
2020-07-16 19:06:47 -05:00
Matthew Planchard b1bf1ed248
Drop support for Python 3.4 (#321)
* Drop support for Python 3.4

Python 3.4 is no longer supported. Even pyenv is failing to install it
for me, because apparently the currnet version of `ensurepip` bombs for
3.4. Pypiserver may still work on 3.4, but testing on it has becomes
more of a hassle than it's worth.

* Fix @mplanchard's email address

Just realized my email address in the authors' file has been wrong for
pretty much forever.

* Remove GL CI

GitLab CI is nice, but doesn't support forks, and so isn't going to be
viable for this project.
2020-07-09 22:39:01 -05:00
Tiemen Schuijbroek 5b14270d0d
Fix cherrypy CherryPyWSGIServer import (#301)
CherryPy changed the import location.
This attempts the new or falls back to the old location.

Co-authored-by: Tiemen Schuijbroek <t.j.l.schuijbroek@ratio-case.nl>
2020-07-09 22:10:44 -05:00
Gerardwx 54d35cdbaf
Typo (#303) 2020-07-09 22:05:37 -05:00
Karthikeyan Singaravelan 0a9904af57
Fix deprecation warnings due to invalid escape sequences. (#317) 2020-07-09 22:04:39 -05:00
Fernando B 11ed7e6abd
readme (#316)
Co-authored-by: Fernando Balandran <ic3balandran@yahoo.com>
2020-06-05 11:31:14 -05:00
Julian Berman a7c49fd3e7
Slightly clarify the relationship to warehouse. (#308)
* Slightly clarify the relationship to warehouse.

Closes: #307

* Wording tweaks and split out the related software into its own section.

* Separate the note in a note directive

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

Co-authored-by: Matthew Planchard <mplanchard@users.noreply.github.com>
2020-06-04 19:39:21 -05:00
Micah Smith 1efb991069
Fix usage of string formatting in HTTPError (#310)
`HTTPError(code, message, format_args)` appears to be equivalent to `HTTPError(status=code, body=message, exception=format_args)` which is not what we want here. The string formatting can't be deferred like in logging library usage.
2020-06-04 19:28:38 -05:00
Kristian Sloth Lauszus 6589170cfb Updated Docker Compose example with HTTPS configuration using Traefik (#295) 2020-01-19 18:30:10 -06:00
Matthew Planchard c932451cd5
MAINT: Update passlib in docker reqs (#293) 2020-01-12 00:31:28 -06:00
Matthew Planchard 98958cf2f8
ENH: Officially support python 3.8 (#292) 2020-01-11 23:53:13 -06:00
Matthew Planchard 2dfc7f8ea1
MAINT: Update bottle to 0.12.18 (#290)
* MAINT: Update bottle to 0.12.18

* DOC: update changelog
2020-01-11 23:32:53 -06:00
Matthew Planchard 31fcc898b4
FIX: requirements for docker tests in gitlab (#291)
The gitlab tests started failing with GL's newest "docker in docker"
image due to the lack of some core C library headers. This ensures that
everything needed for twine (i.e. cryptography) is present before doing
a pip install for twine.
2020-01-11 23:19:33 -06:00
Matthew Planchard db74737d3b
DOC: update CHANGES.rst 2020-01-11 17:31:59 -06:00
Matthew Planchard 9a309883be
chore(ver): bump 1.3.1-->1.3.2 2020-01-11 17:26:14 -06:00
Robin De Schepper 124a2a9c43 Update README.rst (#289) 2020-01-11 16:55:17 -06:00
Étienne Noss 5e3d34324c Use python 3.6 for the Dockerfile (#284)
* Use python 3.6 for the Dockerfile

* Dockerfile: use explicit Alpine version

* Empty commit to trigger a new CI build
2019-12-24 00:36:32 -05:00
Géry Ogam afafd0ae50 Update welcome.html (#283)
* Fix typos

* Improve HTML
2019-11-11 18:38:21 -06:00
Matthew Planchard e074cd7c80
FIX: Move pip installation into base image
Resolves #264

Generally, pip doesn't need to be available for `pypiserver` to work
correctly, but the `-U` command to update packages requires it to be
importable. This ensures the `pip` module will be available in the final
image.
2019-11-10 18:11:39 -06:00
Géry Ogam dbee4ec4ce Update welcome.html (#278)
* Update welcome.html

* Update test_app.py
2019-11-10 17:40:13 -06:00
Matthew Planchard ec7ece1ece
Ignore pypy3 test status for GL 2019-10-19 13:09:53 -05:00
Matthew Planchard 5cd70bfe86
Chore: Revert "Update badge for gitlab (#272)"
This reverts commit de6a9ce194.

Not going to be able to use GL because they do not support forks, so
reverting associated changes.
2019-10-19 13:05:52 -05:00