-
Notifications
You must be signed in to change notification settings - Fork 0
Set up uv-based package management #657
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||
| name: Test | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: [ main ] | ||||||
| pull_request: | ||||||
| branches: [ main ] | ||||||
|
|
||||||
| jobs: | ||||||
| test: | ||||||
| runs-on: ${{ matrix.os }} | ||||||
| strategy: | ||||||
| matrix: | ||||||
| os: [ubuntu-latest, macos-latest, windows-latest] | ||||||
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | ||||||
|
|
||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Install uv | ||||||
| uses: astral-sh/setup-uv@v5 | ||||||
| with: | ||||||
| enable-cache: true | ||||||
| cache-dependency-glob: "uv.lock" | ||||||
|
|
||||||
| - name: Set up Python ${{ matrix.python-version }} | ||||||
| run: uv python install ${{ matrix.python-version }} | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| run: uv sync --frozen | ||||||
|
||||||
| run: uv sync --frozen | |
| run: uv sync --frozen --python ${{ matrix.python-version }} |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verification step attempts to print math_spec_mapping.__version__, but the __init__.py file does not define a __version__ attribute. This will cause the workflow to fail. Either add a __version__ attribute to the package's __init__.py file, or change this verification to a simpler import check without accessing the version attribute.
| run: uv run python -c "import math_spec_mapping; print(math_spec_mapping.__version__)" | |
| run: uv run python -c "import math_spec_mapping" |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,100 @@ | ||||||||||
| # Development Setup | ||||||||||
|
|
||||||||||
| ## Prerequisites | ||||||||||
|
|
||||||||||
| - Python 3.8 or higher | ||||||||||
| - [uv](https://docs.astral.sh/uv/) - Fast Python package installer and resolver | ||||||||||
|
|
||||||||||
| ## Installing uv | ||||||||||
|
|
||||||||||
| If you don't have uv installed, install it using one of these methods: | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| # On macOS and Linux | ||||||||||
| curl -LsSf https://astral.sh/uv/install.sh | sh | ||||||||||
|
|
||||||||||
| # On Windows | ||||||||||
| powershell -c "irm https://astral.sh/uv/install.ps1 | iex" | ||||||||||
|
|
||||||||||
| # Using pip | ||||||||||
| pip install uv | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Setting Up the Development Environment | ||||||||||
|
|
||||||||||
| 1. Clone the repository: | ||||||||||
| ```bash | ||||||||||
| git clone https://github.com/BlockScience/MSML.git | ||||||||||
| cd MSML | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| 2. Install dependencies using uv: | ||||||||||
| ```bash | ||||||||||
| uv sync | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| This will: | ||||||||||
| - Create a virtual environment in `.venv/` | ||||||||||
| - Install all project dependencies | ||||||||||
| - Install the package in editable mode | ||||||||||
|
|
||||||||||
| 3. Activate the virtual environment: | ||||||||||
| ```bash | ||||||||||
| # On macOS/Linux | ||||||||||
| source .venv/bin/activate | ||||||||||
|
|
||||||||||
| # On Windows | ||||||||||
| .venv\Scripts\activate | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Running Commands in the Virtual Environment | ||||||||||
|
|
||||||||||
| You can run commands in the virtual environment without activating it: | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| # Run Python scripts | ||||||||||
| uv run python your_script.py | ||||||||||
|
|
||||||||||
| # Run installed command-line tools | ||||||||||
| uv run <command> | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Installing the Library for Users | ||||||||||
|
|
||||||||||
| For regular users who just want to use MSML (not develop it): | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| pip install math-spec-mapping | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Or with uv: | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| uv pip install math-spec-mapping | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Adding New Dependencies | ||||||||||
|
|
||||||||||
| If you need to add a new dependency to the project: | ||||||||||
|
|
||||||||||
| ```bash | ||||||||||
| # Add a dependency | ||||||||||
| uv add <package-name> | ||||||||||
|
|
||||||||||
| # Add a development dependency | ||||||||||
| uv add --dev <package-name> | ||||||||||
|
Comment on lines
+84
to
+85
|
||||||||||
| # Add a development dependency | |
| uv add --dev <package-name> | |
| # Add a development dependency (in the "dev" group) | |
| uv add --group dev <package-name> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot can you help solve
The failure is due to this line in src/math_spec_mapping/Load/type.py (ref: 187b270):
from typing import _UnionGenericAlias, List, _GenericAliasThe names _UnionGenericAlias and _GenericAlias are private members of the typing module and are not guaranteed to exist in all Python versions. In Python 3.8, these members areThe job failed due to ImportError: cannot import name '_UnionGenericAlias' from 'typing'. This occurs because _UnionGenericAlias and _GenericAlias are internal classes and are not part of the public API of the typing module. They are not guaranteed to exist across Python versions and their use is discouraged outside the standard library.
To fix this, replace any references to _UnionGenericAlias and _GenericAlias with public interfaces. For checking generic types like Union or List, you can use typing.get_origin and typing.get_args (available in Python 3.8+).
Update the relevant section in src/math_spec_mapping/Load/type.py (ref: 187b270) as follows:
from typing import List, get_origin
# Remove: from typing import _UnionGenericAlias, List, _GenericAlias
# In your logic where _UnionGenericAlias or _GenericAlias not directly importable, causing the ImportError.
To fix this:
1. Remove the import of _UnionGenericAlias and _GenericAlias from the import statement.
2. Use typing's public API to check for union and generic aliases. In Python 3.8+, the best practice is to use typing.get_origin and typing.get_args (Python 3.8+ with typing_extensions, otherwise Python 3.9+ natively).
Here's how you could change the logic:
```python
from are used:
if get_origin(data["type"]["python"]) is not None:
data["type_name"]["python"] = data["type"]["python"].__repr__()
else:
data["type_name"]["python"] = data["type"]["python"].__name__This change uses get_origin to check for generic types instead of relying on internal classes. This will resolve the ImportError and make the code forward-compatible with modern Python versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow is named "Test" but only verifies that the package can be imported successfully. It doesn't run any actual test suite. Consider renaming this workflow to something more accurate like "Install and Verify" or "Build" to avoid confusion, or add actual test execution if test files exist or are planned.