ranjith
ranjith

Reputation: 71

How to start pyscaffold(python) project?

How to start the pyscaffold project? I use this command to create the project putup sampleProject but i don't know how to start this project?

Upvotes: 3

Views: 1879

Answers (3)

ieure
ieure

Reputation: 1

I also tried psp that I found it here: https://discuss.python.org/t/new-scaffolding-tool/59634/4, but the stable version: 1.0.0

This is that I obtain after psp and dream name command:

Welcome to PSP (Python Scaffolding Projects): 0.1.0
> Name of Python project: dream
> Do you want to create a virtual environment? Yes
> Do you want to start git repository? Yes
> Select git remote provider: None
> Do you want unit test files? Yes
> Install dependencies: flask pandas
> Select documentation generator: MKDocs
> Do you want to configure tox? Yes
> Select remote CI provider: None
> Do you want create common files? Yes
> Select license: MIT
> Do you want to install dependencies to publish on pypi? Yes
> Do you want to create a Dockerfile and Containerfile? Yes
Python project `dream` created at dream

The folder that contain my Python project:

tree dream --filelimit=18 -a
dream
├── CHANGES.md
├── CODE_OF_CONDUCT.md
├── Containerfile
├── CONTRIBUTING.md
├── Dockerfile
├── docs
│   └── index.md
├── dream
│   ├── __init__.py
│   └── __main__.py
├── .git
│   ├── branches
│   ├── config
│   ├── description
│   ├── HEAD
│   ├── hooks
│   │   ├── applypatch-msg.sample
│   │   ├── commit-msg.sample
│   │   ├── fsmonitor-watchman.sample
│   │   ├── post-update.sample
│   │   ├── pre-applypatch.sample
│   │   ├── pre-commit.sample
│   │   ├── pre-merge-commit.sample
│   │   ├── prepare-commit-msg.sample
│   │   ├── pre-push.sample
│   │   ├── pre-rebase.sample
│   │   ├── pre-receive.sample
│   │   ├── push-to-checkout.sample
│   │   ├── sendemail-validate.sample
│   │   └── update.sample
│   ├── info
│   │   └── exclude
│   ├── objects
│   │   ├── info
│   │   └── pack
│   └── refs
│       ├── heads
│       └── tags
├── .gitignore
├── LICENSE.md
├── Makefile
├── mkdocs.yml
├── pyproject.toml
├── README.md
├── requirements.txt
├── tests
│   ├── __init__.py
│   └── test_dream.py
├── tox.ini
└── venv
    ├── bin  [39 entries exceeds filelimit, not opening dir]
    ├── .gitignore
    ├── include
    │   └── python3.13
    ├── lib
    │   └── python3.13
    │       └── site-packages  [127 entries exceeds filelimit, not opening dir]
    ├── lib64 -> lib
    └── pyvenv.cfg

22 directories, 38 files

This in less than a minute. After this, I work immediately on my new project with git:

git status
On branch main

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        CHANGES.md
        CODE_OF_CONDUCT.md
        CONTRIBUTING.md
        Containerfile
        Dockerfile
        LICENSE.md
        Makefile
        README.md
        docs/
        dream/
        mkdocs.yml
        pyproject.toml
        requirements.txt
        tests/
        tox.ini

nothing added to commit but untracked files present (use "git add" to track)

And make is just configured for test and run:

make
help: make (help|test|run|clean)

make test
venv/bin/python3 -m unittest
Test all dream successfully!
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

make run
venv/bin/python3 -m dream
dream 0.0.1

make clean
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

And docker is the same thing:

docker build . -t dream:0.0.1
...
docker run --rm -it dream:0.0.1 python
Python 3.13.0 (main, Oct  8 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dream
>>> print(dream)
<module 'dream' from '/dream/dream/__init__.py'>
>>> print(dream.__version__)
0.0.1
>>>

Now, I'm ready to build and to distribute the package:

cat pyproject.toml
# Generated by psp (https://github.com/MatteoGuadrini/psp)

[build-system]
requires = ['setuptools', 'wheel']
build-backend = 'setuptools.build_meta'

[project]
name = 'dream'
version = '0.0.1'
readme = 'README.md'
license = {text = 'MIT License'}
authors = [{name = 'psp', email = '[email protected]'}]
maintainers = [{name = 'psp', email = '[email protected]'}]
description = 'A simple but structured Python project'
requires-python = '>=3.12'
classifiers = ["Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License"]
dependencies = ["flask", "pandas"]

[project.urls]
homepage = 'https://www.python.org/'
documentation = 'https://docs.python.org/3/'
repository = 'https://github.com/python'
changelog = 'https://docs.python.org/3/whatsnew/changelog.html'

pip -m build && twine upload dist/*

Nothing else to configure. As easy as drinking a glass of water!

Upvotes: 0

Kevinthecode
Kevinthecode

Reputation: 1

Another and new scaffolding tool for Python (and too much simple respect pyscaffold) is PSP: https://github.com/MatteoGuadrini/psp

It is Work In Progress yet...but is powerful!

I installed latest version and configure my projects in seconds.

Here a sample:

psp   # Press Enter
Welcome to PSP (Python Scaffolding Projects): 0.0.6
> Name of Python project: myprj
> Do you want to start git repository? Yes
> Do you want unit test files? Yes
> Do you want to create a virtual environment? Yes
> Install dependencies: scipy numpy
> Select CI provider: TravisCI
Project `myprj` created

Upvotes: -1

SteveJ
SteveJ

Reputation: 3323

You don't start a pyscaffold project per say -- Its goal is simply to create the files and folder that you will commonly need for your project. See my structure below from "putup MyTestProject". Look at all the nice stuff already created that you now don't have to do by hand.

To get started, you need to start adding packages/code to "..src/mytestproject" and run that code like you normally would.

Might I recommend for you the use of a good IDEA, such as pycharm? I think you will find it makes starting your journey much easier.

A second recommendation -- if you are just getting started, you might skip pyscaffold for now. While a great tool, it might add confusion that you don't need right now.

MyTestProject/
├── AUTHORS.rst
├── CHANGELOG.rst
├── docs
│   ├── authors.rst
│   ├── changelog.rst
│   ├── conf.py
│   ├── index.rst
│   ├── license.rst
│   ├── Makefile
│   └── _static
├── LICENSE.txt
├── README.rst
├── requirements.txt
├── setup.cfg
├── setup.py
├── src
│   └── mytestproject
│       ├── __init__.py
│       └── skeleton.py
└── tests
    ├── conftest.py
    └── test_skeleton.py

[Edit]

With respect to why "python skeleton.py" gives an output, the library is simply providing an example to show the user where to start adding code, and how the code relates to the tests (test_skeleton.py). The intent is that skeleton.py will be erased and replaced with your code structure. This may be some python.py files or packages and sub packages with python.py files. Read it this way; "Your Code goes here ... and here is an arbitrary example to get you started."

But you have to ask yourself what you are trying to accomplish? If you are just creating a few scripts for yourself -- for nobody else in the world to see, do you need the additional stuff (docs, setup, licensing, etc?) If the answer is no - don't use pyscaffold, just create your scripts in a venv and be on your way. This scaffolding is meant to give you most of what you need to create a full, github worthy, project to potentially share with the world. Based on what I gather your python experience to be, I don't think you want to use pyscaffold.

But specific to your question. Were I starting with pyscaffold, I would erase skeleton.py, replace it with "mytester.py", use the begins library to parse my incoming command arguments, then write individual methods to respond to my command line calls.

Upvotes: 7

Related Questions