Skip to content

Commit

Permalink
Rename project to pypickup
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Sep 15, 2022
1 parent a370502 commit 7fcca5f
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 52 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PyPI-cache utility
# pypickup

An utility to download packages from PyPI and save them locally, building a tree as if it were the PyPI repository itself.

Expand All @@ -20,33 +20,33 @@ pip install --editable .
An -h flag can be used on any command to display all the available options and its usage. For instance:

```
pypi-cache add -h
pypickup add -h
```

To add a package for the first time:

```
pypi-cache add numpy
pypickup add numpy
```

This will create a folder in the default location (~/.pypi-cache/) in which all the stablished files (.whl and .zip) for the specified package will be downloaded. Besides, it will create the corresponding metadata files (index.html) to track that package. The next time you want to synchronize the same package against the PyPI remote repository, you should do:
This will create a folder in the default location (~/.pypickup/) in which all the stablished files (.whl and .zip) for the specified package will be downloaded. Besides, it will create the corresponding metadata files (index.html) to track that package. The next time you want to synchronize the same package against the PyPI remote repository, you should do:

```
pypi-cache update numpy
pypickup update numpy
```

This will download the new packages available in the remote, in case there is any. It'll do nothing otherwise. It also updates the index.html of the indicated package with the new downloaded packages, as expected.

2 more commands are available to remove packages and to list the available ones already added:

```
pypi-cache rm numpy
pypickup rm numpy
pypi-cache list
pypickup list
```

If we specify a package for the 'list' command, it will show a list of the downloaded distributions themselves.

```
pypi-cache list numpy
pypickup list numpy
```
3 changes: 0 additions & 3 deletions pypi_cache/__main__.py

This file was deleted.

File renamed without changes.
3 changes: 3 additions & 0 deletions pypickup/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pypickup.cli import cli

cli()
4 changes: 2 additions & 2 deletions pypi_cache/cli.py → pypickup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


def cli():
entrypoints = entry_points()["pypi_cache.cmd"]
entrypoints = entry_points()["pypickup.cmd"]

parser = argparse.ArgumentParser(prog="pypi-cache", description="Manage a local offline PyPi mirror")
parser = argparse.ArgumentParser(prog="pypickup", description="Manage a local offline PyPi mirror")
subparsers = parser.add_subparsers(help="available commands", dest="cmd")

plugins = {}
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions pypi_cache/cmd/add.py → pypickup/cmd/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from typing import List

from pypi_cache.pypiCacheManager import LocalPyPIController
from pypickup.controller import LocalPyPIController


class Add:
@staticmethod
def init_subparser(parser: argparse.ArgumentParser):
parser.add_argument("packageNameList", type=str, nargs='+', default="", help="Python packages list to add to the local repository.")
parser.add_argument("-p", "--index-path", dest="pypiLocalPath", type=str, default=os.getenv('PYPICACHE_INDEX_PATH', default="./.pypi-cache/"), help="Local root path in which the package from the PyPI repository will be downloaded.")
parser.add_argument("packageNameList", type=str, nargs="+", default="", help="Python packages list to add to the local repository.")
parser.add_argument("-p", "--index-path", dest="pypiLocalPath", type=str, default=os.getenv("PYPICACHE_INDEX_PATH", default="./.pypickup/"), help="Local root path in which the package from the PyPI repository will be downloaded.")

parser.add_argument("-s", "--only-src", dest="onlySources", default=False, action="store_true", help="Download only the source files (.zip and .tar.gz). Disabled by default.")
parser.add_argument("--dev", dest="includeDevs", default=False, action="store_true", help="Download also the new development releases (alpha, betas), which are not included by default.")
Expand All @@ -21,13 +21,13 @@ def init_subparser(parser: argparse.ArgumentParser):
def run(args: argparse.Namespace):
listOfPackages: List[str] = args.packageNameList
for packageName in listOfPackages:

args.packageName = packageName
print("Adding '" + packageName + "' to the local index:")

controllerInstance = LocalPyPIController()
controllerInstance.parseScriptArguments(args)

if controllerInstance.validPackageName():
controllerInstance.initLocalRepo()

Expand All @@ -38,5 +38,5 @@ def run(args: argparse.Namespace):
print("Package " + controllerInstance.packageName + " has been already added to the local repository. Try to run the 'update' command instead to synchronize changes with the remote PyPI.")
else:
print("Package " + controllerInstance.packageName + " does not exist in the remote repository (" + controllerInstance.remotePyPIRepository + ")")

print()
4 changes: 2 additions & 2 deletions pypi_cache/cmd/remove.py → pypickup/cmd/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from typing import List

from pypi_cache.pypiCacheManager import LocalPyPIController
from pypickup.controller import LocalPyPIController


class Remove:
@staticmethod
def init_subparser(parser: argparse.ArgumentParser):
parser.add_argument("packageNameList", type=str, nargs="+", default="", help="Python packages list to be removed from the local repository.")
parser.add_argument("-p", "--index-path", dest="pypiLocalPath", type=str, default=os.getenv("PYPICACHE_INDEX_PATH", default="./.pypi-cache/"), help="Local root path in which the specified package is expected to be.")
parser.add_argument("-p", "--index-path", dest="pypiLocalPath", type=str, default=os.getenv("PYPICACHE_INDEX_PATH", default="./.pypickup/"), help="Local root path in which the specified package is expected to be.")

@staticmethod
def __fillUpNonUsedArguments(args: argparse.Namespace) -> argparse.Namespace:
Expand Down
12 changes: 6 additions & 6 deletions pypi_cache/cmd/update.py → pypickup/cmd/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from typing import List

