Skip to content

pywharf-0.2.3-py3-none-any.whl

Latest
Compare
Choose a tag to compare
@huntzhan huntzhan released this 11 Jul 18:22
· 1 commit to master since this release
7e791ac

name = "pywharf"
version = "0.2.3"
filetype = "bdist_wheel"
pyversion = "py3"
metadata_version = "2.1"
summary = "A private PyPI server powered by flexible backends."
home_page = "https://github.com/pywharf/pywharf"
author = "huntzhan"
author_email = "[email protected]"
maintainer = ""
maintainer_email = ""
license = "MIT"
description = "<div align="center">\n\n# pywharf\n\nThe private PyPI server powered by flexible backends.\n\nbuild-and-push\nlicense\n\n\n\n* pywharf\n\t* What is it?\n\t* Design\n\t* Usage\n\t\t* Install from PyPI\n\t\t* Using the docker image (recommended)\n\t\t* Run the server\n\t\t* Server API\n\t\t* Update index\n\t\t* Backend-specific commands\n\t\t* Environment mode\n\t* Backends\n\t\t* GitHub\n\t\t* File system\n\n------\n\n## What is it?\n\npywharf allows you to deploy a PyPI server privately and keep your artifacts safe by leveraging the power (confidentiality, integrity and availability) of your storage backend. The backend mechanism is designed to be flexible so that the developer could support a new storage backend at a low cost.\n\nSupported backends:\n\n- GitHub. (Yes, you can now host your Python package in GitHub by using pywharf. )\n- File system.\n- ... (Upcoming)\n\n## Design\n\n<div align="center"><img width="766" alt="Screen Shot 2020-03-24 at 8 19 12 PM" src="https://user-images.githubusercontent.com/5213906/77424853-c14e0480-6e0c-11ea-9a7f-879a68ada0a0.png\">\n\nThe pywharf server serves as an abstraction layer between Python package management tools (pip/poetry/twine) and the storage backends:\n\n* Package management tools communicate with pywharf server, following PEP 503 -- Simple Repository API for searching/downloading package, and Legacy API for uploading package.\n* pywharf server then performs file search/download/upload operations with some specific storage backend.\n\n## Usage\n\n### Install from PyPI\n\nshell\npip install pywharf==0.2.3\n\n\nThis should bring the execuable pywharf to your environment.\n\nshell\n$ pywharf --help\nSYNOPSIS\n pywharf <command> <command_flags>\n\nSUPPORTED COMMANDS\n server\n update_index\n github.init_pkg_repo\n github.gen_gh_pages\n\n\n### Using the docker image (recommended)\n\nDocker image: pywharf/pywharf:0.2.3. The image tag is the same as the package version in PyPI.\n\nshell\n$ docker run --rm pywharf/pywharf:0.2.3 --help\nSYNOPSIS\n pywharf <command> <command_flags>\n\nSUPPORTED COMMANDS\n server\n update_index\n github.init_pkg_repo\n github.gen_gh_pages\n\n\n### Run the server\n\nTo run the server, use the command pywharf server.\n\ntxt\nSYNOPSIS\n pywharf server ROOT <flags>\n\nPOSITIONAL ARGUMENTS\n ROOT (str):\n Path to the root folder. This folder is for logging,\n file-based lock and any other file I/O.\n\nFLAGS\n --config (Optional[str]):\n Path to the package repository config (TOML),\n or the file content if --config_or_admin_secret_can_be_text is set.\n Default to None.\n --admin_secret (Optional[str]):\n Path to the admin secrets config (TOML) with read/write permission.\n or the file content if --config_or_admin_secret_can_be_text is set.\n This field is required for local index synchronization.\n Default to None.\n --config_or_admin_secret_can_be_text (Optional[bool]):\n Enable passing the file content to --config or --admin_secret.\n Default to False.\n --auth_read_expires (int):\n The expiration time (in seconds) for read authentication.\n Default to 3600.\n --auth_write_expires (int):\n The expiration time (in seconds) for write authentication.\n Default to 300.\n --extra_index_url (str):\n Extra index url for redirection in case package not found.\n If set to empty string explicitly redirection will be suppressed.\n Default to 'https://pypi.org/simple/'.\n --debug (bool):\n Enable debug mode.\n Default to False.\n --host (str):\n The interface to bind to.\n Default to '0.0.0.0'.\n --port (int):\n The port to bind to.\n Default to 8888.\n **waitress_options (Dict[str, Any]):\n Optional arguments that `waitress.serve` takes.\n Details in https://docs.pylonsproject.org/projects/waitress/en/stable/arguments.html.\n Default to {}.\n\n\nIn short, the configuration passed to --config defines mappings from pkg_repo_name to backend-specific settings. In other words, a single server instance can be configured to connect to multiple backends.\n\nExampe of the configuration file passed to --config:\n\ntoml\n[pywharf-pkg-repo]\ntype = \"github\"\nowner = \"pywharf\"\nrepo = \"pywharf-pkg-repo\"\n\n[local-file-system]\ntype = \"file_system\"\nread_secret = \"foo\"\nwrite_secret = \"bar\"\n\n\nExampe of the admin secret file passed to --admin_secret:\n\ntoml\n[pywharf-pkg-repo]\ntype = \"github\"\nraw = \"<personal-access-token>\"\n\n[local-file-system]\ntype = \"file_system\"\nraw = \"foo\"\n\n\nExample run:\n\nshell\ndocker run --rm \\\n -v /path/to/root:/pywharf-root \\\n -v /path/to/config.toml:/config.toml \\\n -v /path/to/admin_secret.toml:/admin_secret.toml \\\n -p 8888:8888 \\\n pywharf/pywharf:0.2.3 \\\n server \\\n /pywharf-root \\\n --config=/config.toml \\\n --admin_secret=/admin_secret.toml\n\n\n### Server API\n\n#### Authentication in shell\n\nUser must provide the pkg_repo_name and their secret in most of the API calls so that the server can find which backend to operate and determine whether the operation is permitted or not. The pkg_repo_name and the secret should be provided in basic access authentication.\n\nSome package management tools will handle the authentication behind the screen, for example,\n\n* Twine: to set the environment variables TWINE_USERNAME and TWINE_PASSWORD. ref\n* Poetry: Configuring credentials.\n\nSome will not, for example,\n\n* Pip: you need to prepend <pkg_repo_name>:<secret>@ to the hostname in the URL manually like this https://[username[:password]@]pypi.company.com/simple. ref\n\n#### Authentication in browser\n\nYou need to visit /login page to submit pkg_repo_name and the secret, since most of the browsers today don't support prepending <username>:<password>@ to the hostname in the URL. The pkg_repo_name and the secret will be stored in the session cookies. To reset, visit /logout .\n\nExample: http://localhost:8888/login/\n\n<div align="center"><img width="600" alt="Screen Shot 2020-03-25 at 12 36 03 PM" src="https://user-images.githubusercontent.com/5213906/77502233-40871b00-6e95-11ea-8ac9-4844d7067ed2.png\">\n\n\n#### PEP-503, Legacy API\n\nThe server follows PEP 503 -- Simple Repository API and Legacy API to define APIs for searching/downloading/uploading package:\n\n* GET /simple/: List all distributions.\n* GET /simple/<distrib>/: List all packages in a distribution.\n* GET /simple/<distrib>/<filename>: Download a package file.\n* POST /simple/: Upload a package file.\n\nIn a nutshell, you need to set the "index url / repository url / ..." to http://<host>:<port>/simple/ for the package management tool.\n\n#### Server management\n\n##### GET /index_mtime\n\nGet the last index index synchronization timestamp.\n\nshell\n$ curl http://debug:foo@localhost:8888/index_mtime/\n1584379892\n\n\n##### POST /initialize\n\nSubmit configuration and (re-)initialize the server. User can change the package repository configuration on-the-fly with this API.\n\nshell\n# POST the file content.\n$ curl \\\n -d \"config=${CONFIG}&admin_secret=${ADMIN_SECRET}\" \\\n -X POST \\\n http://localhost:8888/initialize/\n\n# Or, POST the file.\n$ curl \\\n -F 'config=@/path/to/config.toml' \\\n -F 'admin_secret=@/path/to/admin_secret.toml' \\\n http://localhost:8888/initialize/\n\n\n### Update index\n\n<div align="center"><img width="636" alt="Screen Shot 2020-03-25 at 5 39 19 PM" src="https://user-images.githubusercontent.com/5213906/77522697-9a043f80-6ebf-11ea-95e6-9a086db7af2e.png\">\n\nIndex file is used to track all published packages in a specific time:\n\n* Remote index file: the index file sotred in the backend. By design, this file is only updated by a standalone update index service and will not be updated by the pywharf server.\n* Local index file: the index file synchronized from the remote index file by the pywharf server\n\nTo update the remote index file, use the command pywharf update_index:\n\ntxt\nSYNOPSIS\n pywharf update_index TYPE NAME <flags>\n\nPOSITIONAL ARGUMENTS\n TYPE (str):\n Backend type.\n NAME (str):\n Name of config.\n\nFLAGS\n --secret (Optional[str]):\n The secret with write permission.\n --secret_env (Optional[str]):\n Instead of passing the secret through --secret,\n the secret could be loaded from the environment variable.\n **pkg_repo_configs (Dict[str, Any]):\n Any other backend-specific configs are allowed.\n\n\nBackend developer could setup an update index service by invoking pywharf update_index command.\n\n### Backend-specific commands\n\nThe backend registration mechanism will hook up the backend-specific commands to pywharf. As illustrated, commands github.init_pkg_repo and github.gen_gh_pages are registered by github backend.\n\nshell\n$ pywharf --help\nSYNOPSIS\n pywharf <command> <command_flags>\n\nSUPPORTED COMMANDS\n server\n update_index\n github.init_pkg_repo\n github.gen_gh_pages\n\n\n### Environment mode\n\nIf no argument is passed, pywharf will try to load the arguments from the environment variables. This mode would be helpful if passing argument in shell is not possible.\n\nThe format:\n\n- PYWHARF_COMMAND: to set <command>.\n- PYWHARF_COMMAND_<FLAG>: to set the flag of <command>.\n\n## Backends\n\n### GitHub\n\n#### Introduction\n\npywharf will help you setup a new GitHub repository to host your package. You package will be published as repository release and secured by personal access token. Take https://github.com/pywharf/pywharf-pkg-repo and https://pywharf.github.io/pywharf-pkg-repo/ as an example.\n\n#### Configuration and secret\n\nPackage repository configuration of GitHub backend:\n\n- type: must set to github.\n- owner: repository owner.\n- repo: repository name.\n- branch (optional): the branch to store the remote index file. Default to master.\n- index_filename (optional): the name of remote index file. Default to index.toml.\n- max_file_bytes (optional): limit the maximum size (in bytes) of package. Default to 2147483647 since each file included in a release must be under 2 GB, as restricted by GitHub .\n- sync_index_interval (optional): the sleep time interval (in seconds) before taking the next local index file synchronization. Default to 60.\n\nExample configuration of https://github.com/pywharf/pywharf-pkg-repo:\n\n```toml\n[pywharf-pkg-repo]\ntype = "github"\nowner = "pywharf"\nrepo = "pywharf-pkg-repo"\n\n\nThe GitHub backend accepts [personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) as the repository secret. The `pywharf` server calls GitHub API with PAT to operate on packages. You can authorize user with read or write permission based on [team role](https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization).\n\n#### Initialize the repository\n\nTo initialize a GitHub repository as the storage backend, run the command `github.init_pkg_repo`:\n\nshell\ndocker run --rm pywharf/pywharf:0.2.3 \\n github.init_pkg_repo \\n --name pywharf-pkg-repo \\n --owner pywharf \\n --repo pywharf-pkg-repo \\n --token \\n --pywharf_version 0.2.3\n\n\nThis will:\n\n- Create a new repository `<owner>/<repo>`.\n- Setup the GitHub workflow to update the remote index file if new package is published.\n- Print the configuration for you.\n\nIf you want to host the index in GitHub page, like https://pywharf.github.io/pywharf-pkg-repo/, add `--enable_gh_pages` to command execution.\n\n#### GitHub workflow integration\n\nTo use `pywharf` with GitHub workflow, take [thie main.yml](https://github.com/pywharf/pywharf/blob/master/.github/workflows/main.yml) as an example.\n\nFirstly, run the server as job service:\n\nyaml\nservices:\n pywharf:\n image: pywharf/pywharf:0.2.3\n ports:\n - 8888:8888\n volumes:\n - pywharf-root:/pywharf-root\n env:\n PYWHARF_COMMAND: server\n PYWHARF_COMMAND_ROOT: /pywharf-root\n\n\nSecondly, initialize the server with configuration and admin secret (Note: remember to [add the admin secret to your repository](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) before using it):\n\nyaml\nsteps:\n - name: Setup pywharf\n run: |\n curl \\n -d "config=${CONFIG}&admin_secret=${ADMIN_SECRET}" \\n -X POST \\n http://localhost:8888/initialize/\n env:\n CONFIG: |\n [pywharf-pkg-repo]\n type = "github"\n owner = "pywharf"\n repo = "pywharf-pkg-repo"\n ADMIN_SECRET: |\n [pywharf-pkg-repo]\n type = "github"\n raw = "${{ secrets.PYWHARF_PKG_REPO_TOKEN }}"\n\n\nAfterward, set `http://localhost:8888/simple/` as the repository url, and you are good to go.\n\n### File system\n\n#### Introduction\n\nYou can configure this backend to host the packages in the local file system.\n\n#### Configuration and secret\n\nPackage repository configuration of GitHub backend:\n\n- `type`: must set to `file_system`.\n- `read_secret`: defines the secret with read only permission.\n- `write_secret`: defines the secret with write permission.\n- `max_file_bytes` (optional): limit the maximum size (in bytes) of package. Default to `5368709119` (5 GB).\n- `sync_index_interval` (optional): the sleep time interval (in seconds) before taking the next local index file synchronization. Default to `60`.\n\nExample configuration:\n\ntoml\n[local-file-system]\ntype = "file_system"\nread_secret = "foo"\nwrite_secret = "bar"\n```\n\nTo use the API, user must provide either read_secret or `write_secret`.\n\n#### Initialize the package repository\n\nA folder will be created automatically to store the packages, with the path `/cache/<pkg_repo_name>/storage`.\n\n"
keywords = "private,pypi,packaging,dependency"
classifiers = "License :: OSI Approved :: MIT License"
download_url = ""
comment = ""
md5_digest = "cdef680f5ac39a4735fd3ca8ba428a16"
sha256_digest = "13e225746919015b591f999ea0ea8f5c63e3c35df163c0a5a04c80af88583c2d"
blake2_256_digest = "e785742707ca00f307e1bfed702b3a9a39a22b34fa350e4e4a570dbc5872aed2"
project_urls = "Repository, https://github.com/pywharf/pywharf"
requires_dist = "pywharf-core (==0.2.2)"
requires_python = ">=3.7,<4.0"
description_content_type = "text/markdown"
":action" = "file_upload"
protocol_version = "1"
distrib = "pywharf"
sha256 = "13e225746919015b591f999ea0ea8f5c63e3c35df163c0a5a04c80af88583c2d"