How to create a new python project with projen
-
run
pj new python --name=kaito_model(pjis an alias fornpx projen) -
configure
.projenrc.pyby adding belowproject = PythonProject( ... homepage="", license=None, project_type=ProjectType.LIB, # or ProjectType.APP if this is not a library pip=False, venv=False, setuptools=False, poetry=True, poetry_options={ "repository": "https://github.com/MetaSearch-IO/KaitoModelPython.git", }, deps=[ "python@^3.9", ], )
Note that python dependency is required by poetry and the version should be at least 3.7
-
increase the version in
.projenrc.pyif necessary. -
setup the poetry environment by running
poetry env use <PATH_TO_PROJECT>/.env/bin/python3.9(or your desired python version)- see poetry docs for the exact env path.
- you may also need to change the IDE interpreter to the same path, otherwise the IDE will not be able to find the dependencies.
-
run
pj buildto install dependencies and generate artifacts. -
if not already, setup pypi main token by
poetry config pypi-token.pypi <main-token>, find main token in notion doc -
run
pj publishto upload a new version to pypi.
How to adopt projen to an existing python project
- run
pj new python, the script will recognize your project name and create a.projenrc.pyfile. - delete the content inside the newly created
<project-name>folder, move content fromsrc(or other folder name with existing source files) to<project-name>, and delete thesrcfolder. Move the test files to<project-name>/testsas well.- you may want to change the
module_namein.projenrc.py, note that only lowercase letters and underscores are allowed.
- you may want to change the
- refer to How to create a new python project with projen step 2 till the end, configure the
.projenrc.pyfile. - additionally, you need to base on the existing
setup.cfg(orrequirements.txt), add the dependencies to.projenrc.pyfile. Then delete thesetup.cfg(orrequirements.txt) file.
How to automate the release process
- create a project specific pypi token with
reposcope, and add it to the github secrets asPYPI_API_TOKEN. Or ask your admin to do it for you.
Bonus
How to enforce pre commit actions (for any language)
-
install pre-commit and add pre-commit to deps list.
-
create a pre-commit configuration file
.pre-commit-config.yamlsimilar to below# See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer exclude: ^\.* # Most dot files managed by projen and are read only - id: check-yaml - id: check-added-large-files
-
run
pre-commit install -
(optional) run
pre-commit autoupdateto update hooks to the latest version
How to run github actions locally
-
install act
-
(optional) create an act environment variables fle
.actenvwith extra env variables, some examples could beGITHUB_TOKEN=<your-github-token> PYPI_API_TOKEN=<your-pypi-token>
Note that act will try to load file
.envas environment variables, but it will not work because.envnow it's a virtual environment folder managed by projen. So we need to create a new file. -
run
act --env-file .actenvto run the github actions locally.- the first time run
actwill let you choose default image, you should choose at least Medium image. - make an alias for this command for easier use
alias act='act --env-file .actenv'
- the first time run
TODO: Run projen as pre-commit hook to ensure the project is up to date
TODO: Auto bump the version number
Metadata
Release files for kaito-model 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kaito_model-0.1.4.tar.gz | 10.7 kB | Without provenance | Details for kaito_model-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kaito_model-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for kaito_model-0.1.4-py3-none-any.whl |
Total release size: 22.4 kB
Release files / kaito_model-0.1.4.tar.gz
| Download URL | kaito_model-0.1.4.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81dc9be3ec3d0dc05864a1385fcf98a513fad414a7e8b9a936458d0c5729dde2
|
|
BLAKE2b-256 checksum How to use checksums |
7af23d18074c176d5968d4b3608bfa10270d70d6df756c8c7228daca3f6c84a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / kaito_model-0.1.4-py3-none-any.whl
| Download URL | kaito_model-0.1.4-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4888f478bdd8d61294fe14bac5d6888f5ffd19722a345da9109a46e2c56e5a89
|
|
BLAKE2b-256 checksum How to use checksums |
869b5327d0444131e5155a4bd476066459a3543aab7da1c0cfe2993fe4286e6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Security for kaito-model 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.