from pypi_cache.pypiCacheManager import LocalPyPIController
from pypickup.controller import LocalPyPIController


class Update:
@staticmethod
def init_subparser(parser: argparse.ArgumentParser):
parser.add_argument("packageNameList", type=str, nargs='+', default="", help="Python packages list to add to the local repository.")
parser.add_argument("-p", "--index-path", dest="pypiLocalPath", type=str, default=os.getenv('PYPICACHE_INDEX_PATH', default="./.pypi-cache/"), help="Local root path in which the package from the PyPI repository will be synchronized.")
parser.add_argument("packageNameList", type=str, nargs="+", default="", help="Python packages list to add to the local repository.")
parser.add_argument("-p", "--index-path", dest="pypiLocalPath", type=str, default=os.getenv("PYPICACHE_INDEX_PATH", default="./.pypickup/"), help="Local root path in which the package from the PyPI repository will be synchronized.")

parser.add_argument("-s", "--only-src", dest="onlySources", default=False, action="store_true", help="Download only the source files (.zip and .tar.gz). Disabled by default.")
parser.add_argument("--dev", dest="includeDevs", default=False, action="store_true", help="Download also the new development releases (alpha, betas), which are not included by default.")
Expand All @@ -21,10 +21,10 @@ def init_subparser(parser: argparse.ArgumentParser):
def run(args: argparse.Namespace):
listOfPackages: List[str] = args.packageNameList
for packageName in listOfPackages:

args.packageName = packageName
print("Updating the local index for '" + packageName + "':")

controllerInstance = LocalPyPIController()
controllerInstance.parseScriptArguments(args)

Expand All @@ -33,5 +33,5 @@ def run(args: argparse.Namespace):
controllerInstance.synchronizeWithRemote()
else:
print("Package " + controllerInstance.packageName + " has not been added to the local repository yet. Run the 'add' command first.")

print()
4 changes: 2 additions & 2 deletions pypi_cache/pypiCacheManager.py → pypickup/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import requests

from pypi_cache.utils.htmlManager import HTMLManager
from pypickup.utils.htmlManager import HTMLManager


class LocalPyPIController:
Expand Down Expand Up @@ -150,7 +150,7 @@ def __getLink(self, linkURL: str, verbose: bool = True, retries: int = 10, timeB
if verbose:
print("Trying again...\t(" + linkURL + ")")
time.sleep(timeBetweenRetries)

if response.status_code != 200:
if retries > 1 and verbose:
print("Last try on...\t(" + linkURL + ")")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@
inOrOut_wheels = "out"

# ToDo: "(python_tags>=1.2 | python_tags==1.01) & version>=18.0 & #^cp\d*d-\d*.whl$ | #^cp\d*d-manylinux14.whl$"
inFilters_wheels = {
"version": [],
"python_tags": [">=3.5"],
"abi_tags": ["~cp36", "~cp37"],
"platform_tags": ["~manylinux", "~win32", "~amd64"]
}

outFilters_wheels = {
"version": ["~rc"],
"python_tags": ["~pp", "~cp2", "<3.5"],
"abi_tags": ["~mu"],
"platform_tags": ["~i686", "~win32"]
}
inFilters_wheels = {"version": [], "python_tags": [">=3.5"], "abi_tags": ["~cp36", "~cp37"], "platform_tags": ["~manylinux", "~win32", "~amd64"]}

outFilters_wheels = {"version": ["~rc"], "python_tags": ["~pp", "~cp2", "<3.5"], "abi_tags": ["~mu"], "platform_tags": ["~i686", "~win32"]}

# Attributes lists (https://peps.python.org/pep-0425/):
# version: rc[X]
Expand All @@ -27,10 +17,11 @@

from typing import Dict, List


class WheelsConfig:

"""
A class to save the configuration for the PyPI-cache commands.
A class to save the configuration for the pypickup commands.
The user can choose between filtering wheels in or out. If self.inOrOut == "in", the expected logic is that all packages will not be considere by
default, only if they match with the specified expressions. If self.inOurOut == "out", then all the packages will be included by default and only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import wheel_filename
from multimethod import multimethod

from pypi_cache.settings.wheelFilters import WheelsConfig
from pypickup.settings.wheelFilters import WheelsConfig


class WheelsManager:
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "pypi-cache"
name = "pypickup"
version = "0.1.0"
authors = [
{ name="German Navarro", email="ge.najim@gmail.com" },
Expand All @@ -27,18 +27,18 @@ dependencies = [
]

[tool.setuptools]
packages = ["pypi_cache", "pypi_cache.cmd", "pypi_cache.settings", "pypi_cache.utils"]
packages = ["pypickup", "pypickup.cmd", "pypickup.settings", "pypickup.utils"]

[project.urls]
"Homepage" = "https://github.com/UB-Quantic/pypi-cache"
"Homepage" = "https://github.com/UB-Quantic/pypickup"

[project.scripts]
pypi-cache = "pypi_cache.cli:cli"
pypickup = "pypickup.cli:cli"

[project.entry-points."pypi_cache.cmd"]
add = "pypi_cache.cmd:Add"
update = "pypi_cache.cmd:Update"
rm = "pypi_cache.cmd:Remove"
[project.entry-points."pypickup.cmd"]
add = "pypickup.cmd:Add"
update = "pypickup.cmd:Update"
rm = "pypickup.cmd:Remove"

[tool.black]
line-length = 1000

0 comments on commit 7fcca5f

Please sign in to comment.