Skip to content

Commit 88f8252

Browse files
naveen521kkleotrs
andauthored
Move to Poetry (#165)
* Add necessary files and fix readme * remove poetry.lock * Change some things * Add Github action to Publish * Specify rich version - updates in setup.py * Add lock file * Add some docs about poetry * Add some docs and upgrade rich * remove Setup.py * Github Action using Poetry * Fix tests * Move to py 3.7 until poetry fixes it * Remove 3.6 * Looks like 3.6 works now * Fix Path for CI * Windows build * Add CI that actually works * Fix some spaces * Update docs and fix windows test * Fix windows run * Change some formatting -Docs Co-authored-by: Leo Torres <dleonardotn@gmail.com> * Some docs update * Change doc url Pyproject - Some formatting docs - change ci on release event * Change to manimlib CC. #165 (comment) * Some formatting changes * Merge branch 'master' of https://github.com/ManimCommunity/manim into poetry-change-new * Remove pytest.ini and Have a note in Readme * Update some docs * Update Authors field * Make readthedocs work Co-authored-by: Leo Torres <dleonardotn@gmail.com>
1 parent 5549576 commit 88f8252

File tree

11 files changed

+897
-56
lines changed

11 files changed

+897
-56
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ on:
1010
jobs:
1111
test:
1212
runs-on: ${{ matrix.os }}
13+
env:
14+
POETRY_VIRTUALENVS_CREATE: false
1315
strategy:
16+
fail-fast: false
1417
matrix:
1518
os: [ubuntu-latest, macos-latest, windows-latest]
16-
python: [3.6, 3.7, 3.8]
19+
python: [3.6,3.7, 3.8]
1720

1821
steps:
1922
- name: Checkout the repository
@@ -24,6 +27,11 @@ jobs:
2427
with:
2528
python-version: ${{ matrix.python }}
2629

30+
- name: Install Poetry
31+
run: |
32+
pip install wheel
33+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
34+
2735
- name: Get pip cache dir
2836
shell: bash
2937
id: pip-cache-and-time
@@ -43,6 +51,7 @@ jobs:
4351
sudo apt update
4452
sudo apt install -y ffmpeg
4553
sudo apt-get -y install texlive texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-fonts-extra tipa
54+
echo "::add-path::$HOME/.poetry/bin"
4655
4756
- name: Install system dependencies (MacOS)
4857
if: runner.os == 'macOS'
@@ -52,6 +61,7 @@ jobs:
5261
eval "$(/usr/libexec/path_helper -s)"
5362
sudo tlmgr update --self
5463
sudo tlmgr install standalone preview doublestroke relsize fundus-calligra wasysym physics dvisvgm.x86_64-darwin dvisvgm rsfs wasy cm-super
64+
echo "::add-path::$HOME/.poetry/bin"
5565
echo "::set-env name=PATH::$PATH"
5666
5767
- name: Cache Windows
@@ -80,7 +90,7 @@ jobs:
8090
Invoke-WebRequest "https://downloads.sourceforge.net/project/sox/sox/$($soxVersionNumber)/$($soxVersion).zip" -UserAgent "wget" -O "$($env:TMP)\SoX.zip"
8191
7z x "$($env:TMP)\SoX.zip" -o"$($PWD)\ManimCache"
8292
Move-Item "ManimCache\sox-*" "ManimCache\SoX"
83-
Invoke-WebRequest https://ffmpeg.zeranoe.com/builds/win64/static/$($ffmpegVersion).zip -O "$($env:TMP)\$($ffmpegVersion).zip"
93+
Invoke-WebRequest "https://ffmpeg.zeranoe.com/builds/win64/static/$($ffmpegVersion).zip" -O "$($env:TMP)\$($ffmpegVersion).zip"
8494
7z x "$($env:TMP)\$($ffmpegVersion).zip" -o"$($PWD)\ManimCache"
8595
Move-Item "ManimCache\ffmpeg-*" "ManimCache\FFmpeg"
8696
@@ -90,23 +100,15 @@ jobs:
90100
$env:Path += ";" + "$($PWD)\ManimCache\FFmpeg\bin"
91101
$env:Path += ";" + "$($PWD)\ManimCache\LatexWindows\TinyTeX\bin\win32"
92102
$env:Path += ";" + "$($PWD)\ManimCache\SoX"
103+
$env:Path = "$env:USERPROFILE\.poetry\bin;$($env:PATH)"
93104
echo "::set-env name=Path::$env:Path"
94105
95-
- name: Install Pycairo (Non-Windows)
96-
if: runner.os == 'macOS' || runner.os == 'Linux'
97-
run: pip install pycairo
98-
99-
- name: Install Pycairo (Windows)
100-
if: runner.os == 'Windows'
101-
run: python ./scripts/pycairoinstall.py
102-
103106
- name: Install manim
104107
run: |
105-
pip install wheel
106-
pip install . pytest
108+
poetry install
107109
108110
- name: Run tests
109-
run: pytest
111+
run: poetry run pytest
110112

111113
- name: Run module doctests
112-
run: pytest --doctest-modules manim
114+
run: poetry run pytest --doctest-modules manim
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
#TODO: Set an API key from PyPI `PYPI_API_KEY` in secrets tab.
13+
- name: Build and publish to pypi
14+
uses: JRubics/poetry-publish@v1
15+
with:
16+
pypi_token: ${{ secrets.PYPI_API_KEY }}

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![logo](logo/cropped.png)
1+
![logo](https://raw.githubusercontent.com/ManimCommunity/manim/master/logo/cropped.png)
22

33
![CI](https://github.com/ManimCommunity/manim/workflows/CI/badge.svg)
44
[![Documentation Status](https://readthedocs.org/projects/manimce/badge/?version=latest)](https://manimce.readthedocs.io/en/latest/?badge=latest)
@@ -55,18 +55,15 @@ manim example.py SquareToCircle -pl
5555

5656
You should see your video player pop up and play a simple scene where a square
5757
is transformed into a circle. You can find some more simple examples in the
58-
[GitHub
59-
repository](https://github.com/ManimCommunity/manim/tree/master/example_scenes).
60-
Visit the [official
61-
gallery](https://manimce.readthedocs.io/en/latest/examples.html) for more
62-
advanced examples.
58+
[GitHub repository](https://github.com/ManimCommunity/manim/tree/master/example_scenes).
59+
Visit the [official gallery](https://manimce.readthedocs.io/en/latest/examples.html) for more advanced examples.
6360

6461

6562
## Command line arguments
6663

6764
The general usage of manim is as follows:
6865

69-
![](./readme-assets/command.png)
66+
![manim-illustration](https://raw.githubusercontent.com/ManimCommunity/manim/master/readme-assets/command.png)
7067

7168
The `-p` flag in the command above is for previewing, meaning the video file will automatically open when it is done rendering. The `-l` flag is for a faster rendering at a lower quality.
7269

@@ -94,6 +91,8 @@ please open an issue.
9491
Is always welcome. In particular, there is a dire need for tests and
9592
documentation. For guidelines please see the
9693
[documentation](https://manimce.readthedocs.io/en/latest/contributing.html).
94+
This project uses [Poetry](https://python-poetry.org/docs/) for management. You need to have poetry installed and available in your environment.
95+
You can find more information about it in its [Documentation](https://manimce.readthedocs.io/en/latest/installation/for_dev.html)
9796

9897

9998
## License

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Sphinx==3.1.2
22
guzzle-sphinx-theme
33
recommonmark>=0.5.0
4-
-e git://github.com/ManimCommunity/manim/@master#egg=manim
4+
https://github.com/ManimCommunity/manim/archive/master.zip

docs/source/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Of interest to developers
8989
#. Added autogenerated documentation with sphinx and autodoc/autosummary [WIP]
9090
#. Made manim internally use relative imports
9191
#. Since the introduction of the :code:`TexTemplate` class, the files :code:`tex_template.tex` and :code:`ctex_template.tex` have been removed
92-
92+
#. Move to Poetry.
9393

9494
Other Changes
9595
--------------

docs/source/installation.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Installing dependencies
1515
installation/mac
1616
installation/linux
1717
installation/troubleshooting
18+
installation/for_dev
1819

1920

2021
.. _installing-manim:
@@ -50,8 +51,7 @@ cloned this repo, run the following:
5051

5152
.. code-block:: bash
5253
53-
python3 -m pip install -r requirements.txt
54-
python3 -m pip install -e .
54+
python3 -m pip install .
5555
5656
Please see :doc:`contributing` for more details about contributing to Manim.
5757

@@ -60,4 +60,5 @@ Please see :doc:`contributing` for more details about contributing to Manim.
6060
repository to your local device, please uninstall the pip-installed version
6161
of ``manim-community``, if you had installed it previously.
6262
This is to avoid any accidental usage of the pip-installed version when developing
63-
and testing on your local copy of the repository.
63+
and testing on your local copy of the repository. This warning doesn't apply for
64+
users who use [poetry](https://python-poetry.org).
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
Manim Installation For Developers
2+
=================================
3+
4+
This documentation is for developers who want to contribute to ``ManimCommunity/manim``.
5+
6+
Installing Poetry
7+
*****************
8+
9+
Poetry can be easily installed in any OS by just running the below command.
10+
11+
If your system has the ``curl`` program installed, which is usually true in Linux and Mac,
12+
13+
.. code-block:: bash
14+
15+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
16+
17+
18+
If you are a Windows developer and want to use PowerShell, you can use the below command.
19+
20+
.. code-block:: bash
21+
22+
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python
23+
24+
.. note:: Poetry can be installed by other ways also, such as with ``pip``. See `<https://python-poetry.org/docs/#alternative-installation-methods-not-recommended>`_.
25+
26+
It will add it to ``PATH`` variable automatically. In order to make sure you have poetry installed correctly, try running:
27+
28+
.. code-block:: bash
29+
30+
poetry --version
31+
32+
33+
.. note:: You may need to restart your shell in order for the changes to take effect.
34+
35+
See the `docs on installation python poetry for more information
36+
<https://python-poetry.org/docs/>`_.
37+
38+
Installing System Dependencies
39+
******************************
40+
41+
Please follow the instructions under :ref:`installing-manim` to install all dependencies. Then come back to this page to continue with the installation.
42+
43+
.. important:: Windows Users can skip the steps to install Pycairo.
44+
45+
46+
Additionally, ``git`` has to be installed. For instructions see `Documentation
47+
<https://git-scm.com/>`_.
48+
49+
.. _install-manim-poetry:
50+
51+
Installing Manim using Poetry
52+
*****************************
53+
54+
1. First, clone the Manim repo locally using git.
55+
56+
.. code-block:: bash
57+
58+
git clone https://github.com/ManimCommunity/manim.git
59+
60+
or
61+
62+
.. code-block:: bash
63+
64+
git clone git@github.com:ManimCommunity/manim.git
65+
66+
2. Open a Terminal/Powershell/Command Prompt and cd into the cloned directory.
67+
68+
.. code-block:: bash
69+
70+
cd path/to/manim
71+
72+
73+
.. note:: This path should contain a file called ``pyproject.toml`` if it doesn't contain it, you would need to go a level up.
74+
75+
3. Use the below command to install python dependencies. This will use the default python version installed.
76+
77+
.. code-block:: bash
78+
79+
poetry install
80+
81+
82+
.. note:: Poetry will create a virtual environment rooted at the current directory.
83+
84+
You can select the desired python version using
85+
86+
.. code-block:: bash
87+
88+
poetry env use <python version you need>
89+
90+
For example you can use for python 3.7.
91+
92+
.. code-block:: bash
93+
94+
poetry env use 3.7
95+
96+
For more information about this you can visit the `docs
97+
<https://python-poetry.org/docs/managing-environments/>`_.
98+
99+
4. Now you can activate the virtual environment ``Poetry`` has created by using the command below.
100+
101+
.. code-block:: bash
102+
103+
poetry shell
104+
105+
Or if you want to run a single command use
106+
107+
.. code-block:: bash
108+
109+
poetry run manim -h
110+
111+
Now you are free to start developing on the Manim Repository.
112+
113+
Running the Tests Using Poetry
114+
******************************
115+
116+
Once you are done with :ref:`install-manim-poetry`, you can run manim's test suite by activating a shell using ``poetry shell`` command and then running the command ``pytest`` to run the tests.
117+
118+
.. code-block:: bash
119+
120+
poetry shell
121+
pytest
122+
123+
.. important:: You should always run the test suite before making a PR. For other contributing guidelines, see `the guide for contributions to manim <../contributing.html>`_.
124+
125+
126+
Code Formatting Using Poetry
127+
****************************
128+
129+
Once you are done with :ref:`install-manim-poetry`, you can run the code formatter ``black`` by activating a shell using ``poetry shell`` and then running the command ``black manim``. Or alternatively just use the command ``poetry run black manim``.
130+
131+
.. code-block:: bash
132+
133+
poetry shell
134+
black
135+
136+
.. note:: Here, the word ``manim``, as used in the commands ``black manim`` or ``poetry run black manim``, refers to the folder which ``black`` is to format. You can also reformat the files containing the test suite by running the command ``black tests``.
137+
138+
For example, if you have written some new example and want to format it use the below command
139+
140+
.. code-block:: bash
141+
142+
poetry run black example_scenes
143+

0 commit comments

Comments
 (0)