Skip to content

Commit

Permalink
Merge pull request #625 from leocardao/mr/cardao/add-allow-prerelease…
Browse files Browse the repository at this point in the history
…-option

e3-pypi-closure: Add option to allow pre-release version usage
  • Loading branch information
leocardao authored Sep 4, 2023
2 parents 707543a + 44304d0 commit 0fd3ddb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/e3/python/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ def __init__(
for version in self.data.get("releases", {}):
try:
v = packaging.version.parse(version)
if not v.is_prerelease and not v.is_devrelease:
if (not v.is_prerelease and not v.is_devrelease) or (
v.is_prerelease and self.name in pypi.allowed_prerelease
):
self.versions.append(v)
except Exception:
logger.warning(f"Cannot parse version {version} of {self.name}")
Expand Down Expand Up @@ -375,6 +377,7 @@ def __init__(
cache_dir: str,
cache_file: str | None = None,
pypi_url: str = "https://pypi.org/pypi",
allowed_prerelease: list[str] | None = None,
) -> None:
"""Initialize a PyPI session.
Expand All @@ -394,6 +397,7 @@ def __init__(
self.load_cache_file()
self.requirements: set[Requirement] = set()
self.explicit_requirements: set[Requirement] = set()
self.allowed_prerelease = allowed_prerelease or []

self.platforms = platforms
self.sys_platforms = set()
Expand Down
9 changes: 9 additions & 0 deletions src/e3/python/pypiscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ def main() -> None:
help="Use local clones. When set look for git clones in a directory",
default=None,
)
m.argument_parser.add_argument(
"--allow-prerelease",
dest="allowed_prerelease",
metavar="REQUIREMENT",
nargs="*",
default=None,
help="Allow to use pre-release version for some requirements",
)
m.parse_args()
assert m.args is not None

Expand Down Expand Up @@ -153,6 +161,7 @@ def main() -> None:
cache_dir=wheel_cache_dir,
python3_version=m.args.python3_version,
platforms=config["platforms"],
allowed_prerelease=m.args.allowed_prerelease,
) as pypi:
for wheel in local_wheels:
logging.info(f"Register wheel {wheel.path}")
Expand Down

0 comments on commit 0fd3ddb

Please sign in to comment.