Skip to content

Commit

Permalink
Bring back freecad (#1)
Browse files Browse the repository at this point in the history
* Bring back freecad

* Update deps
  • Loading branch information
trungleduc authored Dec 7, 2023
1 parent 0f4b13f commit 5987145
Show file tree
Hide file tree
Showing 19 changed files with 3,815 additions and 484 deletions.
102 changes: 50 additions & 52 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,72 +11,70 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0,<5"
- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0,<5"

- name: Lint the extension
run: |
set -eux
jlpm
jlpm run lint:check
- name: Install dependencies
run: |
set -eux
jlpm
- name: Build the extension
run: |
set -eux
python -m pip install .[test]
- name: Build the extension
run: |
set -eux
python -m pip install .[test]
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "@jupytercad/jupytercad-freecad.*OK"
python -m jupyterlab.browser_check
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "@jupytercad/jupytercad-freecad.*OK"
python -m jupyterlab.browser_check
- name: Package the extension
run: |
set -eux
- name: Package the extension
run: |
set -eux
pip install build
python -m build
pip uninstall -y "jupytercad-freecad" jupyterlab
pip install build
python -m build
pip uninstall -y "jupytercad_freecad" jupyterlab
- name: Upload extension packages
uses: actions/upload-artifact@v3
with:
name: extension-artifacts
path: dist/jupytercad-freecad*
if-no-files-found: error
- name: Upload extension packages
uses: actions/upload-artifact@v3
with:
name: extension-artifacts
path: dist/jupytercad_freecad*
if-no-files-found: error

test_isolated:
needs: build
runs-on: ubuntu-latest

steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- uses: actions/download-artifact@v3
with:
name: extension-artifacts
- name: Install and Test
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab>=4.0.0,<5" jupytercad-freecad*.whl
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "@jupytercad/jupytercad-freecad.*OK"
python -m jupyterlab.browser_check --no-browser-test
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- uses: actions/download-artifact@v3
with:
name: extension-artifacts
- name: Install and Test
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab>=4.0.0,<5" jupytercad_freecad*.whl
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "@jupytercad/jupytercad-freecad.*OK"
python -m jupyterlab.browser_check --no-browser-test
check_links:
name: Check Links
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Check Release
on:
push:
branches: ["main"]
branches: ['main']
pull_request:
branches: ["*"]
branches: ['*']

jobs:
check_release:
Expand All @@ -16,7 +16,6 @@ jobs:
- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:

token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Distributions
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/prep-release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: "Step 1: Prep Release"
name: 'Step 1: Prep Release'
on:
workflow_dispatch:
inputs:
version_spec:
description: "New Version Specifier"
default: "next"
description: 'New Version Specifier'
default: 'next'
required: false
branch:
description: "The branch to target"
description: 'The branch to target'
required: false
post_version_spec:
description: "Post Version Specifier"
description: 'Post Version Specifier'
required: false
since:
description: "Use PRs with activity since this date or git reference"
description: 'Use PRs with activity since this date or git reference'
required: false
since_last_stable:
description: "Use PRs with activity since the last stable git tag"
description: 'Use PRs with activity since the last stable git tag'
required: false
type: boolean
jobs:
Expand All @@ -36,6 +36,6 @@ jobs:
since: ${{ github.event.inputs.since }}
since_last_stable: ${{ github.event.inputs.since_last_stable }}

- name: "** Next Step **"
- name: '** Next Step **'
run: |
echo "Optional): Review Draft Release: ${{ steps.prep-release.outputs.release_url }}"
12 changes: 6 additions & 6 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: "Step 2: Publish Release"
name: 'Step 2: Publish Release'
on:
workflow_dispatch:
inputs:
branch:
description: "The target branch"
description: 'The target branch'
required: false
release_url:
description: "The URL of the draft GitHub release"
description: 'The URL of the draft GitHub release'
required: false
steps_to_skip:
description: "Comma separated list of steps to skip"
description: 'Comma separated list of steps to skip'
required: false

jobs:
Expand Down Expand Up @@ -44,13 +44,13 @@ jobs:
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
release_url: ${{ steps.populate-release.outputs.release_url }}

- name: "** Next Step **"
- name: '** Next Step **'
if: ${{ success() }}
run: |
echo "Verify the final release"
echo ${{ steps.finalize-release.outputs.release_url }}
- name: "** Failure Message **"
- name: '** Failure Message **'
if: ${{ failure() }}
run: |
echo "Failed to Publish the Draft Release Url:"
Expand Down
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ci:
# pre-commit.ci will open PRs updating our hooks once a month
autoupdate_schedule: monthly
# skip any check that needs internet access
autofix_prs: true

repos:
# Autoformat and linting, misc. details
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: forbid-new-submodules
- id: end-of-file-fixer
exclude: galata/.*-snapshots
- id: check-case-conflict
- id: requirements-txt-fixer
- id: check-added-large-files
args: ['--maxkb=5000']
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: trailing-whitespace
exclude: .bumpversion.cfg

# Autoformat: Python code
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: ['--fix']

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.55.0
hooks:
- id: eslint
files: \.tsx?$
types: [file]
additional_dependencies:
- '[email protected]'
- '@typescript-eslint/[email protected]'
- '@typescript-eslint/[email protected]'
- '[email protected]'
- '[email protected]'
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules
**/lib
**/package.json
!/package.json
jupytercad-freecad
jupytercad_freecad
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nodeLinker: node-modules
enableImmutableInstalls: false
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# jupytercad-freecad
# jupytercad_freecad

[![Github Actions Status](https://github.com/jupytercad/jupytercad-freecad/workflows/Build/badge.svg)](https://github.com/jupytercad/jupytercad-freecad/actions/workflows/build.yml)
A JupyterLab extension.
Expand All @@ -12,15 +12,15 @@ A JupyterLab extension.
To install the extension, execute:

```bash
pip install jupytercad-freecad
pip install jupytercad_freecad
```

## Uninstall

To remove the extension, execute:

```bash
pip uninstall jupytercad-freecad
pip uninstall jupytercad_freecad
```

## Contributing
Expand All @@ -35,11 +35,13 @@ The `jlpm` command is JupyterLab's pinned version of

```bash
# Clone the repo to your local environment
# Change directory to the jupytercad-freecad directory
# Change directory to the jupytercad_freecad directory
# Install package in development mode
pip install -e "."
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Server extension must be manually installed in develop mode
jupyter server extension enable jupytercad_freecad
# Rebuild extension Typescript source after making changes
jlpm build
```
Expand All @@ -64,12 +66,12 @@ jupyter lab build --minimize=False
### Development uninstall

```bash
pip uninstall jupytercad-freecad
pip uninstall jupytercad_freecad
```

In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
folder is located. Then you can remove the symlink named `@jupytercad/jupytercad-freecad` within that folder.
folder is located. Then you can remove the symlink named `@jupytercad/jupytercad_freecad` within that folder.

### Packaging the extension

Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Making a new release of jupytercad-freecad
# Making a new release of jupytercad_freecad

The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).

Expand Down
4 changes: 2 additions & 2 deletions install.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packageManager": "python",
"packageName": "jupytercad-freecad",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupytercad-freecad"
"packageName": "jupytercad_freecad",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupytercad_freecad"
}
7 changes: 7 additions & 0 deletions jupyter-config/server-config/jupytercad_freecad.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"jupytercad_freecad": true
}
}
}
26 changes: 21 additions & 5 deletions jupytercad_freecad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,28 @@
# in editable mode with pip. It is highly recommended to install
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
import warnings
warnings.warn("Importing 'jupytercad-freecad' outside a proper installation.")

warnings.warn("Importing 'jupytercad_freecad' outside a proper installation.")
__version__ = "dev"
from .handlers import setup_handlers


def _jupyter_labextension_paths():
return [{
"src": "labextension",
"dest": "@jupytercad/jupytercad-freecad"
}]
return [{"src": "labextension", "dest": "@jupytercad/jupytercad-freecad"}]


def _jupyter_server_extension_points():
return [{"module": "jupytercad_freecad"}]


def _load_jupyter_server_extension(server_app):
"""Registers the API handler to receive HTTP requests from the frontend extension.
Parameters
----------
server_app: jupyterlab.labapp.LabApp
JupyterLab application instance
"""
setup_handlers(server_app.web_app)
name = "jupytercad_freecad"
server_app.log.info(f"Registered {name} server extension")
Loading

0 comments on commit 5987145

Please sign in to comment.