pyscaffold | 🛠Python project template generator with batteries | Automation library
kandi X-RAY | pyscaffold Summary
kandi X-RAY | pyscaffold Summary
🛠Python project template generator with batteries included
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Adds default arguments to an argument parser .
- Create a scaffold opts .
- Check if a given pathname is valid .
- Create a new project .
- Apply a function to a struct .
- Get a template from the given name .
- Registers a new action .
- Get default options .
- Define a structure .
- Logs an activity .
pyscaffold Key Features
pyscaffold Examples and Code Snippets
├── AUTHORS.md <- List of developers and maintainers.
├── CHANGELOG.md <- Changelog to keep track of new features and fixes.
├── LICENSE.txt <- License as chosen on the command-line.
├── README.md
class AccountAPITestCase(TestCase):
def setUp(self):
pass
def test_create_account(self):
data = {
"email": "snifter@gmail.com",
"display_name": "outrageous canteloupe",
"passwo
Community Discussions
Trending Discussions on pyscaffold
QUESTION
I wanted to write a new Python package that I want to make available via PyPI.
In the past I always used setup.py
. But this time I decided to embrace new
best practices of using setup.cfg
instead. So I started reading a little bit of the documentation, mainly
https://setuptools.pypa.io/en/latest/userguide/declarative_config.html.
I also decided to use pyscaffold for the generation of the files.
pyscaffold generated a setup.cfg
file for me and I added (just for testing
purposes) version = 5.1.1
in under the metadata
section, as described in the
documentation above.
For convenience I'm using anaconda and created a new empty environment:
...ANSWER
Answered 2021-Nov-06 at 14:48That's because pyscaffold
generated a project that uses setuptools-scm
for version detection. When setuptools-scm
is used, the version is not read from version
metadata, but parsed from the repository tags. The version 0.0.post1.dev10+g3ed39c8.d20211106
can be read as follows:
0.0.post1
- dummy version since you don't have any tags in repo yet;dev10
- you have ten commits that are not included in any version tag (basically the amount of commits you made since tagging last);g3ed39c8
- the short hash of commit you have installed from is3ed39c8
(prefixg
means it is a Git repo);d20211106
-d
means you have installed from a dirty state (some files versioned by Git were modified), the rest is just the timestamp.
If you want to use the version metadata from setup.cfg
instead, just drop setuptools-scm
activation in setup.py
:
QUESTION
I have just scaffolded a python project using PyScaffold. One thing that has caught my attention was the fact that the scaffolding generated both setup.cfg and tox.ini files. If my understanding is correct, if I were to use tox using the tox
command, it would just look at the tox.ini file and ignore setup.cfg and setup.py altogether.
With this being the case, here is my question: is there a reason to keep both of them in the project, or would just using tox.ini or setup.cfg be enough? And if I have to keep both of them in my project, is there an easy way so both of them use the same configurations (e.g. configurations for running flake8 for linting) without me having to type those configurations in both setup.cfg and tox.ini?
...ANSWER
Answered 2021-Apr-15 at 06:27Let's go through this step by step.
PyScaffold
is a tool which tries to ease the setup of a new Python project.
What even is a Python project?
At the very heart a single executable Python file is enough.
If you want to make the project being installable, you need configuration file for the build system.
While a lot has changed over time, still setup.py
is the most prominent one. At some point in time it was figured out, that it may be not such a great idea that the build configuration file could execute arbitrary code, so setup.cfg
was invented, where you can define e.g. the projects name and dependencies in a ini-style format. Meanwhile, another format was invented, the pyproject.toml
file.
So basically, to build your project you need one of those:
- setup.py
- setup.py and setup.cfg (the former only calls the latter)
- pyproject.toml
Usually you want to write tests for your project. You could use the builtin unittest
testrunner to run your tests, or nowadays many projects use pytest
. pytest
can be configured with a pytest.ini
.
Tests usually need some dependencies, e.g. pytest
itself and maybe some other test helpers. They need to be installed at some time.
And here comes tox
into play. Amongst many other features, like e.g. running your tests against different Python versions, tox
can both install your project and your test requirements and execute the tests. tox
usually comes with a tox.ini
file.
Oh, and what about linting? You want to have easy to read code and follow the Python guidelines (e.g. PEP 8), so you usually use a tool like flake8
- which also comes with its own configuration file, namely .flake8
.
Ok, now we have many tools and many configuration files, but that's not all. As not everybody likes so many configuration files, some of the tools support to be configured with other tools's configuration file.
e.g. you can configure flake8
both in a setup.cfg
and a tox.ini
, see https://flake8.pycqa.org/en/latest/user/configuration.html
You can also configure tox
via setup.cfg
or pyproject.toml
, see https://tox.readthedocs.io/en/latest/config.html#configuration-discovery
And one important thing to know: You only need to configure your tool once, not in all those files.
So, technically, you do not need all those files, and it is up to you what you think is an easy to read and easy to manage setup for your project.
At a past Python Ireland meetup I gave a 5 minute lightning talk about how this is all confusing and what solution I came up with:
QUESTION
I used PyScaffold to create a template for a PyPi package I am creating, bbox-utils
. The generated __init__.py
is as follows:
ANSWER
Answered 2021-Jan-12 at 17:00You generally should not name your packages or modules using dashes although you can. Since the import statement does not use quotes, using a dash is interpreted as using a minus sign, which will result in an illegal syntax during import if using the dash name.
There are ways around this, such as importing with underscores but installing via pip/searching pypi with dashes, but it is a needless inconsistency that can cause frustration. Generally the python approach is to be able to import modules as valid module objects whose variable name equals the actual module name. When naming projects, it is therefore better to use underscores instead of dashes.
That being said, pkg_resources seems to actually replace all non-alphanumeric and non-dot characters with dashes when resolving project names.
QUESTION
I setup my project using PyScaffold and while running unit tests using pytest I get the following third party warning that I'd like to get rid of but don't know how:
...ANSWER
Answered 2020-Mar-25 at 17:10There are multiple ways to suppress warnings:
- using command-line arguments
To hide the warning completely use
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pyscaffold
You can use pyscaffold like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page