It's not currently possible (and probably won't ever be)
The entire idea of poetry is that a package can be installed without running any arbitrary Python code. Because of that, custom post-install scripts will probably never exist (from the author of poetry, the link you gave in your question).
What you could do instead
You could use setuptools, and modify the setup.py
script, but it's probably easier to remove the need for a post-install script by removing the need for a default config file.
Most Python tools, such as black, tend to assume default config parameters, unless there are settings in a config file (such as a pyproject.toml
file) that overrides them, e.g.:
[tool.black] # specifies this next section is the config for black
line-length = 88 # changes some configuration parameters from the defaults
target-version = ['py36', 'py37']
Jupyter has a command jupyterhub --generate-config
to generate a default config file (source).
If your package is a library, not a command-line tool, i.e. you use it by import
-ing it in your Python code, I'd recommend just passing in the configuration as arguments to the constructor/functions, since that's the standard way of passing config to a library.
As an example, look at PySerial's API. You can configure the library by passing args to the constructor serial.Serial
, e.g.:
import serial
with serial.Serial(
'/dev/ttyUSB0', # first config param, the port
19200, # second config param, the baudrate
timeout=5, # sets the timeout config param
) as ser: