sphinx-copybutton
sphinx-copybutton copied to clipboard
Add copy button to Gitlab
Describe the problem
In Gitlab I have the following .gitlab-ci.yml file:
image: python
before_script:
- apt-get update -y
- apt-get install -y pandoc
pages:
stage: deploy
script:
- pip install numpy ipykernel
- pip install sphinx furo nbsphinx
- mkdir -p doc; cd doc
- pip install sphinx-copybutton
- sphinx-build -b html source ../public/
- echo 'Done'
artifacts:
paths:
- public
only:
- master
And in conf.py I added:
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'nbsphinx',
'sphinx-copybutton'
]
When I now run the workflow to deploy the site from Gitlab Pages, I get this error:
$ pip install sphinx-copybutton
Collecting sphinx-copybutton
Downloading sphinx_copybutton-0.4.0-py3-none-any.whl (12 kB)
Requirement already satisfied: sphinx>=1.8 in /usr/local/lib/python3.9/site-packages (from sphinx-copybutton) (4.1.2)
Requirement already satisfied: babel>=1.3 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (2.9.1)
Requirement already satisfied: sphinxcontrib-serializinghtml>=1.1.5 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (1.1.5)
Requirement already satisfied: Pygments>=2.0 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (2.9.0)
Requirement already satisfied: docutils<0.18,>=0.14 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (0.17.1)
Requirement already satisfied: Jinja2>=2.3 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (3.0.1)
Requirement already satisfied: alabaster<0.8,>=0.7 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (0.7.12)
Requirement already satisfied: requests>=2.5.0 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (2.26.0)
Requirement already satisfied: sphinxcontrib-devhelp in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (1.0.2)
Requirement already satisfied: packaging in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (21.0)
Requirement already satisfied: imagesize in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (1.2.0)
Requirement already satisfied: sphinxcontrib-jsmath in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (1.0.1)
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (57.4.0)
Requirement already satisfied: sphinxcontrib-applehelp in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (1.0.2)
Requirement already satisfied: sphinxcontrib-htmlhelp>=2.0.0 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (2.0.0)
Requirement already satisfied: sphinxcontrib-qthelp in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (1.0.3)
Requirement already satisfied: snowballstemmer>=1.1 in /usr/local/lib/python3.9/site-packages (from sphinx>=1.8->sphinx-copybutton) (2.1.0)
Requirement already satisfied: pytz>=2015.7 in /usr/local/lib/python3.9/site-packages (from babel>=1.3->sphinx>=1.8->sphinx-copybutton) (2021.1)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.9/site-packages (from Jinja2>=2.3->sphinx>=1.8->sphinx-copybutton) (2.0.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests>=2.5.0->sphinx>=1.8->sphinx-copybutton) (1.26.6)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests>=2.5.0->sphinx>=1.8->sphinx-copybutton) (3.2)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests>=2.5.0->sphinx>=1.8->sphinx-copybutton) (2021.5.30)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.9/site-packages (from requests>=2.5.0->sphinx>=1.8->sphinx-copybutton) (2.0.4)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.9/site-packages (from packaging->sphinx>=1.8->sphinx-copybutton) (2.4.7)
Installing collected packages: sphinx-copybutton
Successfully installed sphinx-copybutton-0.4.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
$ sphinx-build -b html source ../public/
Running Sphinx v4.1.2
Extension error:
Could not import extension sphinx-copybutton (exception: No module named 'sphinx-copybutton')
Link to your repository or website
No response
Steps to reproduce
Creating this .gitlab-ci.yml in a Gitlab repo and run a sphinx project.
The version of Python you're using
python3.9
Your operating system
No response
Versions of your packages
No response
Additional context
No response
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Try sphinx_copybutton with an underscore
sphinx_copybutton with an underscore, solved the problem, thanks a lot!🎉🎉🎉
As this was a copy-paste error that also other people might do, is it possible to add a warning like:
Extension error:
Could not import extension sphinx-copybutton (exception: No module named 'sphinx-copybutton')
Did you mean 'sphinx_copybutton' ?
That sounds more like an enhancement to suggest for Sphinx itself. A Sphinx extension can't apply logic before it has been loaded (just like if you are writing a Python module mymodule.py, you cannot make the Python interpreter suggest the name mymodule if the user wrote import mymodle).
Agree - I'll close this one