Please consider this an initial iteration or proof-of-concept. There is certainly more work to be done to really wrap this up and make it something maintainable. Before we move forward with this, it would probably be a good idea for us to get together (mdwheele@ncsu.edu) to make sure this actually works. I don't have any hardware to test this on and you're the best judge of whether or not things are working as intended.
I need to write a Makefile you can use to build and upload archives to PyPi, but here's the gist:
# See: https://packaging.python.org/tutorials/packaging-projects
# Once you've installed all dependencies above and
# registered an account with pypi.org...
# Build distributed archive...
$ python3 setup.py sdist bdist_wheel
# Upload to PyPi using twine...
$ python3 -m twine upload dist/*
Enter your username: mdwheele
Enter your password:
Uploading distributions to https://upload.pypi.org/legacy/
Uploading linux_drivers-0.0.3-py3-none-any.whl
View at:
https://pypi.org/project/linux-drivers/0.0.3/
I picked a name arbitrarily, but we can change that to whatever you like. If we change it, we'll just destroy what's already on PyPi.
The work basically boils down to these requirements:
Restructure the project to separate C from Python. Python packages are expected to follow a standard structure. Because the project was organized by function, rather than language, it made it difficult to apply normal packaging procedures.
The project needed a setup.py configuration. The setup.py configuration calls setuptools.setup to define details about your package including: package name, description, version, where to find packages within the source code and dependencies. It is used during the build process to produce a distributed archive that is uploaded to PyPi.
Once project was restructured, module references needed to be updated.. When you run Python code interactively, you can reference modules relative to the current script. When you package code into modules that are expected to be run from anywhere, you have to take care to reference the full module path.
Things left to do:
[ ] We should write some documentation for how to install the package along with some basic usage instructions (an example of USB, Ethernet and Bluetooth would be good).
[ ] We need to document and/or automate the release process. This is something you'll have to manage periodically because what's on PyPi as a versioned release is not necessarily what's available on GitHub (i.e. it will be behind, usually).
[ ] Make sure I didn't break anything and that you can still work with the C project as well as this Python code. Depending on your preference, it may be a good idea to split the C and Python code into separate repositories. However, just having top-level directories is good enough for now.
[ ] We should add an open-source license to the project. The MIT License is a good choice (it's what I use, by default).
Hey @wjasper!
:tipping_hand_woman: This PR makes structural changes to the project to allow for packaging of your Python drivers on PyPi.
Related: https://pypi.org/project/linux-drivers Project Layout: https://github.com/mdwheele/Linux_Drivers/tree/pypi-packaging
Please consider this an initial iteration or proof-of-concept. There is certainly more work to be done to really wrap this up and make it something maintainable. Before we move forward with this, it would probably be a good idea for us to get together (
mdwheele@ncsu.edu
) to make sure this actually works. I don't have any hardware to test this on and you're the best judge of whether or not things are working as intended.I need to write a
Makefile
you can use to build and upload archives to PyPi, but here's the gist:I picked a name arbitrarily, but we can change that to whatever you like. If we change it, we'll just destroy what's already on PyPi.
The work basically boils down to these requirements:
setup.py
configuration. Thesetup.py
configuration callssetuptools.setup
to define details about your package including: package name, description, version, where to find packages within the source code and dependencies. It is used during the build process to produce a distributed archive that is uploaded to PyPi.Things left to do: