Comments (8)
Perhaps this is too naive but what about just testing if 'site-packages'
is in module.__path__.split(os.pathsep)
?
EDIT: Nevermind, I think I see what you're suggesting. In other words, for importize
to properly detect local packages, the users pwd will need to be the project root? And/or you can set the project root by command-line?
I'm used to developing in an environment where I've done pip install -e .
on my project so it's importable anywhere, but the files don't live in site-packages
. However I don't know if my usage is that popular. Besides, if I can set the project root directory as a command-line flag to importanize
it's super easy to just make that an alias for each project or something along those lines.
from importanize.
This is not an easy problem to solve reliably. I think unlimately config should be used to reliably detect which libs are local because that allows to fine-tune which configs go in which order. That being said, at some point I do want to implement some sort of heuristic to try to detect at least some scenarios automatically.
As for the site-packages
, I dont think this is particularly reliable because even some stdlibs are not in site-packages
.
from importanize.
If it's not possible to automatically detect the local package, one alternative might be to allow them to be listed in the configuration file, and/or on the command line.
from importanize.
@kgaughan specifying it in config is the current behavior. the idea of this ticket is to try to determine that automatically. not sure how more complex configs can be added via command line so I think it should remain configuration based or automatically generate the config if proper heuristic can be determined
from importanize.
I think a built-in "site-packages" group (similar to "stdlib" group) would be useful, even if not automatic.
from importanize.
hmm. interesting idea. I usually use remainder
and list local libs explicitly but the reverse actually makes sense.
from importanize.
See #34
from importanize.
closing since site-packages
is already merged and released
from importanize.
Related Issues (20)
- Handle `import foo.bar as baz` properly HOT 1
- importanize hanging on 0.6.2, works on 0.6.1 HOT 3
- Treats Standard Libraries as 3rd Party Libraries on Windows HOT 3
- Identify which packages are from the Standard Library HOT 3
- Confused about the imports order. HOT 3
- bugs when configure add_imports HOT 2
- I added you to https://pre-commit.com/hooks.html HOT 2
- UnicodeDecodeError with files with utf-8 HOT 7
- Pre-commit HOT 1
- Running on __init__.py files removes all imports HOT 2
- Exclude file/dir not honored HOT 6
- pre-commit fails to run due to importanize HOT 1
- Issue running from pre-commit sets is_print_mode=True HOT 4
- Option to disable space added after comment HOT 1
- conflict with yapf on lines after imports HOT 5
- Impotanize changes line ending to OS line ending when formatting in place HOT 2
- Feature: Ignore specific lines in file HOT 2
- CLI HOT 1
- --formatter="lines" is not supported via the CLI
- importanize not grouping stdlib properly HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from importanize.