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

Add Python packaging #1

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/python-publish.yml
@@ -0,0 +1,31 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
# Python packaging generated files
/dist
*.egg-info
2 changes: 2 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,2 @@
include LICENSE
graft jupyter_threejs_sage/static
19 changes: 17 additions & 2 deletions README.md
@@ -1,7 +1,14 @@

# Custom build of Three.js for SageMath

The steps to create this build from a stable tagged version are
This package provides a single minified Javascript file `three.min.js`, which combines
standard Three.js with a number of scripts from `examples/jsm/`.

The file is made available both as package data of a Python package `jupyter_threejs_sage` (for local access by SageMath) and as a Jupyter notebook extension (to be installed in the Jupyter notebook's Python environment).

# Development

The steps to create this build from a stable tagged version of Three.js are

* Perform a shallow clone of the desired version with

Expand All @@ -24,6 +31,14 @@ export { LineSegmentsGeometry } from '../examples/jsm/lines/LineSegmentsGeometry

* Build the library with `npm run build`

The minified file will be located in the `build` directory and has been copied to the same directory here. The final step before releasing is to update the `version` file with the new number.
The minified file `three.min.js` will be located in the `build` directory.

* Copy the minified file to the `build` directory here.

* Create a new directory for the new version in `jupyter_threejs_sage/static/` and copy the minified file there.
(Do not remove old versions that needed by any released versions of Sage.)

* The final step before releasing is to update the `version` file.


As noted in [this issue](https://github.com/mrdoob/three.js/issues/20591), Three.js releases can be modified for up to a week after the initial release. This build process should wait for this period of time to ensure future consistency of building.
Empty file.
2 changes: 2 additions & 0 deletions jupyter_threejs_sage/static/r122/three.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions jupyter_threejs_sage/static/r123/three.min.js

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions setup.cfg
@@ -0,0 +1,28 @@
[metadata]
name = jupyter-threejs-sage
description = Sage: Open Source Mathematics Software: Jupyter extension for 3D graphics with threejs
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/sagemath/threejs-sage
license = MIT License
author = The Sage Developers
author_email = sage-support@googlegroups.com
classifiers =
Development Status :: 6 - Mature
Intended Audience :: Developers
Intended Audience :: System Administrators
Intended Audience :: Science/Research
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Framework :: Jupyter

[options]
zip_safe = False
include_package_data = True
packages =
jupyter_threejs_sage

[options.package_data]
jupyter_threejs_sage = jupyter_threejs_sage/static
15 changes: 15 additions & 0 deletions setup.py
@@ -0,0 +1,15 @@
from setuptools import setup
import os

with open('version') as f:
package_version_without_r = f.read()[1:]

versions = [ x for x in os.listdir('jupyter_threejs_sage/static') if x.startswith('r') ]

setup(
version=package_version_without_r,
data_files = [(
f'share/jupyter/nbextensions/threejs-sage/{version}', [
f'jupyter_threejs_sage/static/{version}/three.min.js'
]) for version in versions]
)