Recently, a change to Apache Airflow requires setting an environment variable SLUGIFY_USES_TEXT_UNIDECODE=yes before it is able to be installed: https://airflow.apache.org/installation.html
In my custom module's setup.py script, I'm including Airflow in the install_requires
list. So, when I try to install my custom module, it also fails looking for that environment variable to be set.
Since I have a lot of environments to install this into, I want to set that environment variable automatically in my setup.py module so it is always present. However, It doesn't seem to work if I simply put this line at the top of my setup.py or inside of the run() method of a custom subclass of install (via the cmdclass setup.py option).
os.environ['SLUGIFY_USES_TEXT_UNIDECODE'] = 'yes'
Any thoughts on how I can set an environment variable in a setup.py before any of the install_requires
dependencies are installed?
Any help is much appreciated.
It should work out-of-the-box if you run export SLUGIFY_USES_TEXT_UNIDECODE=yes
before pip install YOUR_CUSTOM_PACKAGE
.
An alternative option is to use the following in your setup.py
:
import os
os.system("export SLUGIFY_USES_TEXT_UNIDECODE=yes")
How is your custom module installed? Using wheels? Then you're out of luck as setuptools
run setup.py
at compile/package time but not at the installation time. With wheels the only solution is to set the environment variable before installation:
SLUGIFY_USES_TEXT_UNIDECODE=yes pip install …
You trick with setup.py
should work if you install from sdist (source distribution).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With