A modern Python build backend

Overview

trampolim

test codecov check Documentation Status PyPI version

A modern Python build backend.

Features

  • Task system, allowing to run arbitrary Python code during the build process (Planned)
  • Easy to use CLI -- build, publish, check for errors and recommended practices (Planned)
  • Automatic version detection from git repos and git archives

Usage

trampolim implements PEP 621. Your pyproject.toml should look something like this:

[build-system]
build-backend = 'trampolim'
requires = ['trampolim~=0.0.1']

[project]
name = 'sample_project'
version = '1.0.0'
description = 'A sample project'
readme = 'README.md'
requires-python = '>=3.7'
license = { file = 'LICENSE' }
authors = [
  { name = 'Filipe Laíns', email = '[email protected]' },
]
classifiers = [
  'Development Status :: 4 - Beta',
  'Programming Language :: Python',
]

dependencies = [
  'dependency',
  'some-backport ; python_version < "3.8"',
]

[project.optional-dependencies]
test = [
  'pytest',
  'pytest-cov',
]

[project.scripts]
sample_entrypoint = 'sample_project:entrypoint_function'

[project.urls]
homepage = 'https://my-sample-project-website.example.com'
documentation = 'https://github.com/some-user/sample-project'
repository = 'https://github.com/some-user/sample-project'
changelog = 'https://github.com/some-user/sample-project/blob/master/CHANGELOG.rst'
Comments
  • Support for src structure

    Support for src structure

    Src structure has some important benefits. Running something like pytest needs /src structure or otherwise it loads from the local folder instead. If you have compiled extensions, or if you use importlib stuff, it's critical to load the installed package, not the local folder. See, for example, https://github.com/scikit-build/cmake-python-distributions/pull/145, which was motivated by https://github.com/scikit-build/cmake-python-distributions/pull/139#issuecomment-843507505 for an example of problems in the wild.

    However, not having editable support for now makes it a bit less attractive, since regular layout can run without installing in a pinch (if you avoid things like importlib), so maybe it would be best to wait till editable support is available (maybe best to use PEP 517 editable mode if it comes? PEP 660 or 662, whichever is accepted).

    enhancement 
    opened by henryiii 7
  • Version 0.0.4 doesn't support dynamic version

    Version 0.0.4 doesn't support dynamic version

    Upgrading to 0.0.4 breaks the dynamic version using TRAMPOLIM_VCS_VERSION:

    Processing /Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/tmp/cookie-trampolim
      DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
       pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Installing backend dependencies: started
      Installing backend dependencies: finished with status 'done'
        Preparing wheel metadata: started
        Preparing wheel metadata: finished with status 'error'
        ERROR: Command errored out with exit status 1:
         command: /Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/bin/python /Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpbyha2ong
             cwd: /private/tmp/pip-req-build-cqa182lv
        Complete output (23 lines):
        Traceback (most recent call last):
          File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 143, in prepare_metadata_for_build_wheel
            hook = backend.prepare_metadata_for_build_wheel
        AttributeError: module 'trampolim' has no attribute 'prepare_metadata_for_build_wheel'
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
          File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
            main()
          File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
          File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/tests-trampolim/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 147, in prepare_metadata_for_build_wheel
            whl_basename = backend.build_wheel(metadata_directory, config_settings)
          File "/private/tmp/pip-build-env-osr5lkga/overlay/lib/python3.9/site-packages/trampolim/__init__.py", line 62, in build_wheel
            builder.build(wheel_directory)
          File "/private/tmp/pip-build-env-osr5lkga/overlay/lib/python3.9/site-packages/trampolim/_wheel.py", line 38, in build
            whl.writestr(f'{whl.dist_info_path}/METADATA', bytes(self._project._meta.as_rfc822()))
          File "/private/tmp/pip-build-env-osr5lkga/overlay/lib/python3.9/site-packages/pep621.py", line 243, in as_rfc822
            self.write_to_rfc822(message)
          File "/private/tmp/pip-build-env-osr5lkga/overlay/lib/python3.9/site-packages/pep621.py", line 250, in write_to_rfc822
            raise ConfigurationError('Missing version field')
        pep621.ConfigurationError: Missing version field
    

    See https://github.com/scikit-hep/cookie/pull/41/checks?check_run_id=3804995613

    Pinning to trampolim 0.0.3 fixes the issue.

    opened by henryiii 6
  • ci: support mypy 0.9xx

    ci: support mypy 0.9xx

    I'd recommend running mypy from pre-commit (or maybe something like nox) as it's very important to fully control MyPy's environment, and usually nice to have it pinned as well (say with pre-commit). (See the recommendation here, for an example: https://scikit-hep.org/developer/style#type-checking )

    opened by henryiii 4
  • Exactly sitting on a tag fails

    Exactly sitting on a tag fails

    This line breaks when this matches a tag exactly (which it usually should do if you are building wheels and SDists for publication?)

    https://github.com/FFY00/trampolim/blob/f3e8db8dea5607f708208b57de0d8bc49348a9d1/trampolim/_build.py#L290

    $ git describe --tags
    v0.1.0
    

    You want --long to force the commits since tag and current hash. Or you should check to see if -'s are present, then assume it's exactly a release then.

    $ git describe --tags --long
    v0.1.0-0-g165f120
    

    Example failure from a nox run using scikit-hep/cookie:

    nox -s 'dist(trampolim)'
    nox > Running session dist(trampolim)
    nox > Creating virtual environment (virtualenv) using python3.9 in .nox/dist-trampolim
    nox > python -m pip install cookiecutter build twine
    nox > cd .nox/dist-trampolim/tmp
    nox > cookiecutter --no-input /Users/henryschreiner/git/scikit-hep/cookie --config-file=input.yml
    nox > cd cookie-trampolim
    nox > git init -q
    nox > git add .
    nox > git commit -qm feat: initial version
    nox > git tag v0.1.0
    nox > python -m build
    nox > Command python -m build failed with exit code 1:
    Found existing installation: setuptools 57.0.0
    Uninstalling setuptools-57.0.0:
      Successfully uninstalled setuptools-57.0.0
    Collecting trampolim~=0.0.3
      Using cached trampolim-0.0.3-py3-none-any.whl (13 kB)
    Collecting packaging
      Using cached packaging-21.0-py3-none-any.whl (40 kB)
    Collecting toml
      Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
    Collecting pyparsing>=2.0.2
      Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
    Installing collected packages: pyparsing, toml, packaging, trampolim
    Successfully installed packaging-21.0 pyparsing-2.4.7 toml-0.10.2 trampolim-0.0.3
    Traceback (most recent call last):
      File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 280, in <module>
        main()
      File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/Users/henryschreiner/git/scikit-hep/cookie/.nox/dist-trampolim/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 236, in build_sdist
        return backend.build_sdist(sdist_directory, config_settings)
      File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/__init__.py", line 44, in build_sdist
        project = trampolim._build.Project()
      File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/_build.py", line 117, in __init__
        self.version  # calculate version
      File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/functools.py", line 969, in __get__
        val = self.func(instance)
      File "/private/tmp/build-env-cgul0fht/lib/python3.9/site-packages/trampolim/_build.py", line 289, in version
        tag, r, commit = subprocess.check_output([
    ValueError: not enough values to unpack (expected 3, got 1)
    
    ERROR Backend subproccess exited when trying to invoke build_sdist
    

    This works correctly in setuptools_scm.

    bug 
    opened by henryiii 4
  • tests: use tmp_path (PyTest 3.9+)

    tests: use tmp_path (PyTest 3.9+)

    In #20, from local testing, it is clearly an empty folder that is hanging up on Windows. I don't think it's a critical problem; I don't think it's reproducible when running non-test code. As a nicer fix, we can move to pytest's built in (3.9+) fixtures for making temporary directories (test level and session level). These stick around for ~3 days or the last three sessions, for easier debuging, and therefore don't trigger this issue. Adding -Wd didn't produce any unclosed file warnings on #20, so I think it's safe.

    opened by henryiii 1
  • Use PEP 621 metadata parser from `pep621` package

    Use PEP 621 metadata parser from `pep621` package

    I extracted the parser as the pep621 package, and afterwards made several API improvements. Our code here still has the original parser, we should replace it with the pep621 package.

    https://github.com/FFY00/python-pep621

    enhancement 
    opened by FFY00 1
  • ci: add Python 3.10

    ci: add Python 3.10

    Rather expecting this to fail, as it's failing elsewhere. But I'm getting a somewhat unrelated pep621.ConfigurationError: Missing version field error, so maybe it's not related. We'll see. Edit: Appears to be something else. pep621 is missing release notes for 0.4.0, btw.

    opened by henryiii 0
  • _build: add module-location option

    _build: add module-location option

    Also refactors mcuh of our internal path handling to use pathlib.

    I am aware that the code still isn't great, but it's good enough for now.

    Signed-off-by: Filipe Laíns [email protected]

    opened by FFY00 0
  • nox: type: improve strictness, check 3.7 & 3.9

    nox: type: improve strictness, check 3.7 & 3.9

    Touching up the type checking strictness a bit, also checking both ends. I really like pyproject.toml config for mypy much better, but left it in setup.cfg for now.

    opened by henryiii 0
  • ci: use nox

    ci: use nox

    This allows the CI to be run locally with nox -s tests-3.9 or nox -s type or nox -s docs -- serve, for example. Removes dependence on GitHub Actions.

    (I already added this to do local testing, thought it might be useful to others)

    opened by henryiii 0
  • CVE-2007-4559 Patch

    CVE-2007-4559 Patch

    Patching CVE-2007-4559

    Hi, we are security researchers from the Advanced Research Center at Trellix. We have began a campaign to patch a widespread bug named CVE-2007-4559. CVE-2007-4559 is a 15 year old bug in the Python tarfile package. By using extract() or extractall() on a tarfile object without sanitizing input, a maliciously crafted .tar file could perform a directory path traversal attack. We found at least one unsantized extractall() in your codebase and are providing a patch for you via pull request. The patch essentially checks to see if all tarfile members will be extracted safely and throws an exception otherwise. We encourage you to use this patch or your own solution to secure against CVE-2007-4559. Further technical information about the vulnerability can be found in this blog.

    If you have further questions you may contact us through this projects lead researcher Kasimir Schulz.

    opened by TrellixVulnTeam 0
Owner
Filipe Laíns
packaging for archlinux, breaking hardware and writing drivers
Filipe Laíns
💉 🔍 VaxFinder - Backend The backend for the Vaccine Hunters Finder tool.

?? ?? VaxFinder - Backend The backend for the Vaccine Hunters Finder tool. Development Prerequisites Python 3.8 Poetry: A tool for dependency manageme

Vaccine Hunters Canada 32 Jan 19, 2022
A python program with an Objective-C GUI for building and booting OpenCore on both legacy and modern Macs

A python program with an Objective-C GUI for building and booting OpenCore on both legacy and modern Macs, see our in-depth Guide for more information.

dortania 4.7k Jan 2, 2023
A modern python module including many useful features that make discord bot programming extremely easy.

discord-super-utils Documentation Secondary Documentation A modern python module including many useful features that make discord bot programming extr

null 106 Dec 19, 2022
VacationCycleLogicBackEnd - Vacation Cycle Logic BackEnd With Python

Vacation Cycle Logic BackEnd Getting Started Existing virtualenv If your project

Mohamed Gamal 0 Jan 3, 2022
A collection of modern themes for Tkinter TTK

ttkbootstrap A collection of modern flat themes inspired by Bootstrap. Also includes TTK Creator which allows you to easily create and use your own th

Israel Dryer 827 Jan 4, 2023
A Modern Fetch Tool for Linux!

Ufetch A Modern Fetch Tool for Linux! Programming Language: Python IDE: Visual Studio Code Developed by Avishek Dutta If you get any kind of problem,

Avishek Dutta 7 Dec 12, 2021
Lightweight and Modern kernel for VK Bots

This is the kernel for creating VK Bots written in Python 3.9

Yrvijo 4 Nov 21, 2021
Convert Roman numerals to modern numerals and vice-versa

Roman Numeral Conversion Utilities This is a utility module for converting from and to Roman numerals. It supports numbers upto 3,999,999, using the v

Fictive Kin 1 Dec 17, 2021
This Program Automates The Procces Of Adding Camos On Guns And Saving Them On Modern Warfare Guns

This Program Automates The Procces Of Adding Camos On Guns And Saving Them On Modern Warfare Guns

Flex Tools 6 May 26, 2022
Open-source data observability for modern data teams

Use cases Monitor your data warehouse in minutes: Data anomalies monitoring as dbt tests Data lineage made simple, reliable, and automated dbt operati

null 889 Jan 1, 2023
💻 Algo-Phantoms-Backend is an Application that provides pathways and quizzes along with a code editor to help you towards your DSA journey.📰🔥 This repository contains the REST APIs of the application.✨

Algo-Phantom-Backend ?? Algo-Phantoms-Backend is an Application that provides pathways and quizzes along with a code editor to help you towards your D

Algo Phantoms 44 Nov 15, 2022
Backend/API for the Mumble.dev, an open source social media application.

Welcome to the Mumble Api Repository Getting Started If you are trying to use this project for the first time, you can get up and running by following

Dennis Ivy 189 Dec 27, 2022
Job Guy Backend

جاب‌گای چیست؟ اونجا وضعیت چطوریه؟ یه سوال به همین کلیت و ابهام معمولا وقتی برای یه شرکت رزومه می‌فرستیم این سوال کلی و بزرگ برای همه پیش میاد.اونجا وض

Jobguy.work 217 Dec 25, 2022
XHacks 2021 Startup Track Winner: Be Heard. Educate, Enact, Empower. No voice left behind. (backend)

Be Heard: X Hacks 2021 Submission Educate, Enact, Empower. No voice left behind. Inspiration To say 2020 was an eventful year would be an understateme

null 3 Jul 14, 2022
GA SEI Unit 4 project backend for Bloom.

Grow Your OpportunitiesTM Background Watch the Bloom Intro Video At Bloom, we believe every job seeker deserves an opportunity to find meaningful work

Jonathan Herman 3 Sep 20, 2021
hey, this repo is the backend of the sociio project

sociio backend Hey, this repository is a part of sociio project , In this repo we are working to create an independent server for everything you can i

null 2 Jun 9, 2022
Backend Interview Challenge

Inspect HOA backend challenge This is a simple flask repository with some endpoints and requires a few more endpoints. It follows a simple MVP (model-

null 1 Jan 20, 2022
This is a repository containing the backend and the frontend of a simple pokédex.

Pokémon This is a repository containing the backend and the frontend of a simple pokédex. This is a work in progress project! Project Structure ?? pok

André Rato 1 Nov 28, 2021
Hopefully the the next-generation backend server of bgm.tv

Hopefully the the next-generation backend server of bgm.tv

Bangumi 475 Jan 1, 2023