Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: uv installed by default #64

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/source/all_moccasin_toml_parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ All possible options
# You can have pip-style dependencies and also github-style dependencies
# These are going to be dependencies for your vyper contracts
dependencies = ["snekmate==0.1.0", "pcaversaccio/[email protected]"]
installer = "uv"
save_abi_path = "abis" # location to save ABIs from the explorer
cov_config = ".coveragerc" # coverage configuration file
dot_env = ".env" # environment variables file
Expand Down
17 changes: 3 additions & 14 deletions docs/source/dependencies.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Dependencies
############

Moccasin allows for working with either:
For working with smart contracts, ``moccasin`` allows for working with either:

- :ref:`Installing from GitHub repositories <installing_github_dependencies>`

Expand Down Expand Up @@ -68,20 +68,9 @@ You can then use these packages in your vyper contracts, for example in an minia
Installing uv/pip/PyPI Dependencies
===================================

Moccasin let's you directly install and work with PyPI packages as you would any other python package. PyPi dependencies in moccasin are by default powered by the `uv <https://docs.astral.sh/uv/>`_ tool. In order to use this, you need to have the `uv` tool installed. However, you can change this setting to `pip` in your `moccasin.tom`.
Moccasin let's you directly install and work with PyPI packages as you would any other python package. PyPi dependencies in moccasin are by default powered by the `uv <https://docs.astral.sh/uv/>`_ tool under the hood. It comes built-in with ``moccasin``.

.. code-block:: toml

[project]
installer = "uv" # change/add this setting

As of today, `moccasin` supports:

- `uv`

- `pip`

You can also directly install and work with PyPI packages as you would any other python package. To install a package from PyPI, you can run the following:
To install a package from PyPI, you can run the following:

.. code-block:: bash

Expand Down
15 changes: 3 additions & 12 deletions moccasin/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main(args: Namespace):
pip_requirements.append(requirement)
install_path: Path = config.get_base_dependencies_install_path()
if len(pip_requirements) > 0:
_pip_installs(pip_requirements, install_path, config.installer, args.quiet)
_pip_installs(pip_requirements, install_path, args.quiet)
if len(github_requirements) > 0:
_github_installs(github_requirements, install_path, args.quiet)
return 0
Expand Down Expand Up @@ -226,15 +226,10 @@ def _get_download_url_from_tag(org: str, repo: str, version: str, headers: dict)
)


def _pip_installs(
package_ids: list[str], base_install_path: Path, installer: str, quiet: bool = False
):
def _pip_installs(package_ids: list[str], base_install_path: Path, quiet: bool = False):
logger.info(f"Installing {len(package_ids)} pip packages...")
cmd = []
if installer == "uv":
cmd = ["uv", "pip", "install", *package_ids, "--target", str(base_install_path)]
else:
cmd = ["pip", "install", *package_ids, "--target", str(base_install_path)]
cmd = ["uv", "pip", "install", *package_ids, "--target", str(base_install_path)]

capture_output = quiet
try:
Expand All @@ -243,10 +238,6 @@ def _pip_installs(
logger.info(
f"Stack trace:\n{''.join(traceback.format_exception(type(e), e, e.__traceback__))}"
)
logger.error(e)
logger.info(
f'Your installer {installer} is not found in your system PATH.\nPlease install {installer} or update your installer in your moccasin.toml as: \n\n[project]\ninstaller = "your installer here (pip or uv)"'
)
sys.exit(1)

_write_dependencies(package_ids, DependencyType.PIP)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ dependencies = [
"python-dotenv>=1.0.1",
"titanoboa-zksync>=v0.2.2",
"tqdm>=4.66.5",
"tomlkit>=0.13.2",
# For preserving comments when writing to toml
"tomlkit>=0.13.2", # For preserving comments when writing to toml
"tomli-w>=1.0.0",
"pytest-cov>=5.0.0",
"uv>=0.4.15",
]
readme = "README.md"
requires-python = ">= 3.11, < 3.13"
Expand Down
27 changes: 27 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.