Change folder strucutre from `src` to module name
I'm submitting a ...
- [ ] bug report
- [x] feature request
- [ ] support request => Please do not submit support request here, see note at the top of this template.
What is the current behavior?
Folder structure is like this:
- allure-pytest\
- src\
- source files (...)
- setup.py
- other files (...)
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
Modules are not available for imports when installing with pip install --editable . command.
What is the expected behavior?
We could just rename the src folder with the module name:
- allure-pytest\
- allure_pytest\
- source files (...)
- setup.py
- other files (...)
Sure it is redundant (and aesthetically I don't like it myself) but this will easy the development process until the problem with pip --editable is solved (see below).
What is the motivation / use case for changing the behavior?
The pip editable install does not work with current structure, using package_dir option:
https://github.com/pypa/pip/issues/3160
Please tell us about your environment:
- Allure version: 2.6.0
- Test framework: [email protected]
- Allure adaptor: [email protected]
Other information
due to setuptools shortcomings this is not implementable without breaking support for editable installs
Any update on this issue? I think maybe instead of renaming "src" directory you can add a subdirectory with the name of the module and change the "setup.py" files package_dir to {""}:'src'}
This way there shouldn't be any issue when the package is editable or not. @RonnyPfannschmidt do you see any issue with this kind of implementation?
As an example here's how allure-python-commons will look:
-allue-python-commons
-allure.py
-setup.py
-tox.ini
-src
-allure_commons
-__init__.py
-_allure.py
-_compat.py
-_core.py
-_hooks.py
-lifecycle.py
-logger.py
-mapping.py
-model2.py
-reporter.py
-types.py
-utils.py
And the only file that has been changed is setup.py:
from setuptools import setup, Extension
import os
PACKAGE = "allure-python-commons"
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Software Development :: Testing',
]
install_requires = [
"attrs>=16.0.0",
"six>=1.9.0",
"pluggy>=0.4.0",
"enum34;python_version<'3.4'",
]
# source_list = ["src/%s" % f for in os.listdir("src")]
# ext = Extension()
def main():
setup(
name=PACKAGE,
use_scm_version={"root": "..", "relative_to": __file__},
setup_requires=['setuptools_scm'],
description="Common module for integrate allure with python-based frameworks",
url="https://github.com/allure-framework/allure-python",
author="QAMetaSoftware, Stanislav Seliverstov",
author_email="[email protected]",
license="Apache-2.0",
classifiers=classifiers,
keywords="allure reporting report-engine",
packages=["allure_commons"],
package_dir={"":'src'},
install_requires=install_requires,
py_modules=['allure', 'allure_commons']
)
os.rename
if __name__ == '__main__':
main()
@TomaiMoneyhon that sound sensible, while at it i would also strongly recommend to use the find_packages feature instead of searching them on your own and going for setup.cfg support in recent setuptools
@RonnyPfannschmidt What you mean is to basically change packages parameter to find_packages() right?
yeah, its not nicely clear what to do as you have modules and packages in different places and its all a mixed bag of pitfalls
@RonnyPfannschmidt Understood Thanks!! Will try to push this to the master branch even!
Could anyone explain how to deal with repo in development mode please. I'm trying to pip install -e . in each package, but I still have 'no module' issues during import process. I need to have an opportunity to contribute and test my code by my own.
BTW I tried setup.py develop. It does not help either.
Editable install now works fine. At least with py3.7+ and setuptools 64+
@Denis-Alexeev , just in case: Basic dev environment could be established as follows (on linux, from the root of the repo):
python -m venv .venv
echo "/**/*" > ./.venv/.gitignore
source ./.venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
pip install -e ./allure-python-commons
python -c 'import allure; print("No Error!")'
I'm closing the issue now. If I have missed something important here, please, feel free to reopen.