Skip to content

Commit

Permalink
Resilience to Oddball Internet Setups (#89)
Browse files Browse the repository at this point in the history
* SSL verification can optionally computer's default trust store instead of the default `certifi` when `truststore` is installed (always installed with Nix)
* Volare now supports `socks5://` (and only 5) scheme proxies, intercepting the cryptic `ValueError` for `socks://` schemes
* Token is now set globally and not used to create a session that is then passed around
* Slight code structure cleanup
  • Loading branch information
donn authored May 23, 2024
1 parent b72ce15 commit efe15b9
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ clean:
rm -rf build/
rm -rf logs/
rm -rf dist/
rm -rf *.egg-info
rm -rf *.egg-info
15 changes: 13 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
{
lib,
buildPythonPackage,
click,
pyyaml,
rich,
httpx,
pcpp,
zstandard,
nix-gitignore
truststore,
nix-gitignore,
}:

buildPythonPackage rec {
Expand All @@ -41,5 +43,14 @@ buildPythonPackage rec {
httpx
pcpp
zstandard
];
truststore
] ++ httpx.optional-dependencies.socks;

meta = with lib; {
mainProgram = "volare";
description = "Version manager and builder for open-source PDKs";
homepage = "https://github.com/efabless/volare";
license = licenses.asl20;
platforms = platforms.darwin ++ platforms.linux;
};
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pyyaml>=5,<7
rich>=12,<14 # Rich 12 is the last version supporting Python 3.6
httpx>=0.22.0
pcpp>=1.2,<2
zstandard>=0.19.0,<1
zstandard>=0.19.0,<1
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
author="Efabless Corporation",
author_email="[email protected]",
install_requires=requirements,
extras_require={"truststore": ["truststore"]}, # Python 3.10+
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
Expand Down
4 changes: 4 additions & 0 deletions type_stubs/truststore.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ssl

class SSLContext(ssl.SSLContext):
def __init__(self, protocol: int) -> None: ...
13 changes: 3 additions & 10 deletions volare/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def rm_cmd(pdk_root, pdk, version):
@click.command("ls")
@opt_token
@opt_pdk_root
def list_cmd(pdk_root, pdk, session):
def list_cmd(pdk_root, pdk):
"""Lists PDK versions that are locally installed. JSON if not outputting to a tty."""

pdk_versions = Version.get_all_installed(pdk_root, pdk)
Expand All @@ -131,7 +131,6 @@ def list_cmd(pdk_root, pdk, session):
pdk,
console=console,
installed_list=pdk_versions,
session=session,
)
else:
print(json.dumps([version.name for version in pdk_versions]), end="")
Expand All @@ -140,11 +139,11 @@ def list_cmd(pdk_root, pdk, session):
@click.command("ls-remote")
@opt_token
@opt_pdk_root
def list_remote_cmd(pdk_root, pdk, session):
def list_remote_cmd(pdk_root, pdk):
"""Lists PDK versions that are remotely available. JSON if not outputting to a tty."""

try:
all_versions = Version._from_github(session)
all_versions = Version._from_github()
pdk_versions = all_versions.get(pdk) or []

if sys.stdout.isatty():
Expand Down Expand Up @@ -212,7 +211,6 @@ def enable_cmd(
tool_metadata_file_path,
version,
include_libraries,
session,
):
"""
Activates a given installed PDK version.
Expand Down Expand Up @@ -240,7 +238,6 @@ def enable_cmd(
version,
include_libraries=include_libraries,
output=console,
session=session,
)
except Exception as e:
console.print(f"[red]{e}")
Expand Down Expand Up @@ -271,7 +268,6 @@ def fetch_cmd(
tool_metadata_file_path,
version,
include_libraries,
session,
):
"""
Fetches a PDK to Volare's store without setting it as the "enabled" version
Expand Down Expand Up @@ -300,7 +296,6 @@ def fetch_cmd(
version=version,
include_libraries=include_libraries,
output=console,
session=session,
)
print(version.get_dir(pdk_root), end="")

Expand Down Expand Up @@ -337,7 +332,6 @@ def enable_or_build_cmd(
version,
use_repo_at,
push_libraries,
session,
):
"""
Attempts to activate a given PDK version. If the version is not found locally or remotely,
Expand Down Expand Up @@ -377,7 +371,6 @@ def enable_or_build_cmd(
},
include_libraries=include_libraries,
output=console,
session=session,
)
except Exception as e:
console.print(f"[red]{e}")
Expand Down
2 changes: 1 addition & 1 deletion volare/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = "0.17.0"
__version__ = "0.18.0"

if __name__ == "__main__":
print(__version__, end="")
10 changes: 3 additions & 7 deletions volare/build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
from ..github import (
GitHubSession,
get_open_pdks_commit_date,
VOLARE_REPO_NAME,
VOLARE_REPO_OWNER,
volare_repo,
)
from ..common import (
Version,
Expand Down Expand Up @@ -101,7 +100,6 @@ def build_cmd(
tool_metadata_file_path,
version,
use_repo_at,
session,
):
"""
Builds the requested PDK.
Expand Down Expand Up @@ -138,8 +136,8 @@ def push(
pdk,
version,
*,
owner=VOLARE_REPO_OWNER,
repository=VOLARE_REPO_NAME,
owner=volare_repo.owner,
repository=volare_repo.name,
pre=False,
push_libraries=None,
session: Optional[GitHubSession] = None,
Expand Down Expand Up @@ -244,7 +242,6 @@ def push_cmd(
pdk,
version,
push_libraries,
session,
):
"""
For maintainers: Package and release a build to the public.
Expand All @@ -263,7 +260,6 @@ def push_cmd(
repository=repository,
pre=pre,
push_libraries=push_libraries,
session=session,
)
except Exception as e:
console.print(f"[red]Failed to push version: {e}")
Expand Down
1 change: 0 additions & 1 deletion volare/build/asap7.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def install_asap7(build_directory, pdk_root, version):
console = Console()
with console.status("Adding build to list of installed versions…"):
version_directory = get_version_dir(pdk_root, "asap7", version)
print(version_directory)
if (
os.path.exists(version_directory)
and len(os.listdir(version_directory)) != 0
Expand Down
4 changes: 2 additions & 2 deletions volare/build/gf180mcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from .git_multi_clone import GitMultiClone
from .common import RepoMetadata, patch_open_pdks
from ..families import Family
from ..github import OPDKS_REPO_HTTPS
from ..github import opdks_repo
from ..common import (
get_version_dir,
get_volare_dir,
Expand All @@ -37,7 +37,7 @@

repo_metadata = {
"open_pdks": RepoMetadata(
OPDKS_REPO_HTTPS,
opdks_repo.link,
"cc0029b45c68137aa21323912f50d2fc17eeea13",
"master",
),
Expand Down
4 changes: 2 additions & 2 deletions volare/build/sky130.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .git_multi_clone import GitMultiClone
from .common import RepoMetadata, patch_open_pdks
from ..families import Family
from ..github import OPDKS_REPO_HTTPS
from ..github import opdks_repo
from ..common import (
get_version_dir,
get_volare_dir,
Expand All @@ -38,7 +38,7 @@

repo_metadata = {
"open_pdks": RepoMetadata(
OPDKS_REPO_HTTPS,
opdks_repo.link,
"34eeb2743e99d44a21c2cedd467675a2e0f3bb91",
"master",
),
Expand Down
9 changes: 5 additions & 4 deletions volare/click_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import click

from .common import VOLARE_RESOLVED_HOME
from .github import VOLARE_REPO_OWNER, VOLARE_REPO_NAME, GitHubSession
from .github import volare_repo, GitHubSession

opt = partial(click.option, show_default=True)

Expand Down Expand Up @@ -77,10 +77,10 @@ def opt_build(function: Callable):


def opt_push(function: Callable):
function = opt("-o", "--owner", default=VOLARE_REPO_OWNER, help="Repository Owner")(
function = opt("-o", "--owner", default=volare_repo.owner, help="Repository Owner")(
function
)
function = opt("-r", "--repository", default=VOLARE_REPO_NAME, help="Repository")(
function = opt("-r", "--repository", default=volare_repo.name, help="Repository")(
function
)
function = opt(
Expand All @@ -102,7 +102,7 @@ def set_token_cb(
param: click.Parameter,
value: Optional[str],
):
return GitHubSession(github_token=value)
GitHubSession.Token.override = value


def opt_token(function: Callable) -> Callable:
Expand All @@ -112,6 +112,7 @@ def opt_token(function: Callable) -> Callable:
"session",
default=None,
required=False,
expose_value=False,
help="Replace the GitHub token used for GitHub requests, which is by default the value of the environment variable GITHUB_TOKEN or None.",
callback=set_token_cb,
)(function)
Expand Down
Loading

0 comments on commit efe15b9

Please sign in to comment.