Skip to content

Added setuptools structure to enable installation #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pico-project-generator

This is a command line or GUI tool, written in Python, to automatically generate a Pico C SDK Project.
This is a command line or GUI tool, written in Python, to automatically generate a Raspberry Pi Pico C/C++ SDK Project.

The tool will generate all required CMake files, program files and VSCode IDE files for the set of features requested.

Expand Down Expand Up @@ -43,8 +43,6 @@ optional arguments:
You can list the features supported by the tools by using `./pico_project --list`. These features can
be added to the project using the `--feature` options, this can be used multiple times.



## GUI version

The GUI version of the tool, run by adding `--gui` to the command line, uses `tkinter` to provide a platform agnostic script that will run on Linux, Mac and Windows. All the options from the command line tool are also supported in the GUI.
Expand Down Expand Up @@ -77,10 +75,15 @@ Create VSCode Project | As well as the CMake files, also create the appropriate
Debugger | Use the specified debugger in the IDE


## Optional: Installation using Python Pip (Linux)

This application can **optionally** be installed to your system using standard Python installation tools. If you would like to do so, follow the instructions below. If you do not wish to install the application, you can run it from the the pico_project directory.

Clone the repository with: `$ git clone https://github.com/raspberrypi/pico-project-generator`. Change to the repository's directory with: `$ cd pico-project-generator`.

The package can then be installed for the current user using: `$ pip install .`, or for all users using `$ sudo pip install .`.

You can now run the application from any directory with `$ pico_project` plus any arguments detailed in this README, e.g. `$ pico_project --gui`.


The package can be uninstalled with `$ pip uninstall pico-project-generator`.

File renamed without changes
File renamed without changes.
101 changes: 55 additions & 46 deletions pico_project.py → pico_project/pico_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,13 @@ def CheckSDKPath(gui):


def ParseCommandLine():
# default tsv file location is in this python module's directory
this_module_location = os.path.dirname(os.path.realpath(__file__))
default_tsv_file = os.path.join(this_module_location, "pico_configs.tsv")

parser = argparse.ArgumentParser(description='Pico Project generator')
parser.add_argument("name", nargs="?", help="Name of the project")
parser.add_argument("-t", "--tsv", help="Select an alternative pico_configs.tsv file", default="pico_configs.tsv")
parser.add_argument("-t", "--tsv", help="Select an alternative pico_configs.tsv file", default=default_tsv_file)
parser.add_argument("-o", "--output", help="Set an alternative CMakeList.txt filename", default="CMakeLists.txt")
parser.add_argument("-x", "--examples", action='store_true', help="Add example code for the Pico standard library")
parser.add_argument("-l", "--list", action='store_true', help="List available features")
Expand Down Expand Up @@ -1201,70 +1205,75 @@ def DoEverything(parent, params):

###################################################################################
# main execution starteth here
def main():
global args
args = ParseCommandLine()

args = ParseCommandLine()

if args.nouart:
args.uart = False
if args.nouart:
args.uart = False

# TODO this could be better, need some constants etc
if args.debugger > 1:
args.debugger = 0
if args.debugger > 1:
args.debugger = 0

# Check we have everything we need to compile etc
c = CheckPrerequisites()
c = CheckPrerequisites()

## TODO Do both warnings in the same error message so user does have to keep coming back to find still more to do

if c == None:
m = 'Unable to find the `' + COMPILER_NAME + '` compiler\n'
m +='You will need to install an appropriate compiler to build a Raspberry Pi Pico project\n'
m += 'See the Raspberry Pi Pico documentation for how to do this on your particular platform\n'
if c == None:
m = 'Unable to find the `' + COMPILER_NAME + '` compiler\n'
m +='You will need to install an appropriate compiler to build a Raspberry Pi Pico project\n'
m += 'See the Raspberry Pi Pico documentation for how to do this on your particular platform\n'

if (args.gui):
RunWarning(m)
else:
print(m)
sys.exit(-1)
if (args.gui):
RunWarning(m)
else:
print(m)
sys.exit(-1)

if args.name == None and not args.gui and not args.list and not args.configs:
print("No project name specfied\n")
sys.exit(-1)
if args.name == None and not args.gui and not args.list and not args.configs:
print("No project name specfied\n")
sys.exit(-1)

# load/parse any configuration dictionary we may have
LoadConfigurations()
LoadConfigurations()

p = CheckSDKPath(args.gui)
p = CheckSDKPath(args.gui)

if p == None:
sys.exit(-1)
if p == None:
sys.exit(-1)

sdkPath = Path(p)
sdkPath = Path(p)

if args.gui:
RunGUI(sdkPath, args) # does not return, only exits
if args.gui:
RunGUI(sdkPath, args) # does not return, only exits

projectRoot = Path(os.getcwd())
projectRoot = Path(os.getcwd())

if args.list or args.configs:
if args.list:
print("Available project features:\n")
for feat in features_list:
print(feat.ljust(6), '\t', features_list[feat][GUI_TEXT])
print('\n')
if args.list or args.configs:
if args.list:
print("Available project features:\n")
for feat in features_list:
print(feat.ljust(6), '\t', features_list[feat][GUI_TEXT])
print('\n')

if args.configs:
print("Available project configuration items:\n")
for conf in configuration_dictionary:
print(conf['name'].ljust(40), '\t', conf['description'])
print('\n')
if args.configs:
print("Available project configuration items:\n")
for conf in configuration_dictionary:
print(conf['name'].ljust(40), '\t', conf['description'])
print('\n')

sys.exit(0)
else :
p = Parameters(sdkPath=sdkPath, projectRoot=projectRoot, projectName=args.name,
gui=False, overwrite=args.overwrite, build=args.build, features=args.feature,
projects=args.project, configs=(), runFromRAM=args.runFromRAM,
examples=args.examples, uart=args.uart, usb=args.usb, cpp=args.cpp, debugger=args.debugger, exceptions=args.cppexceptions, rtti=args.cpprtti)

DoEverything(None, p)

sys.exit(0)
else :
p = Parameters(sdkPath=sdkPath, projectRoot=projectRoot, projectName=args.name,
gui=False, overwrite=args.overwrite, build=args.build, features=args.feature,
projects=args.project, configs=(), runFromRAM=args.runFromRAM,
examples=args.examples, uart=args.uart, usb=args.usb, cpp=args.cpp, debugger=args.debugger, exceptions=args.cppexceptions, rtti=args.cpprtti)

DoEverything(None, p)
if __name__ == "__main__":
main()

30 changes: 30 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import setuptools

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

setuptools.setup (
name = "pico-project-generator",
version = "0.1",
description = "Console and GUI C project generator for the Raspberry Pi Pico",
long_description = long_description,
long_description_content_type = "text/markdown",
url = "https://github.com/raspberrypi/pico-project-generator",
classifiers=[
"Programming Language :: Python :: 3",
"Topic :: Software Development",
"Topic :: Software Development :: Code Generators",
"Topic :: Software Development :: Embedded Systems",
],
python_requires = '>=3.6',
package_data = {
'pico_project': ['logo_alpha.gif', 'pico_configs.tsv']
},
packages = ["pico_project"],
entry_points = {
'console_scripts': [
'pico_project=pico_project.pico_project:main',
],
}
)