Packaging Rust with pip
In this section, we will be setting up our pip
package so that it can utilize Rust code. This will enable us to use Python setup tools to import our Rust pip
package, compile it for our system, and use it within our Python code. For this chapter, we are essentially building the same Fibonacci module that we built in Chapter 4, Building pip Modules in Python. It is advised to create another GitHub repository for our Rust module; however, nothing is stopping you from refactoring your existing Python pip
module. To build our Rust pip
module, we are going to have to carry out the following steps:
- Define
gitignore
andCargo
for our package. - Configure a Python setup process for our package.
- Create a Rust library for our package.
Define gitignore and Cargo for our package
To get started, we must make sure that our Git does not track files that we do not want to upload and that our Cargo
has the right dependencies with step 1.
- First...