Skip to content

Commit

Permalink
Don't require npm to build from source
Browse files Browse the repository at this point in the history
We already have this scripts in package.json,
and we commit the static files in the repo.

Close #1014
  • Loading branch information
stsewd committed Jan 20, 2021
1 parent 5d0a396 commit e13aded
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 50 deletions.
4 changes: 3 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
version: 2

python:
version: 3
version: 3.8
install:
- requirements: docs/requirements.txt
- method: pip
path: .

sphinx:
configuration: docs/conf.py
17 changes: 11 additions & 6 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,25 @@ To release a new version of the theme, core team will take the following steps:
#. New versions are by default ``alpha`` releases. If this is a release candidate,
run ``bump2version --allow-dirty release`` to update the release to an ``rc``
release. If this is a final release, run the command again.
#. Update the static files

.. code:: bash
npm install
npm run build
#. Update the changelog (``docs/changelog.rst``) with the version information.
#. Run ``python setup.py update_translations`` to compile new translation files
and update Transifex.
#. Run ``python setup.py build`` to rebuild all the theme assets and the Python
package.
#. Commit these changes.
#. Tag the release in git: ``git tag $NEW_VERSION``.
#. Push the tag to GitHub: ``git push --tags origin``.
#. Upload the package to PyPI:

.. code:: console
.. code:: console
$ rm -rf dist/
$ python setup.py sdist bdist_wheel
$ twine upload --sign --identity [email protected] dist/*
$ rm -rf dist/
$ python setup.py sdist bdist_wheel
$ twine upload --sign --identity [email protected] dist/*
.. _PEP440: https://www.python.org/dev/peps/pep-0440/
54 changes: 11 additions & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
# -*- coding: utf-8 -*-
"""`sphinx_rtd_theme` lives on `Github`_.
.. _github: https://github.com/readthedocs/sphinx_rtd_theme
"""

import distutils.cmd
import os
import subprocess
import distutils.cmd
import setuptools.command.build_py
from io import open
from setuptools import setup


class WebpackBuildCommand(setuptools.command.build_py.build_py):

"""Prefix Python build with Webpack asset build"""

def run(self):
if not 'CI' in os.environ and not 'TOX_ENV_NAME' in os.environ:
subprocess.run(['npm', 'install'], check=True)
subprocess.run(['node_modules/.bin/webpack', '--config', 'webpack.prod.js'], check=True)
setuptools.command.build_py.build_py.run(self)


class WebpackDevelopCommand(distutils.cmd.Command):

description = "Run Webpack dev server"

user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
subprocess.run(
["node_modules/.bin/webpack-dev-server", "--open", "--config", "webpack.dev.js"],
check=True
)
import setuptools.command.build_py
from setuptools import setup


class UpdateTranslationsCommand(distutils.cmd.Command):
Expand Down Expand Up @@ -95,8 +60,6 @@ def run(self):
cmdclass={
'update_translations': UpdateTranslationsCommand,
'transifex': TransifexCommand,
'build_py': WebpackBuildCommand,
'watch': WebpackDevelopCommand,
},
zip_safe=False,
packages=['sphinx_rtd_theme'],
Expand Down Expand Up @@ -137,12 +100,17 @@ def run(self):
'Intended Audience :: Developers',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Operating System :: OS Independent',
'Topic :: Documentation',
'Topic :: Software Development :: Documentation',
],
project_urls={
'Homepage': 'https://sphinx-rtd-theme.readthedocs.io/',
'Source Code': 'https://github.com/readthedocs/sphinx_rtd_theme',
'Issue Tracker': 'https://github.com/readthedocs/sphinx_rtd_theme/issues',
},
)

0 comments on commit e13aded

Please sign in to comment.